I have had problems with my 40GB root partition and want to transfer space from a second 400GB partition. I have BTRFS installed on top of LVM. For some reason, OpenSUSE decided this for me an installation time and I considered it made sense:

# lsblk
sda               8:0    0 464.5G  0 disk 
`-sda1            8:1    0 464.5G  0 part 
  |-system-swap 254:0    0     2G  0 lvm  [SWAP]
  |-system-root 254:1    0    40G  0 lvm  /
  `-system-opt  254:2    0 422.5G  0 lvm  /optLVM
sr0              11:0    1  1024M  0 rom  

# btrfs filesystem show
Label: none  uuid: 681e689d-1ac2-48ac-9fba-f6a6e234e9f5
    Total devices 1 FS bytes used 28.40GiB
    devid    1 size 40.00GiB used 35.53GiB path /dev/mapper/system-root

Label: none  uuid: 90b22bed-5924-425d-ac30-03279f970fa0
    Total devices 1 FS bytes used 159.43GiB
    devid    1 size 300.00GiB used 299.04GiB path /dev/mapper/system-opt

As you see, /dev/mapper/system-opt only has 300GB, so I have 100 GB free there as I did a btrfs resize to free 100 GB.

My problem is that I don't know how to add those 100GB into / directory (/dev/mapper/system-root). I have tried:

# btrfs device add /dev/mapper/system-opt /
/dev/mapper/system-opt appears to contain an existing filesystem (btrfs).
Use the -f option to force overwrite.

It seems OpenSUSE formats btrfs on top of dm-1 and dm-2 which probably map to LVM volumes.

# btrfs device usage /
/dev/dm-1, ID: 1
   Device size:            40.00GiB
   Data,single:            33.00GiB
   Metadata,single:         2.50GiB
   System,single:          32.00MiB
   Unallocated:             4.47GiB
# btrfs device usage /optLVM
/dev/dm-2, ID: 1
   Device size:           422.50GiB
   Data,single:           297.01GiB
   Metadata,single:         8.00MiB
   Metadata,DUP:            2.00GiB
   System,single:           4.00MiB
   System,DUP:             16.00MiB
   Unallocated:           988.00MiB

Can I do?

 btrfs device add /dev/dm-2 /

To make / (root btrfs "partition") get the Unallocated 100GB in the dm-2 partition?


dm-# is device multipath, so basically btrfs partitions are being treated as LUNs.

The resize option works to expand partitions as well as reduce them.

 btrfs filesystem resize +100G /

You may need to do something similar at the device level first to move the free space to the logical drive that holds the root partition.

btrfs reference at kernel.org seems to show that the command I listed may do the trick.

  • I have tried that and just that does not work as / already has all available space already used (40 GB, I get a no enough free space error). / directory is in /dev/dm-1, what i really need is adding the unallocated space in /dev/dm-2 into /, and the executing the command you propose. – icordoba Nov 15 '16 at 17:13
  • I did not find a command to resize volumes. Looks like the process you're trying to follow would be better done on a single volume with subvolumes instead of multiple volumes. I do not understand the configuration of your openSUSE install. – Xalorous Nov 15 '16 at 17:28
  • Yes, I made the wrong decision creating 2 lvm partitions and on top of them, btrfs, but for some reason OpenSUSE suggested this. I now wonder how to solve it. Is there not a way to make the btrfs unallocated blocks of a partition to be used by a different btrfs volume? – icordoba Nov 15 '16 at 17:30
  • To me this looks like a limitation of btrfs. – Xalorous Nov 15 '16 at 17:41

It looks like your BTRFS filesystems are stored on LVM logical volumes. In LVM, logical volumes are made up of chucks (extents) which come from physical volumes (disk partitions) which are grouped together as a single unit known as a volume group. For example, in your case it looks like the OpenSUSE installer did the following:

  1. Created an LVM physical volume on /dev/sda1 (ex. pvcreate /dev/sda1)
  2. Created an LVM volume group named system (ex. vgcreate system /dev/sda1)
  3. Created the LVM logical volumes swap, root, and opt.

You can confirm this with the commands pvdisplay, vgdisplay, and lvdisplay.

Your system volume group has 464.5G of storage it can divide up into logical volumes. So reallocating 100G from opt to root is a matter of:

  1. Shrinking the /optLVM filesystem (which you've done).
  2. Shrinking the opt logical volume with lvreduce. Be careful with this. If you shrink it too much you'll ruin /optLVM
  3. Resizing the root logical volume with lvresize to give it the additional 100G.
  4. Resizing the / filesystem to inhabit the additional space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.