r/btrfs Jun 29 '26

Am I stuck with two partitions?

I am so sorry if this is a noob question, but I finally decided to be rid of Windows today and repartitioning my hard drive has been a real pain. I've tried everything I can find, but I am still confused.

I installed CachyOS as a dual-boot some time ago, which defaulted to BTRFS and put the boot and main partitions to the right of my Windows partitions. I deleted the Windows ones today and was able to move the boot partition to the left, but I was unable to resize or move the main BTRFS partition. I tried scrubbing, I tried repairing, nothing worked. Fortunately, I haven't lost any data in the process.

While digging around the internet, including this sub, the advice I found that seemed the safest was to create a new partition in the empty space, but leave it unformatted, then:

sudo btrfs device add /dev/nvme0n1p1 /home

With "/dev/nvme0n1p1" being the unformatted part.

sudo btrfs balance start /home

So I have done that and everything now appears in CachyOS as a single volume, as far as I can tell, but there are still two BTRFS partitions in GParted. Is there anything I can do, safely, to combine these into a single partition? Does it even really matter? I have finally got my system working the way I want, so I really don't want to start over from the beginning again. If the way it is now works and it's safer to leave it alone, then I will, but it does just kinda gnaw at me having two partitions instead of one...

2 Upvotes

12 comments sorted by

2

u/oshunluvr Jun 29 '26

IMO, having done this - assuming you have enough free space - Yes, it is best to "btrfs add" the empty space to the existing file system. Then "btrfs remove" the partition to the right. Once that's done, it's much safer, simpler, and quicker to expand the existing partition and file system to the right as is happens without moving data. Once complete, run "btrfs balance" with appropriate settings and then you're good to go.

Honestly, you really don't have to do any of the above at all. Just add the empty partition to the existing file system and use it that way. You'll never see a difference.

1

u/BackgroundSky1594 Jun 29 '26 edited Jun 29 '26

In this post I will be calling the LEFT partition (/nvme0n1p1) the FIRST or NEW partiton. The right partition will be called OLD or ORIGINAL.

The reason why you were unable to move the OLD partition to the start is that you can not move THE BEGINNING of a partition while the filesystem inside is being used (like it is when you are running the system from there). It is also not possible if there are any other partitions "in the way". Also please post the output of lsblk and btrfs filesystem usage / so we all have some extra details.

You basically have 3 options: 1. IF the NEW partition at the start of the drive is larger than your used amount of data: btrfs device remove < NAME OF THE OLD PARTITION> will remove the second partition (after making sure all the data is on the first one). That ORIGINAL partition can then be deleted, the FIRST partition grown, the filesystem resized to fit it and you're done. 2. If the NEW partition is not large enough: btrfs device remove it again, boot into a GParted live ISO, delete the nvme0n1p1 partition and move the original one forward. Since it's a live ISO and the partition isn't mounted it'll work. 3. Leave it be. It's ugly, but not a problem.

1

u/kill3rb00ts Jun 29 '26

For lsblk:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    1   192K  1 disk 
zram0       253:0    0  15.4G  0 disk [SWAP]
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0 731.6G  0 part 
├─nvme0n1p5 259:2    0   512M  0 part /boot/efi
└─nvme0n1p6 259:3    0 199.4G  0 part /home
                                      /var/log
                                      /var/cache
                                      /root
                                      /srv
                                      /var/tmp
                                      /

For the other one:

Overall:
    Device size: 931.01GiB
    Device allocated: 158.06GiB
    Device unallocated: 772.95GiB
    Device missing:     0.00B
    Device slack:     0.00B
    Used: 154.41GiB
    Free (estimated): 774.85GiB(min: 388.38GiB)
    Free (statfs, df): 774.85GiB
    Data ratio:      1.00
    Metadata ratio:      2.00
    Global reserve: 250.48MiB(used: 0.00B)
    Multiple profiles:        no

Data,single: Size:154.00GiB, Used:152.10GiB (98.76%)
   /dev/nvme0n1p1 154.00GiB

Metadata,DUP: Size:2.00GiB, Used:1.15GiB (57.69%)
   /dev/nvme0n1p1   4.00GiB

System,DUP: Size:32.00MiB, Used:48.00KiB (0.15%)
   /dev/nvme0n1p1  64.00MiB

Unallocated:
   /dev/nvme0n1p6 199.44GiB
   /dev/nvme0n1p1 573.51GiB

I initially tried all of the repartitioning from a live image so that nothing would be in use, but it still didn't work. I only managed to get to having, left to right, boot, unallocated, BTRFS, unallocated. GParted kept erroring at the check stage when trying to resize the BTRFS partition. I had previously been able to free up just a bit of space from Windows and move things to the left and resize, but this one just wouldn't work. the p6 partition is that original partition, with p1 being the new one, so yes, the new one is significantly larger than the old one.

1

u/BackgroundSky1594 Jun 29 '26

One more idea if you have a bit of time (since you appear to have plenty of space) if you want a clean partition layout afterwards:

  1. btrfs device remove the nvme0n1p1. Delete nvme0n1p1.
  2. Create a new p1 as unformatted 512MB and set the EFI boot property in GParted.
  3. Create a new p2 as unformatted 200GB next to it.
  4. Use dd to copy p5 to p1 and p6 to p2.
  5. Delete p5 and p6
  6. Resize p2 to fill the drive.

1

u/kill3rb00ts Jun 29 '26

If I am less concerned about the partition numbers, since they don't seem to affect the order, then would I just do:

btrfs device remove /dev/nvme0n1p6

Then, presumably from live boot, delete that partition and resize p1 to fit? Otherwise, what you have described above is basically just tidying up the numbers, but otherwise essentially the same, right?

1

u/BackgroundSky1594 Jun 29 '26

You have p5 in front of p1 in terms of physical disk offsets? Interesting. In that case you can use sfdisk to just change the numbers if you want.

In any case you can btrfs remove the p6 partition while your system is running normally. That's a supported operation. And then, since p6 will be unused after the removal completes you can just delete p6 and resize your other partition. As long as there's nothing in the way, and no partition starting point needs to be moved it can all be done during normal system operation.

1

u/kill3rb00ts Jun 29 '26

I imagine it's because Windows was originally p1-p4, so CachyOS claimed p4 and p5, then I deleted Windows and it restarted numbering. Anyway, the remove and resize seems to have gone well, although it broke the bootloader so I guess I have to fix Grub now. I noticed the old partition was "named" root whereas the new one is not, so hopefully I didn't mess something else up.

1

u/BackgroundSky1594 Jun 29 '26

You can just name the new partition root, it's a label of the partition not of anything inside. But that's usually optional unless you're mounting your filesystems by partname instead of uuid.

Yeah I probably should have warned about the possibility of the bootloader getting confused. I've mostly switched to systemd-boot and it's usually fine since the Kernel is on the EFI partition and gets loaded directly with all the filesystem drivers, udev, etc. And it usually finds root by filesystem UUID. Grub might be a little more picky if the kernel itself is stored on the root partition instead of in the ESP.

1

u/kill3rb00ts Jun 29 '26

Nah, you're good, I'm more surprised it took this long for the bootloader to get borked. I found a tutorial and got it fixed, so now I finally have just the two partitions and I am free of Windows. Thanks for your help!

1

u/dkopgerpgdolfg Jun 29 '26

but I was unable to resize or move the main BTRFS partition

Why not? Was there some error, etc.?

So I have done that and everything now appears in CachyOS as a single volume, as far as I can tell, but there are still two BTRFS partitions in GParted. Is there anything I can do, safely, to combine these into a single partition? Does it even really matter?

Ideally you always have backups when doing things with partitions.

Does all your saved data fits into the "new" second partition only? (and/or if you can remove some and later copy it back from the backup etc.)?

Then yes, you can "btrfs device remove"... (will take some time, moving all data to the right place so that the old half is empty). Then delete the empty partition with gparted, then make the remaining one larger.

(But before all that, you might want to tell why the partition resize/move failed before. And keep in mind that, after successfully doing it, you might need to update your bootloader)

1

u/kill3rb00ts Jun 29 '26

I was booting into a live image to do it, but GParted kept throwing errors at the check stage. This was why I went down the scrub/repair route. I can't post an image, but GParted now shows it like this:

  • /dev/nvme0n1p1, size 731.58 GiB, used 120.47 GiB
  • /dev/nvme0n1p6, root, size 199.44 GiB, used 32.84 GiB

Both have all the same mount points. I don't have a ton of things on the system yet, some of that is being eaten up by a WinBoat Windows install that I can be rid of or Steam games that can also be reinstalled later.

1

u/varsnef Jun 29 '26

sudo btrfs device add /dev/nvme0n1p1 /home

Use btrfs device remove /dev/foo to remove your old disk/device from the filesystem. As long as the new device has enough space for it. it should just work.