Jump to content

Create BTRFS subvolumes by default


Recommended Posts

Under Ubuntu when you install using BTRFS and Debian when you install to BTRFS using the Calamares live GUI installer, both installers create a subvolume called @home for the /home directory and another subvol called @ for the rest of the filesystem. This layout enables users to use timeshift to easily (and automatically with timeshift-autosnap-apt) create BTRFS snapshots and restore them using the command line or the timeshift GUI and restore their OS whilst optionally keeping users files stored under /home intact.

 

I would like to see the armbian installation script configure BTRFS in this same manner.

Edited by danboid
Link to comment
Share on other sites

This is a pretty easy add. Basically after creating the btrfs filesystem, mount the LOOP and create the subvolume, now unmount the LOOP and remount it with the correct flags.

 

Lets pretend these are the variables.

P_ROOTFS="/mnt/p1"

IMAGE_LOOP_DEV_ROOTFS="/dev/loop1p1"

 

mkfs.btrfs -f -L ROOTFS ${IMAGE_LOOP_DEV_ROOTFS}
mount "${IMAGE_LOOP_DEV_ROOTFS}" ${P_ROOTFS}
btrfs subvolume create ${P_ROOTFS}/@
umount ${P_ROOTFS}
mount -o compress=lzo,noatime,subvol=@ ${IMAGE_LOOP_DEV_ROOTFS} ${P_ROOTFS}

 

Where all this would reside in the Armbian framework, I'm not really sure? But in general it wouldn't take that much effort to introduce. One issue I can see popping up, is that U-Boot "last I checked?" doesn't support BTRFS subvolumes. So if subvolumes were an option, the image would require a VFAT or EXT4 BOOT partition.

 

Link to comment
Share on other sites

Thanks for that c0rnelius!

 

I was unaware that u-boot (probably still) doesn't support BTRFS subvols. Hopefully they can add that so we'd be able to avoid the extra boot partition.

 

I will look into that today.

EDIT

It looks like it does have subvol support :

https://github.com/u-boot/u-boot/blob/master/fs/btrfs/subvolume.c

Edited by danboid
Link to comment
Share on other sites

I've seen that in there too, but I've never been able to get a subvolume to boot without using a boot partition. There is also CONFIG_CMD_BTRFS and I could be completely off here, but my thought was maybe a command needs to be executed with a boot script in order for the subvolume to be read/found? I normally use extlinux and with CONFIG_FS_BTRFS & CONFIG_CMD_BTRFS enabled it has always been a no go for me. Maybe someone else here has a thought on the subject?

 

EDIT

 

I tried 3 times getting this working using a Radxa Zero and it was a no-go for a single partition. Once I added a boot partition, it booted right up.

 

radxazero: ~  $ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
mmcblk0      179:0    0 29.7G  0 disk 
├─mmcblk0p1  179:1    0  253M  0 part /boot
└─mmcblk0p2  179:2    0 29.5G  0 part /
mmcblk1      179:32   0 14.6G  0 disk 
├─mmcblk1p1  179:33   0  253M  0 part 
└─mmcblk1p2  179:34   0 14.3G  0 part 
mmcblk1boot0 179:64   0    4M  1 disk 
mmcblk1boot1 179:96   0    4M  1 disk 
zram0        253:0    0    1G  0 disk [SWAP]
radxazero: ~  $ findmnt /boot; findmnt /
TARGET SOURCE         FSTYPE OPTIONS
/boot  /dev/mmcblk0p1 ext4   rw,relatime
TARGET SOURCE             FSTYPE OPTIONS
/      /dev/mmcblk0p2[/@] btrfs  rw,noatime,compress=lzo,ssd,space_cache=v2,subvol


 

Edited by c0rnelius
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines