Hi! I’m learning how to use btrfs and I need some advice.

One one of my desktop, I made the mistake of creating 2 partitions, one for /(root) and one for home. Both are btrfs. I didn’t know that I could use subvolumes so that they could share the same physical space.

My question: How can I merge the root and home btrfs partitions into only 1 partition that would use btrfs subvolumes?

I’m looking for something like that:

  • Partition1 (btrfs)
    • subvolume 1: @root (mounted to /)
    • subvolume 2: @home (mounted to /home)
  • Partition 2, 3, 4…

My current setup:

  • 1 physical hard drive (1 TB), shown as sda below
  • The partitions I want to merge are sda7 and sda8
  • That computer is an iMac also running MacOS so it has a few other partitions that I should not touch
$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 931,5G  0 disk 
├─sda1   8:1    0   200M  0 part /boot/efi
├─sda2   8:2    0 371,1G  0 part 
├─sda3   8:3    0 619,9M  0 part 
├─sda4   8:4    0   600M  0 part 
├─sda5   8:5    0  1023M  0 part 
├─sda7   8:7    0 422,9G  0 part /home
└─sda8   8:8    0 135,1G  0 part /
sdb      8:16   1     0B  0 disk 
sr0     11:0    1  1024M  0 rom  
$ blkid
/dev/sda4: UUID="d970eea2-142b-3f1c-9650-5e496d1e9b4b" BLOCK_SIZE="4096" LABEL="Linux HFS+ ESP" TYPE="hfsplus" PARTLABEL="Linux HFS+ ESP" PARTUUID="eab00592-b96d-4ecb-b2e9-816c95eaf860"
/dev/sda2: UUID="6a26963c-eabb-3e42-9e8d-8677a8282b61" BLOCK_SIZE="4096" LABEL="DD Macintosh" TYPE="hfsplus" PARTLABEL="DD Mac" PARTUUID="8257316c-1fd7-4885-bf2b-7e99557acd85"
/dev/sda7: UUID="22f5e59e-8509-484a-92d5-e7dc03bb70cd" UUID_SUB="78a998f5-db55-4a31-9506-afe548ec8d5e" BLOCK_SIZE="4096" TYPE="btrfs" PARTLABEL="Mint Home" PARTUUID="20b6c31d-5e2d-416f-beb3-faa295af67df"
/dev/sda5: UUID="587b0093-4b64-468a-9a01-b933630d184b" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="a47a3fbf-534a-435d-8916-0f83edebf296"
/dev/sda3: UUID="d0c171e8-572d-39f9-8bdc-38f33744a19a" BLOCK_SIZE="4096" LABEL="Recovery HD" TYPE="hfsplus" PARTLABEL="Recovery HD" PARTUUID="c9d0673b-bb2e-4322-9bf9-c661f7de6856"
/dev/sda1: LABEL_FATBOOT="EFI" LABEL="EFI" UUID="67E3-17ED" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="d30954cb-b9b6-40fa-9202-a18cf146f7df"
/dev/sda8: UUID="7027382a-4369-4276-b916-9997c1007e5b" UUID_SUB="3e516464-dee1-4bda-9621-29591d54dc2d" BLOCK_SIZE="4096" TYPE="btrfs" PARTLABEL="Mint root" PARTUUID="f2fdb8cc-54fd-46c8-bf1f-85954c1dc363"
  • narF@lemmy.caOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    4 months ago

    Can I do this while the system is running? I guess it would be safer to boot to a liveUSB before attempting this?

    Also, what do you mean by “After a rebuild of the initrd” ? That’s something I have to do after editing fstab? How do I do that?

    • Atemu@lemmy.mlM
      link
      fedilink
      arrow-up
      1
      ·
      4 months ago

      You can generally do almost anything to a btrfs while the system is running with the filesystem mounted. In fact, most operations require the btrfs to be mounted.

      You should keep a live USB handy though in case you mess up. Oh and also verify that you have a sufficient amount of backups of your important data. 1 copy can turn into 0 copies quite quickly. Rule of thumb places the minimum at 3 copies.

      what do you mean by “After a rebuild of the initrd” ? That’s something I have to do after editing fstab? How do I do that?

      Yes, for modifications to the root mount, you must rebuild the initrd for those changes to actually be applied where it matters.

      How this is done fully depends on the distribution and is one of the more significant technical details that differ between just about every distro family. Consult your distro’s documentation on that.