Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boot Issue: Tinyramfs cannot find root partition after init initramfs step. #9

Closed
crushingteeth opened this issue Jul 5, 2020 · 6 comments

Comments

@crushingteeth
Copy link

Hey there!
I'm having some trouble getting my machine to boot. I've gotten to the point where grub tries to load the initramfs and then it fails to find the root partition. I'm executing tinyramfs with:
tinyramfs -k 5.7.7 -o /boot/initramfs-linux.img (with adding -f if I'm overwriting).

I've exhausted my problem solving capabilities on this one and would love to see if someone has an idea of where I'm going wrong. :)

blkid -f

sdb
├─sdb1                    vfat        FAT16          8DE7-EBA9                               499.5M     0% /mnt/boot/efi
├─sdb2                    crypto_LUKS 1              ca8ebf4f-6e11-4fa7-93ad-af96ca49ccd7
│ └─boot                  ext2        1.0            6290cc6c-0b1a-4e83-89e8-ccad9ea304bc      1.9G     1% /mnt/boot
└─sdb3                    crypto_LUKS 2              b0008a0c-8cc3-42d7-aab2-ca2acdc1e956
  └─root                  ext4        1.0            de28ef56-90ba-4a91-a358-f5f687ada697    202.5G     1% /mnt

Here is the config for Tinyramfs:

# default - 0
# enable this if you have monolithic kernel (builtin modules)
#
monolith=0

# compression program
#
# supported - whatever you choose
# default - none
# example - compress="pigz -9"
#
compress="none"

# root file system
#
# supported - UUID, LABEL, DEVICE, PARTUUID
# example -
#   root="/dev/sda1"
#   root="/dev/dm-0"
#   root="/dev/disk/by-uuid/13bcb7cc-8fe5-4f8e-a1fe-e4b5b336f3ef"
#   root="PARTUUID=35f923c5-083a-4950-a4da-e611d0778121"
#
root="UUID=b0008a0c-8cc3-42d7-aab2-ca2acdc1e956"

# root file system type
#
# default - autodetected throught /proc/mounts
# example - root_type="btrfs"
#
root_type="ext4"

# root file system options
# example - root_opts="subvol=mysubvolume,nodatacow,defaults"
# see fstab(5) man page for more info
#
root_opts="defaults"

# device manager
# supported - udev, mdev, mdevd
#
devmgr="udev"

# hostonly mode
#
# default - 0
# dramatically reduce initramfs size
# useful only for modular kernels
#
hostonly=0

# hooks
#
# currently supported - lvm, luks
# example -
#   hooks="lvm luks" will support booting LUKS on LVM
#   hooks="luks lvm" will support booting LVM on LUKS
#   hooks="luks"     will support booting only LUKS
#   and so on...
#
hooks="luks"

# LVM options
#
# supported - tag, name, group, config, discard
# description -
#   tag - trigger lvm by tag
#   name - trigger lvm by logical volume name. group must be specified
#   group - trigger lvm by volume group name
#   config - embed host lvm config
#   discard - enable issue_discards
# example -
#   lvm_opts="tag=lvm-server"
#   lvm_opts="name=lv1,group=vg1"
#   lvm_opts="config=1,discard=1"
#   lvm_opts="discard=1"
#
#lvm_opts=""

# LUKS options
#
# supported - key, name, root, header, discard
# description -
#   key - embed key
#   name - device mapper name
#   root - encrypted root ( UUID, LABEL, DEVICE, PARTUUID )
#   header - embed header
#   discard - enable allow-discards
# example -
#   luks_opts="root=PARTUUID=35f923c5-083a-4950-a4da-e611d0778121,key=/path/to/keyfile,name=myluksroot,header=/path/to/header,discard=1"
#   luks_opts="root=PARTUUID=35f923c5-083a-4950-a4da-e611d0778121,
#              key=/path/to/keyfile,
#              name=myluksroot,
#              header=/path/to/header,
#              discard=1"
#
#   luks_opts="root=/dev/sda1,discard=1"
#
luks_opts="root=UUID=b0008a0c-8cc3-42d7-aab2-ca2acdc1e956,key=/boot/rootkeyfile.key,name=root,discard=1"
@illiliti
Copy link
Owner

illiliti commented Jul 6, 2020

You have a typo in root. UUID points to luks container, but should point to real root. Change root to root=UUID=de28ef56-90ba-4a91-a358-f5f687ada697

none in compress is not supported option. leave it commented or use gzip(recommended)
root_opts="defaults" no need

And, i assume you using busybox modprobe ? If so you need to compile ext4 built in (CONFIG_EXT4_FS=y), or manually include necessary modules using hooks.
Example:

  1. Add to /etc/tinyramfs/hooks/ext4/ext4
for _mod in crc32c libcrc32c; do
    copy_module "$_mod"
done
  1. Add to /etc/tinyramfs/hooks/ext4/ext4.init.early
modprobe -a crc32c libcrc32c
  1. Append ext4 to hooks option

This needed because busybox modprobe doesn't handle soft dependencies unlike kmod modprobe(you can install kmod to get rid of this manual intervention btw)

Everything is confusing because documentation is lacking i know, i'm working on it

@crushingteeth
Copy link
Author

crushingteeth commented Jul 8, 2020

Progress report! It's been kinda crazy lately so I haven't been at my computer. Unfortunately that fix didn't work. I installed
d KMOD to bypass the manual intervention, however that didn't work either so I did the manual intervention that you mentioned (added the hook, created the files ext4 and ext4.init.early. Still stuck at a failure to lookup partition. I feel like I'm being a goofball and missing something or not typing something in right. Hopefully that's the case.

Thank you for your time!

sdb
├─sdb1                    vfat                    8DE7-EBA9                               499.5M     0% /boot/efi
├─sdb2                    crypto_LUKS             ca8ebf4f-6e11-4fa7-93ad-af96ca49ccd7
│ └─boot                  ext2                    6290cc6c-0b1a-4e83-89e8-ccad9ea304bc      1.9G     1% /boot
└─sdb3                    crypto_LUKS             b0008a0c-8cc3-42d7-aab2-ca2acdc1e956
  └─root                  ext4                    de28ef56-90ba-4a91-a358-f5f687ada697    202.5G     1% /

Okay this is what my new config file looks like.

#
# configuration
#
# uncomment and fill settings which you needed
#
# 0 - disable
# 1 - enable

# monolithic kernel

monolith=0

# compression program

compress="gzip"

# root file system

root="UUID=de28ef56-90ba-4a91-a358-f5f687ada697"

# root file system type

root_type="ext4"

# root file system options
# example - root_opts="subvol=mysubvolume,nodatacow,defaults"
# see fstab(5) man page for more info
#
#root_opts="defaults"

# device manager

devmgr="udev"

# hostonly mode

hostonly=0

# hooks

hooks="luks,ext4"

#LUKS options
luks_opts="root=UUID=b0008a0c-8cc3-42d7-aab2-ca2acdc1e956,key=/boot/rootkeyfile.key,name=root,discard=1"

Here is my grub.cfg:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'KISS GNU/Linux' --class kiss --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-de28ef5
6-90ba-4a91-a358-f5f687ada697' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod cryptodisk
        insmod luks
        insmod gcry_rijndael
        insmod gcry_rijndael
        insmod gcry_sha256
        insmod ext2
        cryptomount -u ca8ebf4f6e114fa793adaf96ca49ccd7
        set root='cryptouuid/ca8ebf4f6e114fa793adaf96ca49ccd7'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='cryptouuid/ca8ebf4f6e114fa793adaf96ca49ccd7'  6290cc6c-0b1a-4e83-89e
8-ccad9ea304bc
        else
          search --no-floppy --fs-uuid --set=root 6290cc6c-0b1a-4e83-89e8-ccad9ea304bc
        fi
        echo    'Loading Linux 5.7.7 ...'
        linux   /vmlinuz-5.7.7 root=UUID=de28ef56-90ba-4a91-a358-f5f687ada697 ro  loglevel=3 quiet
        echo    'Loading initial ramdisk ...'
        initrd  /initramfs-5.7.7.img
}

@illiliti
Copy link
Owner

illiliti commented Jul 9, 2020

hooks="luks,ext4"

space separated, not comma

I installed
d KMOD to bypass the manual intervention, however that didn't work either

After installing kmod you need to replace busybox modprobe and depmod with kmod variants and run depmod command

If that didn't help you need to boot with break=root kernel parameter and manually try to mount root fs, e.g busybox mount -t ext4 /dev/disk/by-uuid/de28ef56-90ba-4a91-a358-f5f687ada697 /mnt/root

If file /dev/disk/by-uuid/de28ef56-90ba-4a91-a358-f5f687ada697 didn't exist run blkid or busybox blkid to see which partitions currently available. If blkid didn't find your root fs, can you send me your kernel config ? cat /proc/config.gz | gzip -d

@crushingteeth
Copy link
Author

hey illiliti, looks like after updating the keyfile on my boot partition, tinyramfs can't find the partition again. What was that command that you gave me on IRC for initializing the program from the git repo itself starting with ./tinyramfs?

@illiliti
Copy link
Owner

@crushingteeth
Copy link
Author

crushingteeth commented Jul 11, 2020

Ah, yeah. I'm at a loss then. It gave me a "Unable to find key file" yesterday and when I recreated the key (cryptsetup luksAddKey.../dev/disk) it just reverted back to throwing the failed to lookup partition. tinyramfs seems to be doing the luks hook with that command you gave me yesterday and that seemed to fix it for that one boot but I haven't been able to reproduce that result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants