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 1, 2  Next  
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: Wed Feb 05, 2020 12:36 am    Post subject: Need help with custom initramfs, not mounting home and swap. Reply with quote

I made custom initramfs, that basically only need lvm and cryptsetup support.
When booting the systemd Gentoo with custom kernel, the boot process get stuck on recognizing /home and swap. I am able to paste the exact error systemd spits out. However right now i am using genkernel to generate the initramfs, so i can have functional system.
To produce the journalctl -xb errors is kind of a hassle at this moment. I will post the exact error when i got time. But it boils down to: systemd time out when booting and starting to fsck and mount the /dev/mapper/Hellovaa-home and /dev/mapper/Hellovaa-swap

After the time out on home and swap, i get dropped to emergency shell.
With the custom initramfs, i can start /dev/mapper/Hellovaa-root, but when i do "ls -l /dev/disk/by-uuid" and lsblk: only the cryptlvm (luks-device) on nvme0n1p2 and the boot partition on nvme0n1p1 are recognized.
I think the kernel config is ok. because it works fine with genkernel generated initramfs.

This is my kernel .config: http://dpaste.com/2DRPYSS
Note that inside that .config i disabled the /usr/src/initramfs source path to disable the failing initramfs for now, that is embedded into the kernel. So normally the /usr/src/initramfs source path is included into the kernel.

Here is my luks lvm disk layout:
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

Here are the UUID of the volumes:
Code:
$ ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Feb  4 23:40 1a77729e-e978-4553-92ed-917ed1c1a0b5 -> ../../dm-3
lrwxrwxrwx 1 root root 10 Feb  4 23:40 35862606-6b6a-484a-8606-4875d80fe279 -> ../../dm-1
lrwxrwxrwx 1 root root 15 Feb  4 23:40 7335-B062 -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 10 Feb  4 23:40 dbdfcefa-5e86-45d0-994f-7a454ac5a26f -> ../../dm-2
lrwxrwxrwx 1 root root 15 Feb  4 23:40 fd4cf64f-e364-44c8-8287-223909711e34 -> ../../nvme0n1p2

/etc/fstab:
Code:
/dev/nvme0n1p1                                 /boot           vfat            defaults,noatime          1 2
UUID=dbdfcefa-5e86-45d0-994f-7a454ac5a26f      /               ext4            noatime                   0 1
UUID=1a77729e-e978-4553-92ed-917ed1c1a0b5      /home           ext4            noatime                   0 1
UUID=35862606-6b6a-484a-8606-4875d80fe279      none            swap            sw                        0 0

And here is the simple initramfs, that is faling to mount home and swap:
Code:
#!/bin/busybox sh

# Create applets
rescue_shell() {
    echo "Something went Wrong. Dropping to a shell."
    /bin/busybox mkdir -p /usr/sbin /usr/bin /sbin /bin
    /bin/busybox --install -s
    exec /bin/sh
}

# Prepare
mount -t proc none /proc
mount -t sysfs none /sys
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

# Unlock Key
cryptsetup --tries 5 luksOpen $(findfs UUID=fd4cf64f-e364-44c8-8287-223909711e34) cryptlvm

# LVM
lvm vgscan --mknodes || rescue_shell "vgscan failed"
lvm vgchange -a ly Hellovaa/root
lvm vgscan --mknodes || recure_shell "vgscan failed"

# Mount the root filesystem
mount -o ro $(findfs UUID=dbdfcefa-5e86-45d0-994f-7a454ac5a26f) /mnt/root || rescue_shell

# Clean up
umount /proc
umount /sys

# Switchrepoo
exec switch_root /mnt/root /sbin/init

Side-note: in this initramfs i am using mdev, because i thought that using devtmpfs was the culprit.
So basically it comes down to i think for "some" reason home and swap not being detected by the system? Can someone please provide some insight, and help boot the box up with custom initramfs.
Back to top
View user's profile Send private message
coderanger
n00b
n00b


Joined: 19 Sep 2018
Posts: 70

PostPosted: Wed Feb 05, 2020 8:48 am    Post subject: Reply with quote

It looks like systemd wants udev support to be present in initramfs
The issue https://forums.gentoo.org/viewtopic-t-1107588.html has the same symptoms
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1850

PostPosted: Wed Feb 05, 2020 10:17 am    Post subject: Reply with quote

First things first: At what point exactly does it fail?


Then some tips:
Quote:
# Prepare
mount -t proc none /proc
mount -t sysfs none /sys
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

You can also mount /dev (-t devtmpfs) instead of generating it with mdev. Kernel already knows what's there. And also /dev/pts on top of that, for terminals.

Quote:
# Mount the root filesystem
mount -o ro $(findfs UUID=dbdfcefa-5e86-45d0-994f-7a454ac5a26f) /mnt/root || rescue_shell

You have LVM there. Use names instead (/dev/vg/lv or /dev/mapper/vg-lv ). UUIDs on top of LVM are bad. What if you create a snapshot?

Quote:
# Clean up
umount /proc
umount /sys
Why, oh why? Is there anything specific to your setup that requires umounting everything before switch_root?

Finally, what's not there:
You do not attempt to mount /home and activate swap in this script. And it's OK. You should add them to /etc/fstab instead and have system init mount them for you, after switch_root.
Which makes me wonder why you think it's an issue with your custom initramfs (I'm not saying it's not. I just don't see how those 2 are related right now)
Once you get to the rescue shell, in what state your system is? Are you able to finish the initial setup manually and then hand over with switch_root?
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 804

PostPosted: Wed Feb 05, 2020 11:17 am    Post subject: Reply with quote

szatox wrote:
...
Quote:
# Clean up
umount /proc
umount /sys
...

As I found recently, umounting is wrong because busybox's switch_root behaves differently to util-linux's, and I'm not sure how umount ever worked. The best thing is to move the mounts into your new root. Note that busybox's mount command has different syntax to util-linux's.
Code:
mount -o move /proc /mnt/root/proc
mount -o move /sys /mnt/root/sys
mount -o move /dev/mnt/root/dev

_________________
Greybeard
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Wed Feb 05, 2020 6:42 pm    Post subject: Reply with quote

szatox wrote:
First things first: At what point exactly does it fail?
Then some tips:
Quote:
# Prepare
mount -t proc none /proc
mount -t sysfs none /sys
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

You can also mount /dev (-t devtmpfs) instead of generating it with mdev. Kernel already knows what's there. And also /dev/pts on top of that, for terminals.[

Just woke up, so i will post the journalctl -xb output to wgetpaste right now, will take about 30 minutes from now and i will update this post with the point the system exactly fails.
I used both mounting with devtmpfs and mdev, with no success.
Quote:
# Mount the root filesystem
mount -o ro $(findfs UUID=dbdfcefa-5e86-45d0-994f-7a454ac5a26f) /mnt/root || rescue_shell

Quote:
You have LVM there. Use names instead (/dev/vg/lv or /dev/mapper/vg-lv ). UUIDs on top of LVM are bad. What if you create a snapshot?

Thanks for the advise, i will use names instead of UUID next time.
Quote:
# Clean up
umount /proc
umount /sys
Quote:
Why, oh why? Is there anything specific to your setup that requires umounting everything before switch_root?

Finally, what's not there:
You do not attempt to mount /home and activate swap in this script. And it's OK. You should add them to /etc/fstab instead and have system init mount them for you, after switch_root.
Which makes me wonder why you think it's an issue with your custom initramfs (I'm not saying it's not. I just don't see how those 2 are related right now)
Once you get to the rescue shell, in what state your system is? Are you able to finish the initial setup manually and then hand over with switch_root?

The same /etc/fstab and kernel .config works with genkernel generated initramfs: # genkernel --luks --lvm --udev --install initramfs
So i thought that just replacing the genkernel initramfs with the simple custom initramfs would be enough to make the system boot.
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Wed Feb 05, 2020 6:43 pm    Post subject: Reply with quote

Goverp wrote:
szatox wrote:
...
Quote:
# Clean up
umount /proc
umount /sys
...

As I found recently, umounting is wrong because busybox's switch_root behaves differently to util-linux's, and I'm not sure how umount ever worked. The best thing is to move the mounts into your new root. Note that busybox's mount command has different syntax to util-linux's.
Code:
mount -o move /proc /mnt/root/proc
mount -o move /sys /mnt/root/sys
mount -o move /dev/mnt/root/dev

Thanks for the advise, i will change umount to mount -o move in my next attempt.
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Wed Feb 05, 2020 6:45 pm    Post subject: Reply with quote

coderanger wrote:
It looks like systemd wants udev support to be present in initramfs
The issue https://forums.gentoo.org/viewtopic-t-1107588.html has the same symptoms

I Thought that simple initramfs does not include udev. So i should use devtmpfs instead, correct me if i am wrong.
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Wed Feb 05, 2020 8:54 pm    Post subject: Reply with quote

Here are some log files about the exact issue:

dmesg:
Your paste can be seen here: http://dpaste.com/10MRJQM

here is where the mounting of swap and home fails:
Your paste can be seen here: http://dpaste.com/08ZDNZY

here is the full output of # journalctl -xb
Your paste can be seen here: http://dpaste.com/2BQJHDM

here is the init i am using:
Code:

#!/bin/busybox sh

# Create applets
rescue_shell() {
    echo "Something went Wrong. Dropping to a shell."
    /bin/busybox mkdir -p /usr/sbin /usr/bin /sbin /bin
    /bin/busybox --install -s
    exec /bin/sh
}

# Prepare
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs none /dev

# Unlock Key
cryptsetup --tries 5 luksOpen $(findfs UUID=fd4cf64f-e364-44c8-8287-223909711e34) cryptlvm

# LVM
lvm vgscan --mknodes || rescue_shell "vgscan failed"
lvm lvchange -a ly Hellovaa/root
lvm vgscan --mknodes || recure_shell "vgscan failed"

# Mount the root filesystem
mount -o ro /dev/mapper/Hellovaa-root /mnt/root || rescue_shell

# Clean up
mount -o move /proc /mnt/root/proc
mount -o move /sys /mnt/root/sys
mount -o move /dev/mnt/root/dev

# Switchrepoo
exec switch_root /mnt/root /sbin/init


/etc/fstab
Code:

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't
# needed); notail increases performance of ReiserFS (at the expense of storage
# efficiency).  It's safe to drop the noatime options if you want and to
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#
# NOTE: Even though we list ext4 as the type here, it will work with ext2/ext3
#       filesystems.  This just tells the kernel to use the ext4 driver.
#
# NOTE: You can use full paths to devices like /dev/sda3, but it is often
#       more reliable to use filesystem labels or UUIDs. See your filesystem
#       documentation for details on setting a label. To obtain the UUID, use
#       the blkid(8) command.

#LABEL=boot             /boot           ext4            noauto,noatime  1 2
#UUID=58e72203-57d1-4497-81ad-97655bd56494              /               ext4            noatime         0 1
#LABEL=swap             none            swap            sw              0 0
#/dev/cdrom             /mnt/cdrom      auto            noauto,ro       0 0

#/dev/nvme0n1p1                                 /boot           vfat            defaults,noatime          1 2
#UUID=dbdfcefa-5e86-45d0-994f-7a454ac5a26f      /               ext4            noatime                   0 1
#UUID=1a77729e-e978-4553-92ed-917ed1c1a0b5      /home           ext4            noatime                   0 1
#UUID=35862606-6b6a-484a-8606-4875d80fe279      none            swap            sw                        0 0

/dev/nvme0n1p1          /boot           vfat            defaults,noatime 1 2
/dev/mapper/Hellovaa-root /             ext4            noatime          0 1
/dev/mapper/Hellovaa-home /home         ext4            noatime          0 1
/dev/mapper/Hellovaa-swap none          swap            sw               0 0


The first thing i notice when booting: After providing the luks keys, the first thing that is displayed is: MOUNT CAN NOT FIND /etc/fstab

[edit] Here is grub kernel parameter:
Code:
GRUB_CMDLINE_LINUX="crypt_root=UUID=fd4cf64f-e364-44c8-8287-223909711e34 dolvm ipv6.disable=1 nvidia-drm.modeset=1 init=/lib/systemd/systemd rootfstype=ext4 i8042.noloop i8042.nomux i8042.nopnp i8042.reset loglevel=2"
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Wed Feb 05, 2020 11:06 pm    Post subject: Reply with quote

Made small progression, however systemd still failing to mount swap and home.
First the system could not recognize /dev/mapper/Hellovaa-swap and /dev/mapper/Hellovaa-root at all.
After changing the LVM section in the init script from:
Code:

# LVM
lvm vgscan --mknodes || rescue_shell "vgscan failed"
lvm lvchange -a ly Hellovaa/root
lvm vgscan --mknodes || recure_shell "vgscan failed"

to ->
Code:
# LVM
lvm vgscan --mknodes || rescue_shell "vgscan failed"
lvm lvchange -a ly Hellovaa/root
lvm lvchange -a ly Hellovaa/home
lvm lvchange -a ly Hellovaa/swap
lvm vgscan --mknodes || recure_shell "vgscan failed"

# lsblk will list that swap and home are detected by the system now.
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 
  └─cryptlvm        253:0    0 118.6G  0 crypt
    ├─Hellovaa-root 253:1    0    32G  0 lvm   /
    ├─Hellovaa-home 253:2    0  78.6G  0 lvm   /home
    └─Hellovaa-swap 253:3    0     8G  0 lvm   [SWAP]

So when systemd still fails to mount swap and home, i get dropped to emergency shell, i can log-in with root user. Then do:
# mount /dev/mapper/Hellovaa-home /mnt/home
# swapon /dev/mapper/Hellovaa-swap
Log out root-user, then log-in with regular user and startx.

Only still stuck on why systemd does not mount home and swapon swap.
Side-note: /etc/fstab is being read by the system, at least i think because the error mount /etc/fstab is not displayed anymore.

Any help is still appreciated.
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Wed Feb 05, 2020 11:11 pm    Post subject: Reply with quote

One more thing, it's still pretty vague for me what /usr/src/initramfs/dev exactly should contain. At the moment i got:
Code:
$ ls -a /usr/src/initramfs/dev/
.  ..  console  control  cryptlvm  dm-0  dm-1  dm-2  dm-3  Hellovaa-home  Hellovaa-root  Hellovaa-swap  null  nvme0n1  nvme0n1p1  nvme0n1p2  random  tty  urandom
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Thu Feb 06, 2020 1:29 am    Post subject: Reply with quote

coderanger wrote:
It looks like systemd wants udev support to be present in initramfs
The issue https://forums.gentoo.org/viewtopic-t-1107588.html has the same symptoms

After reading the www, i start to think it might not be possible to get custom initramfs in combination with systemd.
Can someone confirm if we are forced to use genkernel-next (or dracut) to generate the initramfs with -udev flag?

Been spending 5 days on trying to get the custom initramfs to work, but keep on failing to mount swap and root.
For now i will give up. : :evil: And will stick to genkernel-next to generate the initramfs.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14971

PostPosted: Thu Feb 06, 2020 1:37 am    Post subject: Reply with quote

vaav wrote:
One more thing, it's still pretty vague for me what /usr/src/initramfs/dev exactly should contain.
Nothing, because you should have the initramfs generated from a manifest. ;) You should use a devtmpfs in the initramfs, so the manifest only needs to provide (at most) the very basic nodes like console, null, and tty:
Code:
dir /dev 755 0 0
nod /dev/null 644 0 0 c 1 3
nod /dev/tty 644 0 0 c 5 0
nod /dev/console 600 0 0 c 5 1


Why is the service timing out? It should either succeed or fail instantly, depending on whether the device node is present and functional. Since it is already waiting and presumably retrying, what happens if you increase the timeout? What can you see if you add a prerequisite service that lists all available devices, then exits success?
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Thu Feb 06, 2020 3:38 am    Post subject: Reply with quote

Hu wrote:
vaav wrote:
One more thing, it's still pretty vague for me what /usr/src/initramfs/dev exactly should contain.
Nothing, because you should have the initramfs generated from a manifest. ;) You should use a devtmpfs in the initramfs, so the manifest only needs to provide (at most) the very basic nodes like console, null, and tty:
Code:
dir /dev 755 0 0
nod /dev/null 644 0 0 c 1 3
nod /dev/tty 644 0 0 c 5 0
nod /dev/console 600 0 0 c 5 1

Oke that is good to know.
Hu wrote:

Why is the service timing out? It should either succeed or fail instantly, depending on whether the device node is present and functional. Since it is already waiting and presumably retrying, what happens if you increase the timeout? What can you see if you add a prerequisite service that lists all available devices, then exits success?

I am not 100% why mounting swap and home is timing out. When looking at journalctl -xb: http://dpaste.com/08ZDNZY
It looks like fsck is starting and times out.
About increasing the time-out: 1 minute and 30 seconds is already a pretty long time out i.m.h.o ;)
Not sure what you mean with: "What can you see if you add a prerequisite service that lists all available devices, then exits success"

Honestly Hu, what should i do now?
I start to believe that the only option is genkernel-next initramfs with --udev flag. Not sure if it's even possible to get custom simple initramfs on this particular system build.

[edit]
Code:
-- The unit systemd-rfkill.service has successfully entered the 'dead' state.
Feb 05 21:20:32 Rerrazaur systemd[1]: dev-mapper-Hellovaa\x2dhome.device: Job dev-mapper-Hellovaa\x2dhome.device/start timed out.
Feb 05 21:20:32 Rerrazaur systemd[1]: Timed out waiting for device /dev/mapper/Hellovaa-home.
-- Subject: A start job for unit dev-mapper-Hellovaa\x2dhome.device has failed
-- Defined-By: systemd
-- Support: https://gentoo.org/support/
--
-- A start job for unit dev-mapper-Hellovaa\x2dhome.device has finished with a failure.
--
-- The job identifier is 57 and the job result is timeout.
Feb 05 21:20:32 Rerrazaur systemd[1]: Dependency failed for /home.
-- Subject: A start job for unit home.mount has failed
-- Defined-By: systemd
-- Support: https://gentoo.org/support/
--
-- A start job for unit home.mount has finished with a failure.

Not sure if /dev/rfkill got anything to do with the issue.
Systemd saying: " Dependency failed " what could that be?

[another edit] Seems that the system is trying to mount swap and root that does not exist. No solution so far.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14971

PostPosted: Fri Feb 07, 2020 3:16 am    Post subject: Reply with quote

I asked why it is timing out because I don't think it should be waiting at all. It should either immediately succeed or immediately fail. Delaying is wrong.

We need to see the system state, and none of your journalctl output shows that. I want to know when those device nodes appear, because that tells us whether the mount fails because the nodes are missing or because they are broken.
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Fri Feb 07, 2020 1:08 pm    Post subject: Reply with quote

Hu wrote:
I asked why it is timing out because I don't think it should be waiting at all. It should either immediately succeed or immediately fail. Delaying is wrong.
Ah oke, sorry for misunderstanding.
Hu wrote:
We need to see the system state, and none of your journalctl output shows that. I want to know when those device nodes appear, because that tells us whether the mount fails because the nodes are missing or because they are broken.

How can i provide such information about, when nodes appear, if mount fails, or nodes are missing because they are broken?
Could you guide me trough the process?
Sorry for late reaction, just woke up in Netherlands ;)
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Fri Feb 07, 2020 4:50 pm    Post subject: Reply with quote

One more confusion on mounting the root filesystem to ? /mnt/root ?
Is that on /mnt/root
or on /usr/src/initramfs/mnt/root?
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Fri Feb 07, 2020 5:15 pm    Post subject: Reply with quote

Just to clear things up. For /usr/src/initramfs/dev
I do:
Code:
/usr/src/initramfs/dev $ sudo rm *
/usr/src/initramfs/dev $ ls
/usr/src/initramfs/dev $ sudo cp --archive /dev/{null,console,tty,nvme0n1p2} /usr/src/initramfs/dev/
/usr/src/initramfs/dev $ ls
console  null  nvme0n1p2  tty


And I noticed in the past the /dev/nvme0n1p2 (luks device) was labeled "cryptlvm" and lsblk would show "cryptlvm". But now i noticed that the /dev/nvme0n1p2/ (luks device) is called:
"root_nvme0n1p2-Hellovaa-root" and NOT "cryptlvm".
Does the name change of /dev/nvme0n1p2 (luks device) matter?

Code:

/usr/src/initramfs $ 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

Code:

/usr/src/initramfs $ sudo parted -a optimal /dev/nvme0n1
GNU Parted 3.3
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                               
Model: RPFTJ128PDD2EWX (nvme)
Disk /dev/nvme0n1: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size   File system  Name       Flags
 1      1049kB  734MB  733MB  fat32        bios_grub  bios_grub
 2      735MB   128GB  127GB               cryptlvm



Still stuck :(
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14971

PostPosted: Sat Feb 08, 2020 2:16 am    Post subject: Reply with quote

vaav wrote:
How can i provide such information about, when nodes appear, if mount fails, or nodes are missing because they are broken?
Make the initramfs print the required data to screen. For things that happen after systemd takes over, you may need to make systemd print the required information. I don't know how to make it do that.
vaav wrote:
One more confusion on mounting the root filesystem to ? /mnt/root ?
Is that on /mnt/root
or on /usr/src/initramfs/mnt/root?
/mnt/root in the initramfs.
vaav wrote:
Just to clear things up. For /usr/src/initramfs/dev
I do:
That should be safe, although unnecessary. You only need enough nodes to get devtmpfs up.
vaav wrote:
And I noticed in the past the /dev/nvme0n1p2 (luks device) was labeled "cryptlvm" and lsblk would show "cryptlvm".
Does the name change of /dev/nvme0n1p2 (luks device) matter?
Only if your boot process depends on those names.

What do you hope to achieve by using a custom initramfs? Why are you trying to avoid the use of a generated one that works?
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Sat Feb 08, 2020 10:37 am    Post subject: Reply with quote

Hu wrote:
What do you hope to achieve by using a custom initramfs? Why are you trying to avoid the use of a generated one that works?

I thought it would be cool to make initramfs by hand, and not depend on genkernel-next to make the initramfs.
But honestly i did not expect making the initramfs with this exotic gentoo setup would be that much of a p.i.t.a.
So for now, because i use the Gentoo box for gaming, i will just stick to: genkernel-next to make the initramfs with udev support.
I will not mark thread solved, because the issue is not solved.
For now i will:
Code:
$ sudo rm -r /usr/src/initramfs/

and:
Code:
genkernel --luks --lvm --udev --install initramfs
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14971

PostPosted: Sat Feb 08, 2020 4:50 pm    Post subject: Reply with quote

I use a custom initramfs that looks very similar to the one you showed, and it works fine. I don't use systemd though, so I don't know if its startup processes expect something that my current initramfs does not do.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat Feb 08, 2020 5:28 pm    Post subject: Reply with quote

vaav,

I use a custom initrd without systemd too.
As my initrd does not contain any kernel modules, its like firmware. Unchanged since the system was new in 2009.

You need to take care that you do not need any kernel modules to be able to mount the real root.
That implies that you didn't make your kernel with
Code:
genkernel all
as almost everything is modular.

Code:
ls -l /dev/disk/by-uuid
is not expected to work in the initrd.
All the /dev/disk/by* entries are symbolic links created by udev and you don't have udev in the initrd.

I use the initrd creation process documented on the wiki
That does not require devtmpfs to provide /dev.

That example is all the userspace tools for root on lvm on top of raid5.
You will need to drop the raid5 and add in luks.
_________________
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 7:00 pm    Post subject: Reply with quote

Hey NeddySeagoon,

The kernel is not build with genkernel.
The kernel .config can be seen in post #1, i am pretty sure there are no modular modules, that are being expected when booting the initramfs. The initramfs kernel dependency's are all build-in. Unless i missed one by accident, i think the kernel should be fine.
Looking at the wiki you provided, i am trying to translate the initramfs_list to my own setup.
I stripped away the # Raid section. And changed the /dev/sda /dev/sdb devices to /dev/nvme0 because that is the only ssd i am using.

To include dm-crypt (luks) into the initramfs_list how would i do that?

The custom initramfs gentoo handbook notes that: "Since cryptsetup also often requires the use of the kernel's random device, include them as well."
Code:
# cp --archive /dev/{urandom,random} /usr/src/initramfs/dev


I have problems with building lvm2 and cryptsetup static, on my previous initramfs attempt i had to lddtree the /sbin/lvm and /sbin/cryptsetup dynamically. How would i translate the dynamic binaries into this Old Fashioned Gentoo making the initrd_list?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sat Feb 08, 2020 7:18 pm    Post subject: Reply with quote

vaav,

Point lddtree at the dynamically linked binary you need in the initrd.
For example
Code:
$ sudo lddtree /bin/mount
Password:
/bin/mount (interpreter => /lib64/ld-linux-x86-64.so.2)
    libc.so.6 => /lib64/libc.so.6
    libmount.so.1 => /lib64/libmount.so.1
        libblkid.so.1 => /lib64/libblkid.so.1

This tells that /bin/mount needs
Code:
/lib64/ld-linux-x86-64.so.2
/lib64/libc.so.6
/lib64/libmount.so.1
/lib64/libblkid.so.1
in the initrd.
However, it looks for libc.so.6, so you need /lib64 in your PATH, or it won't be found.

The initrd is very simple. Its just the kernel, the things in the initrd and the init script that tells what to do.
and nothing else. If you don't set a PATH, then its not set.
If you need some environment variables, you must set them.
The hard part of doing it yourself is to think simply enough. It fails when you make an assumption that you were not even aware of making.
_________________
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 7:22 pm    Post subject: Reply with quote

Oke i will have a look at it, one last thing though:
i have to mask udev? even it being dependency of systemd?
Back to top
View user's profile Send private message
vaav
n00b
n00b


Joined: 28 Jan 2020
Posts: 30

PostPosted: Sat Feb 08, 2020 7:39 pm    Post subject: Reply with quote

I am bit sleepy at the moment, so i might make some mistakes. Might get a night rest first.
The dynamical linked /sbin/lvm and the dynamical linked /sbin/cryptsetup:
Code:
$ sudo lddtree /sbin/lvm
/sbin/lvm (interpreter => /lib64/ld-linux-x86-64.so.2)
    libdevmapper-event.so.1.02 => /lib64/libdevmapper-event.so.1.02
        libpthread.so.0 => /lib64/libpthread.so.0
    libsystemd.so.0 => /lib64/libsystemd.so.0
        librt.so.1 => /lib64/librt.so.1
        liblz4.so.1 => /usr/lib64/liblz4.so.1
        libcap.so.2 => /lib64/libcap.so.2
        libgcrypt.so.20 => /usr/lib64/libgcrypt.so.20
            libgpg-error.so.0 => /usr/lib64/libgpg-error.so.0
    libudev.so.1 => /lib64/libudev.so.1
    libdl.so.2 => /lib64/libdl.so.2
    libblkid.so.1 => /lib64/libblkid.so.1
    libdevmapper.so.1.02 => /lib64/libdevmapper.so.1.02
        libm.so.6 => /lib64/libm.so.6
    libaio.so.1 => /lib64/libaio.so.1
    libreadline.so.8 => /lib64/libreadline.so.8
        libtinfow.so.6 => /lib64/libtinfow.so.6
    libc.so.6 => /lib64/libc.so.6

Code:
$ sudo lddtree /sbin/cryptsetup
/sbin/cryptsetup (interpreter => /lib64/ld-linux-x86-64.so.2)
    libcryptsetup.so.12 => /usr/lib64/libcryptsetup.so.12
        libdevmapper.so.1.02 => /lib64/libdevmapper.so.1.02
            libudev.so.1 => /lib64/libudev.so.1
                librt.so.1 => /lib64/librt.so.1
            libpthread.so.0 => /lib64/libpthread.so.0
            libm.so.6 => /lib64/libm.so.6
        libcrypto.so.1.1 => /usr/lib64/libcrypto.so.1.1
            libz.so.1 => /lib64/libz.so.1
            libdl.so.2 => /lib64/libdl.so.2
        libargon2.so.1 => /usr/lib64/libargon2.so.1
        libjson-c.so.4 => /usr/lib64/libjson-c.so.4
    libpopt.so.0 => /usr/lib64/libpopt.so.0
    libuuid.so.1 => /lib64/libuuid.so.1
    libblkid.so.1 => /lib64/libblkid.so.1
    libc.so.6 => /lib64/libc.so.6
How exactly do i translate that into /root/initrd/initramfs_list?
Code:

# 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 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

file /sbin/lvm.static           /sbin/lvm.static         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

# our init script
file    /init                   /root/initrd/init               755 0 0
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 1, 2  Next
Page 1 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