2

I'm trying to move my root subvolume to another drive. I've booted into a live disc, ran "cp -a /mnt/sdb/@ /mnt/sda", fixed my FSTAB, and reinstalled grub. However when I boot up I can see that both subvolumes are mounted on / and I'm really confused.

1 Answer 1

1

When booting, the kernel doesn't see the fstab file yet, so changing the file is not enough. The place the kernel takes information when booting is Grub (now Grub 2). But to modify the grub.cfg, you need first to know, what is the name of the root subvolume, you just created.

What exactly is the name of your root subvolume on the other drive? Make sure it is mounted, and check it with

sudo btrfs subvolume list /

You might want to change the name of that subvolume to something, that starts with "@" - its an Ubuntu convention - and it is mounted in the "root" directory of the btrfs partition.

Now, when you know what is the name of the root subvolume, go to /boot/grub/grub.cfg and change all references from "@" to the new name (including the possible path).


Now, if you want mount the given subvolume on the "root" directory of the btrfs, instead of as some directory under the existing subvolume, you need to follow this steps:

  1. Mount your target btrfs partition manually, in e.g. /mnt/btrfs by using

    sudo mount /dev/sda2 /mnt/btrfs

(assuming the partition holding the btrfs is /dev/sda2). This will mount the "root subvolume" - the default place to put the "@" Linux root subvolume, as well as "@home" and your brand new subvolume.

  1. Go there (you will see all the already made , and make a copy of the already copied subvolume by

    sudo btrfs subvolume snapshot @mynewroot

The path to the copied root, is just the path where you have copied the root files.

  1. Delete the originally-copied-but-placed-in-not-the-best-place subvolume by

    sudo btrfs subvolume delete


Now, the last remark:

To make a copy of subvolume on the same btrfs partition you just need to do sudo btrfs subvolume snapshot <path to the copied root> @mynewroot (ideal, when you want to test in parallel many btrfs-based Linux distributions, but not own 1TB hard drive). In this case, after installing the next Linux OS on the same partition, as your Ubuntu (but on different root subvolume), try deduplicating it. If it is similar distribution (like Linux Mint), you will save a lot of space!

To copy between partitions, use btrfs send and btrfs receive - this will automatically preserve all links, and stuff; it is equivalent to dd, but will only copy the relevant information, and operate on a subvolumes, rather on the whole partitions.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .