You are not logged in.

#1 2018-08-21 15:19:24

eth0:1
Member
Registered: 2015-07-17
Posts: 33

Setting BTRFS default subvolume problem.

Hello!
I noticed strange behaviour of btrfs. I don't know if I'm doing something wrong or may be it is some kind of feature or bug! I can't find any mention of it in google or BTRFS wiki.

# btrfs subvolume set-default

command takes effect only after mounting default subvolume somewhere.

How to reproduce:
1. Let's consider one has rootfs on btrfs and a rw snapshot with id 1122
2. Make sure that there is no subvolid/subvol in rootfs mount options (fstab) and kernel command line.
3. Currently set default subvolume=5 (FSTREE) for /
4. reboot into grub menu, add init=/bin/bash at the end of kernel line. Boot into
5. Now we have mounted rootfs from default subvolume and kernel booted from default subvolume too. Change default subvolume

# btrfs subvolume set-default 1122 /
# reboot -f 

And here we go! We still boot into subvolume with id=5, not 1122.

Actually, to be able to boot into 1122, one have to do this on step 5:

# btrfs subvolume set-default 1122 /
# mount /dev/sdXN /mnt
# umount /mnt
# reboot -f

That will bring us in 1122 subvolume after reboot.
What is it?

# btrfs --version
btrfs-progs v4.17.1

Last edited by eth0:1 (2018-08-21 17:47:54)

Offline

#2 2018-08-21 17:37:57

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Setting BTRFS default subvolume problem.

Please edit your thread title an change it to one that actually describes your issue, your current one is meaningless
https://wiki.archlinux.org/index.php/Co … ow_to_post


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-08-21 17:49:44

eth0:1
Member
Registered: 2015-07-17
Posts: 33

Re: Setting BTRFS default subvolume problem.

jasonwryan wrote:

Please edit your thread title an change it to one that actually describes your issue, your current one is meaningless
https://wiki.archlinux.org/index.php/Co … ow_to_post

It was meaningful for me)
Is it better now?

Offline

#4 2018-08-22 02:50:26

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Setting BTRFS default subvolume problem.

eth0:1 wrote:
# btrfs subvolume set-default

command takes effect only after mounting default subvolume somewhere.

Looks like this would be the intended behavior. According to btrfs-subvolume man page:

btrfs-subvolume(8) wrote:

set-default [subvolume>|<id> <path>]
    Set the default subvolume for the (mounted) filesystem.

Offline

#5 2018-08-22 07:20:51

eth0:1
Member
Registered: 2015-07-17
Posts: 33

Re: Setting BTRFS default subvolume problem.

ooo wrote:
eth0:1 wrote:
# btrfs subvolume set-default

command takes effect only after mounting default subvolume somewhere.

Looks like this would be the intended behavior. According to btrfs-subvolume man page:

btrfs-subvolume(8) wrote:

set-default [subvolume>|<id> <path>]
    Set the default subvolume for the (mounted) filesystem.

Yeah it is mounted when I change default subvolume. The trick is that you have to mount it again after changing default subvolume.

Offline

#6 2018-08-22 08:01:39

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Setting BTRFS default subvolume problem.

eth0:1 wrote:

Yeah it is mounted when I change default subvolume. The trick is that you have to mount it again after changing default subvolume.

Ah, sorry I misunderstood the issue.

Are you sure the filesystem is properly unmounted during the reboot process?

Offline

#7 2018-08-22 08:36:14

eth0:1
Member
Registered: 2015-07-17
Posts: 33

Re: Setting BTRFS default subvolume problem.

ooo wrote:

Ah, sorry I misunderstood the issue.

Are you sure the filesystem is properly unmounted during the reboot process?

Actually, I don't unmount it. I thought that btfs changes apply instantly. Because

#btrfs subvolume set-default 1122 /
# btrfs subvolume get-default / 

command will return freshly set default subvolume.

I'll test it. But if you are right that means btrfs actually changes default subvolume on unmount? Is it documented somewhere?

Offline

#8 2018-08-22 08:40:11

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,384

Re: Setting BTRFS default subvolume problem.

Why are you using reboot -f ? From what I'm reading that will force a shutdown and not sync/unmount changes to your filesystem properly. Does it work if you preceed the reboot -f with a sync ?

Offline

#9 2018-08-22 08:46:32

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Setting BTRFS default subvolume problem.

eth0:1 wrote:

But if you are right that means btrfs actually changes default subvolume on unmount? Is it documented somewhere?

I didn't see it documented anywhere. Just one possibility that came to mind, that maybe btrfs doesn't actually write the default subvolume setting to disk until during unmount.

Offline

#10 2018-08-22 08:54:05

eth0:1
Member
Registered: 2015-07-17
Posts: 33

Re: Setting BTRFS default subvolume problem.

Why are you using reboot -f ? From what I'm reading that will force a shutdown and not sync/unmount changes to your filesystem properly. Does it work if you preceed the reboot -f with a sync ?

Because when I don't have init running (changed init to /bin/bash in grub configuration) that is the only option to reboot the system.

unmounting system after setting default subvolume should not affect saving default subvolume in filesystem.

# btrfs subvolume set-default 1122 /
# mount /dev/sdXN /mnt
# umount /mnt
# reboot -f

In this example, mount command is with no actual subvol/subvolid option. That will mount /dev/sdXN with default subvolume (1122) that was just set. It is a sign that default subvolume is actually set.
But if you omit mounting it - default subvolume doesn't changes.

Last edited by eth0:1 (2018-08-22 08:54:57)

Offline

#11 2018-08-22 09:48:33

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Setting BTRFS default subvolume problem.

Yes, I saw that. My idea was that maybe the default-subvolume setting is only kept in RAM until unmount, or some other operation. That's kind of a long shot, but it may be a good idea to test with some more conventional init=, that actually unmounts the filesystem on reboot.

If that doesn't help, you should probably inquire whether this is intended behavior from btrfs developers directly.

Last edited by ooo (2018-08-22 13:40:40)

Offline

Board footer

Powered by FluxBB