Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HELP - initrd embedded in kernel - SOLVED
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Thu Feb 07, 2019 3:57 pm    Post subject: HELP - initrd embedded in kernel - SOLVED Reply with quote

I have been running gentoo since 2004, linux since 1993, unix since 1989. I have used grub to boot my gentoo systems for over 10 years (at least!). Now good old grub is superceeded by grub2. Since I am rebuilding my road warrior laptop, I decided to install 4.14.83-gentoo for my kernel, and use the shiny new grub2 to boot it.

I copied the .config from my old kernel (3.12.21-gentoo-r1, yes, I know that's pretty old.) and did a make oldconfig, taking the defaults for everything. Then I did a make && make modules_install followed by make install. I dutifully followed the handbook's directions for grub2, but it wouldn't boot.

I have used an initrd for years on this box because the boot drive is a usb-stick on my keychain (along with the house key, car key, etc.), and the drive in the laptop is a 2 TB SSD that is whole-disk encrypted with LUKS. The initrd lets me put in my pass phrase, then activates LVM on the result, then mounts the root filesystem.

I have used the nice feature of embedding the initrd into the kernel image for years, so my grub.conf did not need to specify anything regarding the initrd.

Suspecting something was wrong with the initrd, I ran make menuconfig and verified the initrd stuff was configured properly in the "General setup" menu. It looked like this:
Code:
  | |               [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support                   | | 
  | |               (/usr/src/initramfs) Initramfs source file(s)                                        | | 
  | |               (0)   User ID to map to 0 (user root)                                                | | 
  | |               (0)   Group ID to map to 0 (group root)                                              | | 
  | |               [*]   Support initial ramdisk/ramfs compressed using gzip                            | | 
  | |               [*]   Support initial ramdisk/ramfs compressed using bzip2                           | | 
  | |               [*]   Support initial ramdisk/ramfs compressed using LZMA                            | | 
  | |               [*]   Support initial ramdisk/ramfs compressed using XZ                              | | 
  | |               [*]   Support initial ramdisk/ramfs compressed using LZO                             | | 
  | |               [*]   Support initial ramdisk/ramfs compressed using LZ4                             | | 
  | |               [ ]   Built-in initramfs compression mode                                            | | 


I seem to remember that I used to have to specify an initial ramdisk size or something like that when the initrdfs was internal to the kernel. Where did this selection go? Do I need to do something different for an internal initrdfs now?
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.


Last edited by Moriah on Tue Feb 26, 2019 2:10 am; edited 1 time in total
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3076
Location: Illinois, USA

PostPosted: Thu Feb 07, 2019 4:18 pm    Post subject: Reply with quote

The shiny new grub2 is old. Unless your hardware is really old and doesn't support UEFI, use reFind instead.
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2574

PostPosted: Thu Feb 07, 2019 4:34 pm    Post subject: Reply with quote

The problem is most likely trying to go from 3.12.21 to 4.14.83. Make oldconfig cannot handle that. I recommend poking around the forum to find the appropriate kernel seed from pappy and start over.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13831

PostPosted: Fri Feb 08, 2019 3:17 am    Post subject: Re: HELP - initrd embedded in kernel Reply with quote

Moriah wrote:
I dutifully followed the handbook's directions for grub2, but it wouldn't boot.
Please show us how it fails. There are far more ways to do it wrong than to do it right. We need to start with the symptoms before we can identify the cause.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Fri Feb 08, 2019 4:38 am    Post subject: Reply with quote

It drop into a rescue shell without booting any kernel.
_________________
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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Fri Feb 08, 2019 9:14 pm    Post subject: Reply with quote

Moriah,

The rescue shell comes from the initrd which is embedded in the kernel, so the kernel must load, decompress and get as far as mounting the initrd as root.
In the rescue shell, what do you have in /dev ?

Some /dev/sd? entries would be good.
/dev/mapper would be even better.

You must have /dev/console and /dev/null as character devices too, or nothing will work.
_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Sun Feb 10, 2019 4:40 pm    Post subject: Reply with quote

Got a little further today. Now it says "uncompression error". (or "decompression error" -- can't remember which)

I assume this was trying to uncompress the initrd. I fell back to good old original grub, not grub2. Once I get it to boot with grub, then I will try grub2.

My concern, as stated earlier, is that I see no way in menuconfig to specify an initrd embedded in the kernel image, and that'sd the way I have been operating for years -- with the initrd in the kernel image. What happened to that option? How do I specify the path to the initrd? Is it the directory that has the iniotrd filesystem tree in it, or is it the tarred and gzipped image file in the /boot directory, where the kernel image lives?

Or is there a way to get the initrd in the kernel image after all, and I am just missing it?
_________________
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: 13831

PostPosted: Sun Feb 10, 2019 5:32 pm    Post subject: Reply with quote

The Kconfig symbol you want is CONFIG_INITRAMFS_SOURCE. It may be hidden if a prerequisite is not satisfied. Use the standard menuconfig tools to explore that: / to find it and see its dependencies or Z to show everything, including things you cannot select due to dependencies. That option takes either a path to a directory to bundle into the initrd or a path to a file which describes what to bundle. The latter is more convenient, since you don't need to retain separate copies of everything, and you can use it to generate an initrd with special files that your build user cannot create.
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Mon Feb 11, 2019 12:54 pm    Post subject: Reply with quote

So I now have it booting and running the initramfs, but it fail when it does the "cryptsetup luksOpen /dev/sda blahblah" saying "device not found". How could it not find /dev/sda? Here is the init file:
Code:

#!/bin/busybox sh

rescue_shell() {
    echo "Something went wrong. Dropping you to a shell."
    busybox --install -s
    exec /bin/sh
}

echo Mount the /proc and /sys filesystems.
sleep 10
mount -t proc none /proc
mount -t sysfs none /sys

echo prior to luksOpen
fdisk -l
sleep 30

echo doing luksOpen
sleep 10
cryptsetup luksOpen /dev/sda cryptoroot
echo after luksOpen
sleep 30

echo doing vgscan
sleep 10
lvm vgscan

echo doing vgchange
sleep 10
lvm vgchange -a y

echo mounting root
sleep 10
mount /dev/gentoo/rootfs /mnt/root

echo unmounting /proc and /sys
sleep 10
umount /proc
umount /sys

echo doing the pivot root
sleep 10
exec switch_root /mnt/root /sbin/init

# if we get here, it means trouble!  :-(
echo "starting emergency rescue shell..."
rescue_shell()


The echo and sleep lines are my way of debugging it, to see what is happening. The fdisk -l was an attempt to see what drives it recognized, but I guess fdisk is not in busybox. :(
_________________
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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Mon Feb 11, 2019 2:03 pm    Post subject: Reply with quote

Moriah,

When it fails and drops you to the shell, run
Code:
ls /dev/sd*

If sda isn't listed, then devtmpfs probably isn't being mounted.

That's either a kernel option, or you can add it to
Code:
mount -t proc none /proc
mount -t sysfs none /sys


For testing in the initrd shell,
Code:
mount -t devtmpfs none /dev
should work.

Now you can execute the init script by hand, either all of it and ignore the errors about proc and sys being mounted, or you can type it a line at a time.
_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Mon Feb 11, 2019 2:57 pm    Post subject: Reply with quote

When the luksOpen fails, the initscript continues anyway, and since the drive is not "right" at that point, it just runs away bonkers and does something to the usb port that messes up my little 2-port kvm. I have to disconnect the kvm from both usb ports and also from the hdmi video to totally p0ower it down, the reconnect to get it in its right mind again. That's the reason for the sleep 30 after the luksOpen: it gives me time to manually shut the laptop off with the power button, so the kvm confusion doesn't occur. I guess I could just work on the laptop screen, but I like my big monitor.

Anyway, thanks for the devtmpfs clue. I'll be looking into the kernel config to see about that later 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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Mon Feb 11, 2019 3:17 pm    Post subject: Reply with quote

Moriah,

Heh ... you never get to the shell, I didn't notice. Lets fix your init script.

Add in the echo "$@".
Code:
rescue_shell() {
    echo "$@"
    echo "Something went wrong. Dropping you to a shell."
    busybox --install -s
    exec /bin/sh
}


cryptsetup luksOpen /dev/sda cryptoroot becomes
Code:
cryptsetup luksOpen /dev/sda cryptoroot || rescue_shell "cryptsetup  failed"

and so on.

If cryptsetup fails, the || is executed. That calls rescue_shell and passes the string "cryptsetup failed" to it.

Do your calls to sleep and mount work?
My initrd init script contains full path names because I didn't set $PATH.
_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Mon Feb 11, 2019 4:00 pm    Post subject: Reply with quote

I guess I should mention that my entire initrsmfs is the same one I have used since 2014 to boot my laptop. The echos and sleeps were added to help me debig booting the linux-4.14.83-gentoo kernel, but iut has worked for almost 5 years before now.

Yes, I thought of using the || trick, but I also thought of just putting debug lines before the luksOpen to see what was happening.

I'm thinking its the devtempfs problem...
_________________
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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Mon Feb 11, 2019 4:07 pm    Post subject: Reply with quote

Moriah,

You want it to drop to a shell as soon as it fails. When it works its fine.

Check your devtmpfs settings in the kernel and add in the || clauses to the init script.
Any changes are a kernel rebuild for you anyway.
_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Mon Feb 11, 2019 4:59 pm    Post subject: Reply with quote

OK, made your suggested changes. First off, the devtmpfs automount was not set, so I turned it on.

Added the || clause to invoke the rescue shell if cryptsetup failed, which it did.

Code:

doing luksOpen
Command failed: Can not access device
cryptsetup failed
Something went wrong.  Dropping you to a shell.
/bin/sh: can't access tty; job control turned off
/ #


So I did an ls /dev, and it gave me:

console mapper null sda urandom

should I see devtmpfs there? I also did a cat /etc/mtab, but only saw /prov and /sys there.

A df returns nothing but the header line.

I next tried a "dd if=/dev/sda of=/dev/null" but it complained:
"dd: can't open '/dev/sda': No such device of address

So something is apparently screwed up with /dev/sda

ls -l /dev/sda returns:

brw-rw---- 1 0 6 8, 0 Feb 11 16:38 /dev/sda

Are the perms wrong? The major or minor numbers wrong? What gives?

These are the same perms and major/minor numbers /dev/sda has when I boot 3.12.21-gentoo-r1 on the same laptop.
_________________
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: 2117
Location: Kentucky

PostPosted: Mon Feb 11, 2019 6:39 pm    Post subject: Reply with quote

Got it to boot and get past cryptsetup. Had a misconfigured SATA driver. :oops:

Now it fail mounting root:
Code:

mounting root
mount: mounting /dev/gentoo/rootfs on /mnt/root failed: Invalid argument
mount root failed
Something went wrong.  Dropping you to a shell.
/bin/sh: can't access tty; job control turned off
/ #


I did ls -ld /mnt and got drwxr-wr-w 3 0 0 60 Feb 11 18:27 /mnt

the ls -la /mnt and it showed root with drwxr-xr-x perms, so that looks good.

then I did lvm lvdisplay and a reasonable looking output.

/dev/gentoo/rootfs is a symlink to /dev/mapper/gentoo-rootfs which is reasonable.

What could be invalid about those 2 arguments?
_________________
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: 2117
Location: Kentucky

PostPosted: Tue Feb 12, 2019 2:22 am    Post subject: Reply with quote

By chance, I was using a usb keyboard today and noticed that it didn't work. The laptop builtin keyboard worked fine. Hmm... Maybe there is a problem with usb! Maybe that's why the mount fails. So I compared the usb setting in my 3.12.21 kernel where the usb keyboard works with the setting in my new 4.whateve kernel, and guess what? There was a missing usb driver. I added it to the mix, rebuild, and booted. Now my usb keyboard works, but the mount still fails.

I should mention that the boot drive is a usb stick on this system.

Perhaps there are fislesystem related setting that apply to usb that I still don't have right. Any ideas? :idea:
_________________
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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Tue Feb 12, 2019 10:47 am    Post subject: Reply with quote

Moriah,

Once the kernel is loaded, /boot no longer matters.

Once you get into the rescue shell does
Code:
mount /dev/mapper/gentoo-rootfs /mnt/root
work.
Do both exist and look OK?

You have already said that /mnt/root does. The mount should be -o ro at this stage too as checkrootfs needs to run.

Your
Code:
/bin/sh: can't access tty; job control turned off
is probably because you need
Code:
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)

With devpts not mounted, you can't have any background jobs.

Check /dev/null permissions.
Code:
crw-rw-rw- 1 root root 1, 3 May 12  2013 /dev/null
is correct.
Lots of strange things go wrong if thats not right.

Do you have /dev/console too?
Code:
ls /dev/console -l
crw------- 1 root root 5, 1 Feb 12 09:59 /dev/console

_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Tue Feb 12, 2019 6:52 pm    Post subject: Reply with quote

My root filesystem is xfs. I had carelessly built xfs as a module. :oops:

I rebuilt it compiled into the kernel, and now it boots and I can log in! :mrgreen:
_________________
The MyWord KJV Bible tool is at http://www.elilabs.com/~myword

Foghorn Leghorn is a Warner Bros. cartoon character.


Last edited by Moriah on Tue Feb 12, 2019 6:55 pm; edited 1 time in total
Back to top
View user's profile Send private message
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Tue Feb 12, 2019 6:54 pm    Post subject: Reply with quote

Thanks for you help, Neddy! I think I can take it from here. I still have a lot of stuff to add to it, but at least it boots.
_________________
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: 2117
Location: Kentucky

PostPosted: Wed Feb 13, 2019 3:16 pm    Post subject: Reply with quote

So I have a bootable system. I have added support for a simple X server using the intel integrated video on the laptop. The box also has nvidia video, but I'll worry about that later. I need to get the basics working first.

I can ssh out of the laptop. I have sshd running on it, but I cannot log in to the laptop from another machine; it fails on the password. I can log in when I am physically at the laptop. I even re-established the passwd just to be sure, but still no remote ssh login to the laptop.

Any idea what could be wrong there?

Also, I have an X-server running, and I have twm, xemacs, firefox, xterm, xsetroot, xload, and xclock running on it just fine. But there is one nagging problem: once I start the xserver (using xinit), I cannot switch back to a text console using alt-ctl-f1 thru f6. This makes it a pain to test many things, or to close down in an orderly fashion and reboot to test a new kernel, etc. Normally I would just start X instead of using xinit, but once I start X, I loose the console and cannot get it back. Since I cannot login remote over ssh, I must power cycle the laptop to regain control.

I have not tried starting several x-servers and switching between them, although I usually operate with 5 x-server running at once on f7 thru f11. This is to support full screen vnc clients, for remote systems, or for virtual machines on the laptop.

Any idea what is causing the inability to switch to a text console after I start an X-server?
_________________
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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Wed Feb 13, 2019 6:35 pm    Post subject: Reply with quote

Moriah,

ssh into the laptop from the laptop. Its not very useful but it a good test.
Try ssh@localhost and ssh@wired/wireless_IP

password logins are not permitted for root any longer.

Once that works, god back to the remote system and try ssh -v ...
Post the output.

You don't use startx?
That should run twm, with three xterms and an analogue clock without any configuration.
alt-ctl-FnX works here.

There is a xorg.conf option to prevent alt-ctl-FnX working. My xorg.conf started life in 1999, I've just migrated it from system to system :)
_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Wed Feb 13, 2019 6:51 pm    Post subject: Reply with quote

ssh to itself doesn't work eother, but since I'm still setting this box up, the only user I have is root. I didn't know that password logins were no longer permitted for root, so that's the reason it doesn't. I'll wait until I have another user and try again. All I was doing was testing the sshd setup.

Any thought on why X doesn't let me switch back to the boot console? I seem to remember there was something you had to dop to let that happen, either in setting up the terminals, or in setting up Xorg or something else in X.
_________________
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
NeddySeagoon
Administrator
Administrator


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

PostPosted: Wed Feb 13, 2019 7:04 pm    Post subject: Reply with quote

Moriah,

My xorg.conf contains
Code:
# Uncomment this to disable the <Ctrl><Alt><Fn> VT switch sequence
# (where n is 1 through 12).  This allows clients to receive these key
# events.

#    Option "DontVTSwitch"


Do you have the Option "DontVTSwitch" active?
_________________
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
Moriah
Advocate
Advocate


Joined: 27 Mar 2004
Posts: 2117
Location: Kentucky

PostPosted: Wed Feb 13, 2019 11:48 pm    Post subject: Reply with quote

I did not even have an /etc.xorg.conf, so I copied the one I used to have from my backup server. That stopped xinit from working at all. It said "unable to find any available screen".

I'm working on bluetoth in the meanwhile, so I can get my good mouse working. I hate touch pads.
_________________
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 Kernel & Hardware All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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