slashbeast / better-initramfs

Small and reliable initramfs solution supporting (remote) rescue shell, lvm, dmcrypt luks, software raid, tuxonice, uswsusp and more.
BSD 3-Clause "New" or "Revised" License
318 stars 54 forks source link

Can't get rootflags to parse/be used #34

Closed grondinm closed 7 years ago

grondinm commented 8 years ago

Hello,

I'm sure this is something silly i am doing or not doing but i can't seem to get the rootflags to work. I just over the weekend moved my root partition inside my luks encrypted btrfs partition but when i try to pass the subvol to mount it using rootflags it still only mounts the root of the btrfs partition and so it stops and i have to manually unmount /newroot and mount it again with the proper subvol.

Here is my kernel append line. I use syslinux as a boot loader

APPEND video=uvesafb:1280x1024-32,mtrr:3,ywrap sshd sshd_port=6969 binit_net_if=eth0 binit_net_addr=192.168.2.2/24 binit_net_gw=192.168.2.1 sshd_wait=20 luks enc_root=/dev/sda3 root=/dev/mapper/enc_root rootflags=subvol=/@Rootfs,compress=lzo rw

is it an order thing? I've tried putting rootflags before the root declaration with same results. I've also tried using sobvolid instead of subvol. I've tried the name with the / and without.

grondinm commented 8 years ago

Looking at the function.sh (which i should have done first) it would seem that i have to specify rootfstype in order for the rootflags to get included.

Correct me if i'm wrong(can't test now not at home)

slashbeast commented 8 years ago

Hi,

Indeed the logic there would pass rootlfags only if rootfstype was also specified. I've fixed it in 88abf43.

Please try the better-initramfs from devel branch and let me know if that does works for you.

grondinm commented 8 years ago

That did work but first i got a bunch of file exists errors it was trying to create symlinks by-label for each hdd in my system

slashbeast commented 8 years ago

That's disturbing. That would mean that the by-label symlinks where there in first place and I was not aware that something could create it at all. devtmpfs or something, or multiple devices have the same label?

Could you please run it on your regular system and provide me the output?

#!/bin/sh
for block_device in /sys/class/block/*; do
    unset blkid_output LABEL UUID TYPE

    block_device="${block_device##*/}"

    blkid_output="$(blkid "/dev/${block_device}")"
    [ "${blkid_output}" ] || continue
    vars="${blkid_output#*:}"
    eval "${vars}"

    [ "${LABEL}" ] && echo run ln -s "../../${block_device}" "/dev/disk/by-label/${LABEL}"
    [ "${UUID}" ] && echo run ln -s "../../${block_device}" "/dev/disk/by-uuid/${UUID}"
done

I'd like to know whatever multiple block devices have the same label on your host.

grondinm commented 8 years ago

Here is the output. If i had looked at the output during initramfs start i would have realized what was going on. I have a 4 disk btrfs FS so of course they have the same label.

run ln -s ../../dm-0 /dev/disk/by-label/SAND run ln -s ../../dm-0 /dev/disk/by-uuid/56bbc0a7-c820-450d-b1b7-7b144ce79a03 run ln -s ../../dm-1 /dev/disk/by-uuid/a033c8c3-9886-4402-b114-ad7b2426412c run ln -s ../../dm-2 /dev/disk/by-label/Storage3 run ln -s ../../dm-2 /dev/disk/by-uuid/127a59ef-f289-43e0-bb9d-0085bee5b0c5 run ln -s ../../sda1 /dev/disk/by-label/Boot run ln -s ../../sda1 /dev/disk/by-uuid/5510a8e7-032d-4e21-86f2-49ecc8ed5be1 run ln -s ../../sda3 /dev/disk/by-uuid/b29a26a5-d090-42ba-8ea8-fbfd9753cc37 run ln -s ../../sdb /dev/disk/by-label/Storage2 run ln -s ../../sdb /dev/disk/by-uuid/fb275ad7-cdee-479e-af9c-f2ef6d0a51ea run ln -s ../../sdc /dev/disk/by-label/Storage2 run ln -s ../../sdc /dev/disk/by-uuid/fb275ad7-cdee-479e-af9c-f2ef6d0a51ea run ln -s ../../sdd1 /dev/disk/by-uuid/370a9745-35d6-4c83-95ce-ab908cf8cb37 run ln -s ../../sde /dev/disk/by-label/Storage2 run ln -s ../../sde /dev/disk/by-uuid/fb275ad7-cdee-479e-af9c-f2ef6d0a51ea run ln -s ../../sdj /dev/disk/by-label/Storage2 run ln -s ../../sdj /dev/disk/by-uuid/fb275ad7-cdee-479e-af9c-f2ef6d0a51ea run ln -s ../../sdk1 /dev/disk/by-uuid/aed8f941-840b-4cef-a822-bec462a37a33

slashbeast commented 8 years ago

A Btrfs-powered RAID array out of 4 disks or 4 separated btrfs systems with the same label?

I can either print a warning regarding a symlink already existing due to multiple devices having the same name, silently fail or silently overwrite the link so the last device will have the symlink. I am not sure how I should handle it at all. Any suggestion?

grondinm commented 8 years ago

It's a BTRFS powered raid array.

I would say print a warning and silently fail. I know in the case of BTRFS it would not matter what drive ends up being linked but I'm not sure how other raid implementations would react. So with a warning one would know what was up.

slashbeast commented 8 years ago

Oh wow, and here I entirely forgot about the RAID1 and similar with the feature of creating symlink to by-uuid and by-label.

I will re-work the function a bit. It will first loop over on dm-* block device, then on all rest of them and not replace existing symlinks. This will guarantee that if you have software raid (like mdadm based) it will put the uuid and label symlink to the raid and not a single mirror of it. It won't help in btrfs case beside not dropping you to rescue shell. Sounds resonable?

grondinm commented 8 years ago

Sounds reasonable to me. Thank you