Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Need help with custom initramfs, not mounting home and swap.
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Sat Feb 08, 2020 8:05 pm    Post subject: Reply with quote

This is my pro to-type initramfs_list that includes dynamic /sbin/lvm and dynamic /sbin/cryptsetup.
Please correct any mistakes.
Code:
/root/initrd/initramfs_list

# directory structure
dir /proc       755 0 0
dir /usr        755 0 0
dir /usr/lib64 755 0 0
dir /bin        755 0 0
dir /sys        755 0 0
dir /var        755 0 0
dir /lib        755 0 0
dir /lib64      755 0 0
dir /sbin       755 0 0
dir /mnt        755 0 0
dir /mnt/root   755 0 0
dir /etc        755 0 0
dir /root       700 0 0
dir /dev        755 0 0
dir /dev/mapper 755 0 0

# we have a static /dev so we need all dev entries too
# e.g. /dev/console below
nod /dev/console        0600 0 0 c 5 1
nod /dev/null           0666 0 0 c 1 5

# dev/nvme0 and partitions
nod /dev/nvme0      0660 0 0 b 8 0
nod /dev/nvme0n1           0660 0 0 b 8 1
nod /dev/nvme0n1p1           0660 0 0 b 8 2
nod /dev/nvme0n1p2           0660 0 0 b 8 4

# all the lvm nodes I need
nod /dev/dm-0            0660 0 0 b 253 0
nod /dev/dm-1            0660 0 0 b 253 1
nod /dev/dm-2            0660 0 0 b 254 2
nod /dev/dm-3
# ...

slink /dev/stderr                       /proc/self/fd/2                 777 0 0
slink /dev/stdin                        /proc/self/fd/0                 777 0 0
slink /dev/std/out                      /proc/self/fd/1                 777 0 0

# busybox
file /bin/busybox /bin/busybox  755 0 0

# libraries required by /sbin/fsck.ext4 and /sbin/fsck

slink   /lib                            /lib64                          777 0 0
file    /lib64/ld-linux-x86-64.so.2     /lib64/ld-linux-x86-64.so.2     755 0 0
file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0
file    /lib64/libcom_err.so.2          /lib64/libcom_err.so.2          755 0 0
file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0
file    /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libuuid.so.1             /lib64/libuuid.so.1             755 0 0
file    /lib64/libe2p.so.2              /lib64/libe2p.so.2              755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0
file    /lib64/libmount.so.1            /lib64/libmount.so.1            755 0 0

file    /sbin/fsck              /sbin/fsck                      755 0 0
file    /sbin/fsck.ext4         /sbin/fsck.ext4                 755 0 0


# libraries required by /sbin/lvm

slink   /lib                            /lib64                          777 0 0
file    /lib64/ld-linux-x86-64.so.2     /lib64/ld-linux-x86-64.so.2     755 0 0
file    /lib64/libdevmapper-event.so.1.02 /lib64/libdevmapper-event.so.1.02  755 0 0
file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0
file    /lib64/libsystemd.so.0          /lib64/libsystemd.so.0          755 0 0
file    /lib64/librt.so.1               /lib64/librt.so.1               755 0 0
file    /usr/lib64/liblz4.so.1          /usr/lib64/liblz4.so.1          755 0 0
file    /lib64/libcap.so.2              /lib64/libcap.so.2              755 0 0
file    /usr/lib64/libgcrypt.so.20      /usr/lib64/libgcrypt.so.20      755 0 0
file    /usr/lib64/libgpg-error.so.0    /usr/lib64/libgpg-error.so.0    755 0 0
file    /lib64/libudev.so.1             /lib64/libudev.so.1             755 0 0
file    /lib64/libdl.so.2               /lib64/libdl.so.2               755 0 0
file    /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libdevmapper.so.1.02     /lib64/libdevmapper.so.1.02     755 0 0
file    /lib64/libm.so.6                /lib64/libm.so.6                755 0 0
file    /lib64/libaio.so.1              /lib64/libaio.so.1              755 0 0
file    /lib64/libreadline.so.8         /lib64/libreadline.so.8         755 0 0
file    /lib64/libtinfow.so.6           /lib64/libtinfow.so.6           755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0

file     /sbin/lvm                      /sbin/lvm                       755 0 0

# libraries required by /sbin/cryptsetup

slink   /lib                            /lib64                          777 0 0
file    /usr/lib64/libcryptsetup.so.12  /usr/lib64/libcryptsetup.so.12  755 0 0
file    /lib64/libdevmapper.so.1.02     /lib64/libdevmapper.so.1.       755 0 0
file    /lib64/libudev.so.1             /lib64/libcom_err.so.2          755 0 0
file    /lib64/librt.so.1               /lib64/librt.so.1               755 0 0
file    /lib64/libm.so.6                /lib64/libm.so.6                755 0 0
file    /usr/lib64/libcrypto.so.1.1     /usr/lib64/libcrypto.so.1.1     755 0 0
file    /lib64/libz.so.1                /lib64/libz.so.1                755 0 0
file    /lib64/libdl.so.2               /lib64/libdl.so.2               755 0 0
file    /usr/lib64/libargon2.so.1       /usr/lib64/libargon2.so.1       755 0 0
file    /usr/lib64/libjson-c.so.4       /usr/lib64/libjson-c.so.4       755 0 0
file    /usr/lib64/libpopt.so.0         /usr/lib64/libpopt.so.0         755 0 0
file    /lib64/libuuid.so.1             /lib64/libuuid.so.1             755 0 0
file    /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0

file    /sbin/cryptsetup                /sbin/cryptsetup                755 0 0

# our init script
file    /init                   /root/initrd/init               755 0 0
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat Feb 08, 2020 8:14 pm    Post subject: Reply with quote

vaav,

Think of the initrd as being a completely separate install to your real root. It is.
It borrows binaries because that's convenient but it doesn't have to.
e.g. genkernel all builds its own binaries for the initrd.

Do not mask udev.
/sbin/lvm shows that it needs libudev.so.1. That's fine.
The udev service will not be started in the initrd and udev will not make any adjustments to /dev for you.
Its not runnning, so it cant,

Code:
nod /dev/nvme0      0660 0 0 b 8 0
looks wrong.
The
Code:
b 8 0
means a block device with kernel major number 8, minor number 0. That's /dev/sda
From your
Code:
$ lsblk
NAME                             MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
nvme0n1                          259:0    0 119.2G  0 disk
├─nvme0n1p1                      259:1    0   699M  0 part  /boot
└─nvme0n1p2                      259:2    0 118.6G  0 part
  └─root_nvme0n1p2-Hellovaa-root 253:0    0 118.6G  0 crypt
    ├─Hellovaa-swap              253:1    0     8G  0 lvm   [SWAP]
    ├─Hellovaa-root              253:2    0    32G  0 lvm   /
    └─Hellovaa-home              253:3    0  78.6G  0 lvm   /home

You need
Code:
nod /dev/nvme0      0660 0 0 b 259 0

Check your other nod entries too.

Code:
# libraries required by /sbin/fsck.ext4 and /sbin/fsck

slink   /lib                            /lib64     

slink make a symbolic link.

Code:
file    /lib64/ld-linux-x86-64.so.2     /lib64/ld-linux-x86-64.so.2     755 0 0

Copies the input file to the output file (in the intrd) and gives it 755 permissions, thats rwxr-xr-x

The order of file statements is not important. They are copied to the initrd,
There is no need to list any file more than once.

My directory structure is for a /no-multilib/ profile. Multilib may be different.
I just copied the output of
Code:
ls /

_________________
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
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Sat Feb 08, 2020 8:32 pm    Post subject: Reply with quote

Changed to nod entries:
Code:

# we have a static /dev so we need all dev entries too
# e.g. /dev/console below
nod /dev/console        0600 0 0 c 5 1
nod /dev/null           0666 0 0 c 1 5

# dev/nvme0 and partitions
nod /dev/nvme0                0660 0 0 b 259 0
nod /dev/nvme0n1              0660 0 0 b 259 0
nod /dev/nvme0n1p1            0660 0 0 b 259 0
nod /dev/nvme0n1p2            0660 0 0 b 259 0

# all the lvm nodes I need
nod /dev/dm-0            0660 0 0 b 259 0
nod /dev/dm-1            0660 0 0 b 259 0
nod /dev/dm-2            0660 0 0 b 259 0
nod /dev/dm-3            0660 0 0 b 259 0

I assumed the lvm nodes and nvme0 partition are also "0660 0 0 b 259 0"

Here is my new initramfs_list pro to-type:
Code:

/root/initrd/initramfs_list

# directory structure
dir /proc       755 0 0
dir /usr        755 0 0
dir /bin        755 0 0
dir /sys        755 0 0
dir /var        755 0 0
dir /lib        755 0 0
dir /lib64      755 0 0
dir /sbin       755 0 0
dir /mnt        755 0 0
dir /mnt/root   755 0 0
dir /etc        755 0 0
dir /root       700 0 0
dir /dev        755 0 0
dir /dev/mapper 755 0 0

# we have a static /dev so we need all dev entries too
# e.g. /dev/console below
nod /dev/console        0600 0 0 c 5 1
nod /dev/null           0666 0 0 c 1 5

# dev/nvme0 and partitions
nod /dev/nvme0      0660 0 0 b 259 0
nod /dev/nvme0n1           0660 0 0 b 259 0
nod /dev/nvme0n1p1           0660 0 0 b 259 0
nod /dev/nvme0n1p2           0660 0 0 b 259 0

# all the lvm nodes I need
nod /dev/dm-0            0660 0 0 b 259 0
nod /dev/dm-1            0660 0 0 b 259 0
nod /dev/dm-2            0660 0 0 b 259 0
nod /dev/dm-3
# ...

slink /dev/stderr                       /proc/self/fd/2                 777 0 0
slink /dev/stdin                        /proc/self/fd/0                 777 0 0
slink /dev/std/out                      /proc/self/fd/1                 777 0 0

# busybox
file /bin/busybox /bin/busybox  755 0 0

# libraries required by /sbin/fsck.ext4 and /sbin/fsck

slink   /lib                            /lib64                          777 0 0
file    /lib64/ld-linux-x86-64.so.2     /lib64/ld-linux-x86-64.so.2     755 0 0
file    /lib64/libext2fs.so.2           /lib64/libext2fs.so.2           755 0 0
file    /lib64/libcom_err.so.2          /lib64/libcom_err.so.2          755 0 0
file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0
file    /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libuuid.so.1             /lib64/libuuid.so.1             755 0 0
file    /lib64/libe2p.so.2              /lib64/libe2p.so.2              755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0
file    /lib64/libmount.so.1            /lib64/libmount.so.1            755 0 0

file    /sbin/fsck              /sbin/fsck                      755 0 0
file    /sbin/fsck.ext4         /sbin/fsck.ext4                 755 0 0

# libraries required by /sbin/cryptsetup and /sbin/lvm
slink   /lib                            /lib64                          777 0 0
file    /usr/lib64/libcryptsetup.so.12  /usr/lib64/libcryptsetup.so.12  755 0 0
file    /usr/lib64/libcrypto.so.1.1     /usr/lib64/libcrypto.so.1.1     755 0 0
file    /lib64/libz.so.1                /lib64/libz.so.1                755 0 0
file    /usr/lib64/libargon2.so.1       /usr/lib64/libargon2.so.1       755 0 0
file    /usr/lib64/libjson-c.so.4       /usr/lib64/libjson-c.so.4       755 0 0
file    /usr/lib64/libpopt.so.0         /usr/lib64/libpopt.so.0         755 0 0
file    /lib64/libuuid.so.1             /lib64/libuuid.so.1             755 0 0
file    /lib64/libdevmapper-event.so.1.02 /lib64/libdevmapper-event.so.1.02  755 0 0
file    /lib64/libpthread.so.0          /lib64/libpthread.so.0          755 0 0
file    /lib64/libsystemd.so.0          /lib64/libsystemd.so.0          755 0 0
file    /lib64/librt.so.1               /lib64/librt.so.1               755 0 0
file    /usr/lib64/liblz4.so.1          /usr/lib64/liblz4.so.1          755 0 0
file    /lib64/libcap.so.2              /lib64/libcap.so.2              755 0 0
file    /usr/lib64/libgcrypt.so.20      /usr/lib64/libgcrypt.so.20      755 0 0
file    /usr/lib64/libgpg-error.so.0    /usr/lib64/libgpg-error.so.0    755 0 0
file    /lib64/libudev.so.1             /lib64/libudev.so.1             755 0 0
file    /lib64/libdl.so.2               /lib64/libdl.so.2               755 0 0
file    /lib64/libblkid.so.1            /lib64/libblkid.so.1            755 0 0
file    /lib64/libdevmapper.so.1.02     /lib64/libdevmapper.so.1.02     755 0 0
file    /lib64/libm.so.6                /lib64/libm.so.6                755 0 0
file    /lib64/libaio.so.1              /lib64/libaio.so.1              755 0 0
file    /lib64/libreadline.so.8         /lib64/libreadline.so.8         755 0 0
file    /lib64/libtinfow.so.6           /lib64/libtinfow.so.6           755 0 0
file    /lib64/libc.so.6                /lib64/libc.so.6                755 0 0

file    /sbin/cryptsetup                /sbin/cryptsetup                755 0 0
file    /sbin/lvm                      /sbin/lvm                       755 0 0


# our init script
file    /init                   /root/initrd/init               755 0 0
Looks OK?
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Sat Feb 08, 2020 9:05 pm    Post subject: Reply with quote

After putting the initramfs_list and init in post above, in /root/initrd/
And rebooting, i was greeted with kernel panic. Not able to mount root filesystem.
Think i have to look deeper at how the initramfs_list and init should actually should look. And keep it simple ;)

[edit] looking at that initramfs_list and init at the wiki, it seems way too complicated. And i lack the skills for every achieving something like that.
That leaves me to a question that is popping up right now: Should i switch from systemd to openRC, because writing initramfs with /dev/tmpfs would probably be easier to achieve on openRC?
But then again, will openRC ever reach end of life status?
Maybe i should keep this system in tact, and use genkernel initramfs.
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Mon Feb 17, 2020 7:11 pm    Post subject: Reply with quote

Don't want to necrobump my own post. But just want to update, that i switched systemd for openRC, and the custom initramfs works just fine on openRC.
So the custom initramfs failing to mount /home and swap, must have been udev / systemd related.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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