You are not logged in.

#1 2014-07-12 04:32:39

markc
Member
From: Gold Coast, Australia
Registered: 2007-05-15
Posts: 502
Website

How to setup a btrfs subvolume and boot onto it

I have backed up my previous laptops Arch install onto an external drive and now I have a new laptop with btrfs and I would like to rsync my previous Arch into a subvolume so I can boot into it separetely from the main current OS. Being new to btrfs, and not wanting to destroy my new installation, I was hoping someone could provide some generic step by step instructions on how to create a bootable btrfs subvolme (the rsync step is easy) and how to tweak grub to boot onto it?

Offline

#2 2014-07-12 06:01:44

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: How to setup a btrfs subvolume and boot onto it

Its pretty simple actually.  You create a subvolume and you can mount the filesystem from that point.  So say I were to do:

# btrfs subvolume create /rootfs 

I could then mount it with:

# mount -o subvol=rootfs /dev/sda1 /mnt 

Thus, to make it so that you can mount that filesystem as the rootfs, you would need pass that mount option when the machine is booting.  This is typically done in the fstab.  But there is a small problem there since the initramfs will first mount the partition looking for /sbin/init, using the kernel command line to figure out what to do.  So you will have to modify your kernel command line in order to get it to mount the proper thing.  This can be done with the rootflags= option.

Alternatively, you can specify /rootfs as the default subvolume.  This will make it so that if you pass no mount options to it, it will mount at subvol=rootfs.

You should do some reading about btrfs on the btrfs wiki (the actual btrfs wiki).  Some basic knowledge about how to use things and the various tools that ship with the progs would take you a long way.  It might also keep you from unnecessarily doing various recovery things that might totally wreck the filesystem.  Remember that btrfs is still in very active development.  Make sure you have tested backups.

Offline

#3 2014-07-12 06:12:16

Pse
Member
Registered: 2008-03-15
Posts: 413

Re: How to setup a btrfs subvolume and boot onto it

See here: https://wiki.archlinux.org/index.php/Bt … _subvolume

If you are going to use a MBR/GPT partition to contain a bootable Btrfs filesystem, remember to leave at least 1MB from the beginning of the disk to leave room for GRUB files. If you are going to skip partitions and let Btrfs manage the whole device, just follow the steps in the link above.

Offline

Board footer

Powered by FluxBB