2

I have a Debian 11 system on VirtualBox VM, and I am now trying to increase its disk size.

I create this Debian 11 with btrfs file system for my main division at the beginning, so right now, it should already run on btrfs system with my existed volume.

What I already done:

use fdisk to create a new section from the volume I added in my vdi file use order fdisk /dev/sda, the new section called /dev/sda4

and

mkfs.btrfs -L extand /dev/sda4 

to make it a btrfs file system.

so right now:

fdisk -l shows:

Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A5328659-9CBF-49AE-BF68-F9F4670D45C8

Device        Start      End  Sectors  Size Type
/dev/sda1      2048  1050623  1048576  512M EFI System
/dev/sda2   1050624  2050047   999424  488M Linux filesystem
/dev/sda3   2050048 16775167 14725120    7G Linux LVM
/dev/sda4  16775168 52428766 35653599   17G Linux filesystem


Disk /dev/mapper/debian--vg-root: 6.03 GiB, 6476005376 bytes, 12648448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/debian--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

btrfs filesystem show :

Label: none  uuid: 3ea73e8c-64ac-442c-8c88-2675908cecdd
        Total devices 1 FS bytes used 4.68GiB
        devid    1 size 6.03GiB used 6.03GiB path /dev/mapper/debian--vg-root

Label: 'extand'  uuid: ef622e2c-9c19-415e-a8d7-6e60ef448bc2
        Total devices 1 FS bytes used 192.00KiB
        devid    1 size 17.00GiB used 536.00MiB path /dev/sda4

df :

Filesystem                  1K-blocks    Used Available Use% Mounted on
udev                           990920       0    990920   0% /dev
tmpfs                          201748   20780    180968  11% /run
/dev/mapper/debian--vg-root   6324224 5103168         0 100% /
tmpfs                         1008720       0   1008720   0% /dev/shm
tmpfs                            5120       0      5120   0% /run/lock
/dev/sda2                      481642   87234    369423  20% /boot
/dev/sda1                      523244    3484    519760   1% /boot/efi
tmpfs                          201744       0    201744   0% /run/user/0

What should I do next?

I tried the resize2fs, that doesn't work on btrfs file system, and I don't know how and where to mount the /dev/sda4 to use btrfs filesystem resize order.

1 Answer 1

1

Sorry to inform you, but it seems you made quite a lot of mess.

The issue started long before you did extension even, already at install.

Whole point of ZFS (and its filesystems) and BTRFS (and it subvolumes) is to replace obsolete last century ideas like LVM.

Both ZFS and BTRFS are their "own LVMs", ie you don't need one, so why do I see your root / BTRFS pool instantiated from /dev/mapper/debian--vg-root LVM device (which I presume is layered on top of /dev/sda3) ?

Unless you have some very specific reason to do such silly layering, this is quite wrong.

Given your visor (vbox) and single disk vm system, your process should have been:

  1. increase disk size in the visor
  2. instruct guest to rescan the disk size (or whole storage bus ) - if disk size did not increase already - you can check in kernel log through dmesg(1)
  3. edit partition table and stretch last partition (hosting your root)
  4. after your partition is stretched you can issue: # btrfs filesystem resize max /

Instead you did:

  1. Installed BTRFS on top of LVM

Some time later:

  1. Increased disk size in the visor
  2. Instructed guest to rescan the disk size
  3. Added new partition(!) to the partition table
  4. Formatted this new partition to new BTRFS pool and labelled it "extand" (cool name by the way :))

How to fix it

Start a new VM. If you are on Windows I suggest you to get rid of VirtualBox and replace it with HyperV, if you can (you need windows 10 something) management and performance characteristics and virtual hw support are day and night between them, in favor of HyperV that is. Plus your HyperV VM can run even if you are logged out.

Ensure following layout:

Device        Start      End  Sectors  Size Type
/dev/sda1      2048  ???????  ???????  512M EFI System
/dev/sda2   ???????  ???????  ???????  488M Linux filesystem # I assume this is /boot)
/dev/sda3   ???????  ???????  ???????   **G Linux filesystem # <- this will be your btrfs

If you need swap either put it on different disk, or, if you know size beforehand, put it in front of btrfs partition to minimize hassle:

Device        Start      End  Sectors  Size Type
/dev/sda1      2048  ???????  ???????  512M EFI System
/dev/sda2   ???????  ???????  ???????  488M Linux filesystem # I assume this is /boot)
/dev/sda3   ???????  ???????  ???????   7G Linux filesystem # <- swap prepends btrfs
/dev/sda4   ???????  ???????  ???????   **G Linux filesystem # <- this will be your btrfs

Once you consume all the space on /dev/sda3 (/dev/sda4 respectively) you just extend the disk in visor, and reedit partition size with fdisk, parted, cgdisk or what have you, an then do btrfs filesystem resize on the /.

14
  • why do u think btrfs makes lvm obsolete? you can have lvm -> btrfs without any problems. I don't know of any way how you can extend a btrfs over multiple disks like you can do when using lvm. Jun 27, 2022 at 11:09
  • 1
    @AlexOnLinux btrfs device add ... makes it trivial to "extend a btrfs over multiple disks".
    – rickhg12hs
    Jun 27, 2022 at 14:42
  • @rickhg12hs i thought that command is to add more disks to a raid0 or raid1 - this is really somethink i have to get into it. So instead of partitions then I have to work with subvolders only? Jun 27, 2022 at 18:48
  • @AlexOnLinux I am fully aware you can have BTRFS on top of LVM, in some special setups that is the only way even. Now please explain to me what exactly do you gain by introducing the LVM to the mix in the normal circumstances? What problem or what benefits introduction of one very complex layer under another very complex layer brings?
    – etosan
    Jun 27, 2022 at 23:24
  • Don't get me wrong, @AlexOnLinux this is unix, you can have chicken under the cheese under salad on top of bread on top of pizza on top of ricecake. But even if you can, it does not mean you should.
    – etosan
    Jun 27, 2022 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .