You are not logged in.
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-defaultcommand 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 -fThat will bring us in 1122 subvolume after reboot.
What is it?
# btrfs --version
btrfs-progs v4.17.1Last edited by eth0:1 (2018-08-21 17:47:54)
Offline
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
Offline
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
# btrfs subvolume set-defaultcommand takes effect only after mounting default subvolume somewhere.
Looks like this would be the intended behavior. According to btrfs-subvolume man page:
set-default [subvolume>|<id> <path>]
Set the default subvolume for the (mounted) filesystem.
Offline
eth0:1 wrote:# btrfs subvolume set-defaultcommand 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
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
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
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
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
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 -fIn 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
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