Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
luksOpen fails in initramfs
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sat Mar 23, 2024 7:18 pm    Post subject: Reply with quote

Quote:
Secondly the "random" is a character device, it is not a block device. In your shared output it show it is a block device. (i.e. it should be made with "mknod dev/random 1 8 c")

OOPS! :oops:

I will fix that this evening and try it again. I will also do ls -l /dev in the initramfs environment. The cryptsetup luksOpen occurs before the chroot, and the root filesystem is on the encrypted disk.
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Sat Mar 23, 2024 9:26 pm    Post subject: Reply with quote

pingtoo wrote:
Secondly the "random" is a character device, it is not a block device.
Nice catch. I glanced at OP's ls output, but did not notice the b which should have been a c. I will also note that if the initramfs used a devtmpfs (as frostschutz suggested early on), then the kernel would have prepared appropriate device nodes (including random and urandom), with the right ownership and permissions. There would be no need to manually maintain a special directory of device nodes, and thus no opportunity to make this mistake.
pingtoo wrote:
I am not sure how the open() call with O_NONBLOCK on a block device will or will not cause the open() call falire.
It might fail outright if the block device with major=1, minor=8 does not match any device known to the system, regardless of the specific open flags used.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sat Mar 23, 2024 11:14 pm    Post subject: Reply with quote

APPLAUSE !!!
When I corrected /dev/random from block to character device, the SYSTEM BOOTS !!! :D

Now I need to clean up a few things.

First and foremost, I need to change my network device names from enp0s25 to eth0, and from wlp3s0 to wlan0.

Next I need to force vgmknodes to run, perhaps in /etc/rc.d/rc.local so my LVM device names are listed in /dev.

Then I need mkswap /dev/gentoo/swap to run, also probably in rc.local.

I seem to recall that there is a preferred method instead of rc.local, but I am an old timer, and that's the way I remember doing it before. I haven't built a new kernel in several years, and then it was for a set of hardware-identical machines that serve as routers, firewalls, etc. on my network.

Its really too bad that I let this laptop get so far out of date, but the pandemic and associated pandemonium kept me so busy I didn't have time to risk having something go wrong and mess up my laptop, so I put it of, and off. :(
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Sun Mar 24, 2024 1:40 am    Post subject: Reply with quote

Moriah wrote:
First and foremost, I need to change my network device names from enp0s25 to eth0, and from wlp3s0 to wlan0.
This is udev's Predictable Network Interface Names feature. To get kernel standard names, you need to disable udev's feature. There are many threads discussing this, since udev's default is fairly unpopular among people who like simple names.
Moriah wrote:
Next I need to force vgmknodes to run, perhaps in /etc/rc.d/rc.local so my LVM device names are listed in /dev.
Why not run it in the initramfs, immediately after changing the volume group to active?
Moriah wrote:
Then I need mkswap /dev/gentoo/swap to run, also probably in rc.local.
Why? If you make the swap device once, it will remain a swap device unless overwritten by hibernation. If you hibernate to swap, and later resume successfully, the resume will adjust the header to make it swap again. The only time you would want to force a mkswap like this is to overwrite a failed hibernation image.
Moriah wrote:
I seem to recall that there is a preferred method instead of rc.local
Are you thinking of /etc/local.d with its start and stop scripts?
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sun Mar 24, 2024 2:19 am    Post subject: Reply with quote

I was trying to avoid having to staticly link yet another executable to run in my initramfs. That is why I wanted to run vgmknodes after the main system started up. Yes, it might be "prettier" to do it in the iniramfs, but it seemed easier to do it when the main system starts up.

When I said "mkswap", I meant to say "swapon".

I do not plan to use hibernation at all. My plan is to use kvm or lxd to create a savable envirionment that I can control manually without having to do a reboot. This will allow me to save a virtual environment for a project, and restore a different virtual environment for a different project at will, without having to reboot. This would be useful when I am supporting multiple clients or project in the same timeframe, and would even allow me to hot-swap my second laptop drive to mount a disk with a different client's project, then restore the saved kvm or lxd environment, again, without having to reboot. This approach can also provide an alternative to hibernation if I need to shut my laptop down and then reboot it later.

Yes, /etc/local.d with stat/stop scripts (mostly start scripts) might be an alternative to rc.local. I currently use rc.local to start my gateway firewall, but I don't recall using it anywhere else lately.


Predictable Network Interface Names is what I am looking to disable so I can use eth0, etc. since I have a number of scripts that rely on those names. Thanks for reminding me what to look for.
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Sun Mar 24, 2024 2:44 am    Post subject: Reply with quote

You already put lvm in the initramfs, presumably statically linked. You are using its subcommands for vgchange, among other purposes. lvm vgmknodes would be yet another subcommand, so I think you do not need to add any other programs to your initramfs to be able to use vgmknodes. Just add lvm vgmknodes at the right point in the script.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sun Mar 24, 2024 11:40 am    Post subject: Reply with quote

Good point. What was I thinking? You are right. I will put vgmknodes in the initramfs init script today.
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
sublogic
Apprentice
Apprentice


Joined: 21 Mar 2022
Posts: 222
Location: Pennsylvania, USA

PostPosted: Mon Mar 25, 2024 12:44 am    Post subject: Reply with quote

[Assuming Openrc] the swap is enabled if you declare it in your /etc/fstab and put the swap service in the boot runlevel.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Mon Mar 25, 2024 2:34 am    Post subject: Reply with quote

So I put vgmknodes in my init script of my initramfs, and followed it by a ls -l /dev/g* because my volume group is /dev/gentoo, and sure enough, the logical device names were there.

But when the system had completely booted and prompted for a login, I signed in as root and did another ls -l /dev/g* and nothing was there! This surprised me at first, but after thinking about it for a few minutes, I realized that before the chroot in the initscript, /dev is on a filesystem that becomes hidden after the chroot because the vgmknodes was executed before the root filesystem was mounted.

So the bottom line is a need the vgmknodes in my rc.local (or local.d/whatwever) script so it will run after the chroot, as the work done in the initramfs init script gets lost at the chroot.
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Mon Mar 25, 2024 2:53 am    Post subject: Reply with quote

If you switch your initramfs to use devtmpfs, and configure the booted system to also use devtmpfs, then changes made to the initramfs dev will be visible in the main system. Also, for certain complex arrangements, the initramfs may need a vgmknodes even if those do not persist into the main system.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Mon Mar 25, 2024 12:03 pm    Post subject: Reply with quote

I used to use /dev/tmpfs, but then after a while I started to run into problems with large ebuilds such as rust, etc. so I switched to a disk resident tmpfs, since I almost always have plenty of disk space. I know it is slower, but like the tortoise and the hare, slow and steady wins the race. :wink:

I think I'll stick with using disk for tmpfs for now. Maybe when I get more ram, I'll try /dev/tmpfs again...

Here is my current /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.
#/dev/sda1              /boot           ext2            noauto,noatime  1 2
/dev/gentoo/rootfs      /               xfs             noatime         0 1
#/dev/gentoo/vmdk       /home/rj/vmware/vmdk    xfs     noatime         0 1
#/dev/sda3              none            swap            sw              0 0
/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0
#/dev/fd0               /mnt/floppy     auto            noauto          0 0

# tmpfs may need to be increased from 2048M to 4096M for large emerges,
# such as firefox, thunderbird, openoffice, etc.
#

# 2 GB for emerging normal stuff
#tmpfs                   /var/tmp/portage tmpfs size=2048M,mode=0777,noatime 0 0

# 4 GB for emerging big stuff like firefox, thunderbird, etc.
#tmpfs                   /var/tmp/portage tmpfs size=4096M,mode=0777,noatime 0 0
#tmpfs                   /var/tmp/portage tmpfs size=8192M,mode=0777,noatime 0 0
tmpfs                   /var/tmp/portage tmpfs size=16384M,mode=0777,noatime 0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0

_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Mon Mar 25, 2024 3:00 pm    Post subject: Reply with quote

I think you misunderstand the idea of devtmpfs. It is a kernel-managed filesystem, which happens to use a lot of tmpfs code internally, and it contains the device nodes the kernel thinks it should have, based on current hardware. It is not meant to be writable by ebuilds or users, nor even written by root other than when udev tweaks the kernel defaults. It is not used for backing /dev/shm. It is not used as a general storage area. You seem to be talking about using a regular tmpfs for PORTAGE_TMPDIR, which yes, that can have problems with very large builds. To use devtmpfs, mount it: mount -t devtmpfs devtmpfs /dev. Then the nodes in the resulting /dev are accurate for your hardware.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Mon Mar 25, 2024 3:31 pm    Post subject: Reply with quote

So do I mount it before the luksOpen, like /proc and /sys ? Or do I just put it in the dev directory of my initramfs, or what?
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Mon Mar 25, 2024 3:40 pm    Post subject: Reply with quote

It is a virtual filesystem, so you cannot store it in the static on-disk directory. Mount it in the same block where you mount the procfs and sysfs virtual filesystems.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Mon Mar 25, 2024 7:19 pm    Post subject: Reply with quote

Thanks for the tip on devtmpfs. I put it in the initramfs init script and it works great.

Now for more fun. I did an emerge --sync and got a news item to read. Seems that the devs just released a new profile. :evil:

So I am now making an image backup of my system using dd from the live usb. Running at about 20 GB/min, it should take about 2 hours to finish, then I will follow the directions in the news item to upgrade my profile.
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2365
Location: Kentucky

PostPosted: Sun Mar 31, 2024 12:24 am    Post subject: Reply with quote

Well, everything is now working under the old profile except alsa sound, specifically alsamixer fails, so something is wrong with my kernel, because it used to work with the old kernel, and the hardware is the same.

I think getting the alsa sound working is a new topic for a new thread, and then I will update the profile per instruction given in the latest news item. :?
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.
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
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