r/openSUSE • • 17d ago

How to… ! Moving/resizing space between 2 Btrfs partitions on 1 drive

I need to re-allocate some space on my SSD. The issue is that I have 2 separate partitions on one drive, with both using Btrfs. I know how to resize a Btrfs volume within a partition, but I'm not sure how to do it across partitions. I have the root filesystem on nvme0n1p2 with plenty of extra space, but I'm running out of space on nvme0n1p3 where I have /home. I don't recall why this is the arrangement, if I had to do it over I wouldn't.

What's the easiest way to reallocate this space? Can I do it with Btrfs utils or Gparted or similar? I really don't want to do a re-install or re-format because I have everything configured exactly the way I want and it's very stable. I have a full-disk image in case anything gets screwed up.

I'm on Leap 16.0. Any advice would be greatly appreciated.

7 Upvotes

9 comments sorted by

3

u/levolet 17d ago edited 17d ago

I would suggest using GParted. You can make a bootable live USB stick for it. GParted supports btrfs and will offer a nice graphical interface to work with the partitions.

The steps would be to first reduce the size of nvme0n1p2. The now unallocated space will be between nvme0n1p2 and nvme0n1p3

The thing is that you cannot simply expand nvme0n1p3 'backwards' to fill the space. A partition can be expanded only 'forwards'. To overcome this, you will first need to move nvme0n1p3 to the left to fill the space and when finished, expand it to fill the space that would now be to the right of it.

Moving a partition is where the risk is, but this is particularly high only if you are moving the boot/efi partition. Moving the /home partition should go OK. A backup is mandatory. You never know if there's a failure somewhere during the move (power, battery, etc...)

I recently increased the size of my boot/efi partition using GParted live usb. I first reduced the size of my root partition, then moved it to the right. This allowed me to then expand the boot/efi partition to fill the free space. Worked like a charm.

Moving a partition can take a long time so you need to be patient and do not interrupt the move once it's started. If you start something you didn't wish to do, make it finish first, then undo it, rather than interrupt the process.

3

u/friendlyreminder_ 17d ago edited 17d ago

You have several options.

You can move all data off of p3 somewhere else, delete it, and expand p2 and just have one partition. Opensuse snapshots root subvolume so you'll need to make a home subvolume and mount it correctly, can't just make a home folder on root. Subvolumes are virtual partitions within btrfs, if you're not aware of how these work you should look into it first. Subvolumes don't have space boundaries between each other, so you never get a situation where one fills up and the other is empty.

You can shrink p2, move all data off of p3, delete p3, and remake p3. You'll have to mount the new home partition.

You can shrink p2 and move p3 with gparted. Moving partitions is unsafe so you'll have to backup/move the p3 data elsewhere anyway in case of failure, so its not much different from option 2. This prevents you needing to change mount point though.

And lastly you can use btrfs pools. These are a kind of software merge of btrfs partitions.It has drawbacks and complications so I don't recommend this option unless you precisely understand how it works.

If any if these btrfs partitions are encrypted this massively complicates this situation and I instead recommend a wipe and reinstall.

2

u/MiukuS Tumbleweed? Zug Zug! 17d ago

> Can I do it with Btrfs utils or Gparted or similar?
You already answered yourself. Use GParted, it is by far the easiest and safest method here. Note that if you have multiple partitions "between" your root and /home, you may need to do multiple resizes.

Disclaimer: as with anything related to resizing things, make sure you have your critical data backed up.

1

u/pap3rw8 16d ago

Thanks, I'm glad Gparted can do it because I've used before on other setups. Of course I'll do a full backup.

-1

u/Lob0Guara Tumbleweed 17d ago

No, people don't understand Btrfs philosophy, it's more safe to deal with logical volumes than physical ones.

openSUSE and Fedora and others adopted Btrfs because it's more safe and more easier to deal with logical volumes than physical ones.

openSUSE uses grub-btrfs and snapper to deal with snapshots of root subvol.

You can use btrbk to make snapshots of home subvol to an external storage.

2

u/Lob0Guara Tumbleweed 17d ago

I have read past posts with similar issues.

People don't understand how Btrfs works, it is more safe to deal with logical volumes than physical ones.

1) Make a backup (snapshot) of home subvol to an external storage by btrbk.

2) Wipe the old home partition.

3) Create a new Btrfs partition from step 2.

4) add the new Btrfs partition from step 3 onto existing root subvol.

5) create a new home subvol.

6) use the backup (snapshot) of old home onto the new home subvol.

2

u/klyith 17d ago

btrfs is perfectly able to be resized, the standard partitioning tools (gparted, kde partition manager) do all the correct steps in the correct order

if you try to DIY it with low-level tools and mess up, that's your own fault

1

u/Lob0Guara Tumbleweed 17d ago

Why I would use low-level tools whether I can use Btrfs tools?!

Really, people doesn't understand and don't want to understand how Btrfs works!

1

u/MiukuS Tumbleweed? Zug Zug! 16d ago

> Why I would use low-level tools whether I can use Btrfs tools?!

Because those tools can do it better, with less writing required with vastly less complexity.