anthonyrisinger / mkinitcpio-btrfs

This hook provides advanced support for single and multi device btrfs partitions, including rollback operations at boot time.
https://aur.archlinux.org/packages/mkinitcpio-btrfs
21 stars 7 forks source link

Non-default root subvolume reset on hook if not top-level #8

Closed rbellamy closed 10 years ago

rbellamy commented 10 years ago

I have the following:

__system
__system/ROOT
__system/home
__system_snapshots

With __system/ROOT set as the default subvolume.

I then boot, and the default subvolume is set to __system, regardless of the value of BTRFS_DIR_ACTIVE in /etc/defaults/btrfs_advanced

I realize now after reading some more and looking at the code, that this is by design. But thought someone else might find it useful if it were mentioned here.

visit1985 commented 10 years ago

Hi @rbellamy,

I've tested it, and can't get whats wrong with your setup. In my opinion it should work. Check out the following.

Setup a test partition, like your's:

$ cd /tmp
$ sudo su
# dd if=/dev/urandom of=./drive count=100 bs=1M
# losetup /dev/loop0 ./drive
# mkfs.btrfs -L test /dev/loop0
# mkdir ./test
# mount /dev/loop0 ./test
# cd ./test
# btrfs su cr __system
# btrfs su cr __system/root
# btrfs su cr __system/home
# btrfs su cr __snapshot
# btrfs subvolume list . --sort=gen | awk '{print $2 ",/" $9}'
257,/__system/root
256,/__system
258,/__system/home
259,/__snapshot

Now use some code from mkinitcpio-btrfs:

# work="."
# BTRFS_DIR_ACTIVE="/__system/root"
# x="$(btrfs subvolume list ${work} | awk '{print $2 ",/" $9}' | grep -E "^[0-9]*,${BTRFS_DIR_ACTIVE}$")"
# BTRFS_BOOT_SUBVOL=${x#*,}
# BTRFS_BOOT_SUBVOLID=${x%,*}
# btrfs subvolume set-default ${BTRFS_BOOT_SUBVOLID} ${work}

And here comes the result:

# btrfs subvolume get-default ${work}
ID 257 gen 7 top level 5 path __system/root

Finally cleanup:

# cd ..
# umount ./test
# losetup -d /dev/loop0
# rm ./drive
# exit

I don't understand it, can you give me a hint?

rbellamy commented 10 years ago

Oh wow... sorry just noticed your request for more info. I've tried to reproduce, and haven't been able to... so closing this is the right thing. Sorry for the late response.

visit1985 commented 10 years ago

This was not meant to be offense. And I had a long response time too :) If you are able to provide the requested infos, please reopen it any time.