This discussion is archived
3 Replies Latest reply: Oct 8, 2012 10:18 AM by Dude! RSS

btrfs default subvolume

Dude! Guru
Currently Being Moderated
Hi,

I'm using the OL 6.3 UEK2 boot CD and experience the following:

Although setting the default subvolume works, querying seems not, unless I'm doing it wrong. Please see below:

# mkfs.btrfs -L root /dev/sda3

# mount /dev/sda3 /mnt/root
# btrfs subvol create /mnt/root/root-subvol1
# btrfs subvol create /mnt/root/root-subvol2
# btrfs subvol create /mnt/root/root-subvol3

# btrfs subvol list /mnt/root
ID 256 top level 5 path root-subvol1
ID 258 top level 5 path root-subvol2
ID 259 top level 5 path root-subvol3

# btrfs subvol set-default 258 /mnt/root
# btrfs subvol get-default /mnt/root
ID 256 top level 5 path root-subvol1
ID 258 top level 5 path root-subvol2
ID 259 top level 5 path root-subvol3

# umount /mnt/root
# mount /dev/sda3 /mnt/root
# touch /mnt/root/testfile

# umount /mnt/root
# mount -o subvolid=0 /dev/sda3 /mnt/root
# ls -R /mnt/root
/mnt/root:
root-subvol1 root-subvol2 root-subvol3

/mnt/root/root-subvol1:

/mnt/root/root-subvol2:
testfile

/mnt/root/root-subvol3:

Thanks!
  • 1. Re: btrfs default subvolume
    Avi Miller Guru
    Currently Being Moderated
    Dude wrote:
    Although setting the default subvolume works, querying seems not, unless I'm doing it wrong.
    It's a known bug with that version of btrfs-progs.
  • 2. Re: btrfs default subvolume
    Dude! Guru
    Currently Being Moderated
    Ok, I see. Too bad. Thanks for the info!

    Well, I thought it might be easier to simply change the default subvolume rather than modifying the kernel startup parameters to mount the btrfs root volume by subvolid. But even if the bug gets fixed, how can I tell what is currently mounted? It seems to me there is no option in btrfs to show the current name or ID of a mounted subvolume or snapshot. Using the example above, for instance:

    # mkdir /mnt/258 /mnt/0
    # mount -o subvolid=258 /dev/sda3 /mnt/258
    # mount -o subvolid=0 /dev/sda3 /mnt/0

    If I don't know the mount command, how can I tell what btrfs subvolume or snapshot is currently mounted. /etc/mtab does not keep track of the subvolid. The btrfs subvol list command gives me the same output on /mnt/258 as it does on /mnt/0. I could create a certain file in /mnt/258 and then search for it in /mnt/0 to find the parent directory, but is there a more elegant way to determine what is actually mounted?
  • 3. Re: btrfs default subvolume
    Dude! Guru
    Currently Being Moderated
    I guess I can provide an answer to my last question:

    https://btrfs.wiki.kernel.org/index.php/FAQ#How_do_I_find_out_which_subvolume_is_mounted.3F

    +"A specific subvolume can be mounted by -o subvol=/path/to/subvol option, but currently it's not implemented to read that path directly from /proc/mounts. If the filesystem is mounted via a /etc/fstab entry, then output of mount command will show the subvol path, as it reads it from /etc/mtab."+

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points