Expand btrfs volume

Topics: btrfs

When I ran out of disk space on my development VM’s /home volume, I used the “Resize” disk action to add 40 GB to the virtual hard drive in the Proxmox hypervisor. Then I expanded the partition and the btrfs volume to use the added space.

Probing the newly added disk space:

$ sudo partprobe /dev/sda
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 83886080 blocks) or continue with the current setting?

Expand partition number 3:

$ sudo parted /dev/sda
(parted) p
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 83886080 blocks) or continue with the current setting?
Fix/Ignore? f
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 129GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  630MB   629MB   fat32        EFI System Partition  boot, esp
 2      630MB   2778MB  2147MB  ext4
 3      2778MB  85.9GB  83.1GB  btrfs

(parted) resizepart 3 100%
Warning: Partition /dev/sda3 is being used. Are you sure you want to continue?
Yes/No? yes
(parted) p
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 129GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  630MB   629MB   fat32        EFI System Partition  boot, esp
 2      630MB   2778MB  2147MB  ext4
 3      2778MB  129GB   126GB   btrfs
(parted) q

Finally, expand the filesystem:

$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        78G   74G  1.2G  99% /home

$ sudo btrfs filesystem resize max /home
Resize device id 1 (/dev/sda3) from 77.41GiB to max

$ df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       118G   74G   42G  65% /home

Bookmarks

Questions