Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
init script help/suggestions
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
etnull
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2019
Posts: 143

PostPosted: Sat May 04, 2019 3:02 pm    Post subject: init script help/suggestions Reply with quote

Hi, me again.. I'm trying to make my own slim and most minimal initramfs.
Currently it has sh, bash, findfs, dmesg, mount, umount, clear, switch_root, echo, cryptsetup
Here is my init script:
Code:
#!/bin/sh
mount -t devtmpfs none /dev
mount -t proc none /proc
mount -t sysfs none /sys
echo 0 > /proc/sys/kernel/printk
clear
echo "Opening the root crypt volume"
cryptsetup --header header --key-file keyfile --keyfile-offset=33288 --keyfile-size=8192 luksOpen $(/sbin/findfs PARTUUID="12492d2a-f189-4fbf-a72f-d34ae256bac8") cryptroot
echo "Opening the home crypt volume"
cryptsetup --header header --key-file keyfile --keyfile-offset=33288 --keyfile-size=8192 luksOpen $(/sbin/findfs PARTUUID="2c66334e-5228-41e0-b887-22bd258e47d8") crypthome
echo "Mounting opened crypt volumes"
mount /dev/mapper/cryptroot /mnt/root
mount /dev/mapper/crypthome /mnt/root/home
echo "Cleaning up"
echo 1 > /proc/sys/kernel/printk
umount /dev /proc /sys
# Booting the real thing
exec switch_root /mnt/root /sbin/init

When I boot, I'm getting these warnings:
Code:
switch_root: failed to mount moving /dev to /mnt/root/dev: Invalid argument
switch_root: forcing unmount of /dev
switch_root: failed to mount moving /proc to /mnt/root/proc: Invalid argument
switch_root: forcing unmount of /proc
switch_root: failed to mount moving /sys to /mnt/root/sys: Invalid argument
switch_root: forcing unmount of /sys
switch_root: failed to mount moving /run to /mnt/root/run: No such file or directory
switch_root: forcing unmount of /run

But after that it boots successfully. What are these errors? I mounted something wrongfully? How can I do it properly to switch root and also free up all memory?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43194
Location: 56N 3W

PostPosted: Sat May 04, 2019 3:48 pm    Post subject: Reply with quote

etnull,

It looks like
Code:
umount /dev /proc /sys
failed to run so those filesystems are still mounted when you do the switch_root.

It looks like /run is mounted in your initrd too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
etnull
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2019
Posts: 143

PostPosted: Mon May 06, 2019 3:18 pm    Post subject: Reply with quote

The problem was in util-linux version of switch_root, the version from busybox works without errors/warnings.
But I didn't want to use busybox because I only need very few of tools from there, so I took the binary from here:
https://busybox.net/downloads/binaries/1.30.0-i686/ and integrated it into my initramfs, now it works.

I also completely disabled fsck in fstab because it slows the boot process, and ends up with error anyway (because of encryption?)
is this OK, or there are some other recommended way of doing it?

I recorded the boot process, would any thing stand out to the more experienced eye?
https://streamable.com/95u95
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum