LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 09-16-2008, 03:28 PM   #1
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Rep: Reputation: 30
Custom kernel problems after encrypting disk


Hi all,

I followed the excellent guide to encrypting my laptop hard drive at http://slackware.osuosl.org/slackware/README_CRYPT.TXT on Slack 12.1. Everything went well, until I came to install my own 2.6.25.4 kernel.

I followed (Bruce Hill's I think) kernel compile guide, which in short consisted of the following:

Code:
Extract source
copy in custom .config file
make
cp System.map /boot/System.map-2.6.25.4
ln -sf /boot/System.map-2.6.25.4 /boot/System.map
make modules_install
cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.25.4
I then added the following to /etc/lilo.conf:

Code:
image = /boot/vmlinuz-2.6.25.4
  initrd = /boot/initrd.gz
  root = /dev/cryptvg/root
  label = Linux_2.6.25.4
  read-only
The following section was already there from the cryptsetup (which works):

Code:
image = /boot/vmlinuz-generic-smp-2.6.24.5-smp
  initrd = /boot/initrd.gz
  root = /dev/cryptvg/root
  label = Linux
  read-only
I compiled in the following to my custom kernel:

Code:
CONFIG_EXT3=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y
After running lilo and rebooting, my system system now fails to boot. I get the following error:
Code:
VFS: Cannot open root device "fd02" or unknown-block(253,2)
Please append a correct "root=" boot option; here are the available partitions:
0300  58605120 hda driver: ide-disk
  0301     96358 hda1
I would expect an error like this because I've fail to compile something into my custom kernel - but I thought I had everything.

What have I missed?

Do I have to create a separate initrd.gz for each kernel, for instance:
Code:
2.6.24.5-smp-initrd.gz
2.6.25.4-initrd.gz

Mark.
 
Old 09-16-2008, 05:16 PM   #2
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current
Posts: 184

Rep: Reputation: 17
Did you correctly generate initrd.gz file and initrd-tree subdir in /boot ?
That should be done after placing your new modules in /lib/modules/ and kernel image file in /boot.

I used the following command to do it (kernel generic 2.6.24.7-smp from Patrick V.) while succesfully upgrading to current kernel:

mkinitrd -c -k 2.6.24.7-smp -m ext3 -f ext3 -r /dev/cryptvg/root -C /dev/sda3 -L

Try to compare your kernel settings with settings applied by Patrick V.

My first reboot attempt failed due to my faulty /dev/sda2 definition in the mkinitrd command sequence but I was able to correct that:
http://www.linuxquestions.org/questi...ukslvm-669700/
 
Old 09-16-2008, 05:25 PM   #3
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Original Poster
Rep: Reputation: 30
Hi,

Not at first - and this is where I think I went wrong.

The newer 2.6.25.4 wouldn't boot. So I did the following:

Code:
mv /boot/initrd.gz initrd-old.gz
mkinitrd -c -k 2.6.25.4 -m ext3 -f ext3 -r /dev/cryptvg/root/ -C /dev/hda2 -L
Although this wouldn't boot either. So I tried to backout by:

Code:
mv initrd.gz initrd-didntwork.gz
mv initrd-old.gz initrd.gz
My thinking was that my stock 2.6.24.5-smp kernel would at least now boot again. And it doesn't.

So now I have two kernels and neither boot. I'm pretty much resigned to the fact I'll have to do a complete rebuild, as I don't know how to get back into my encrypted drive.

Any ideas?


M.
 
Old 09-16-2008, 06:05 PM   #4
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
Mark,

No need to "do a complete rebuild."

When you use -c with mkinitrd, it does this:
Code:
mingdao@silas:~$ man mkinitrd
<snip>
       -c     Clear the existing initrd tree (by default in /boot/initrd-tree/) first.  If this is not done, running mkinitrd will add additional
              modules to the existing initrd.
So when you issued that command the first time, your old initrd image,
and everything under /boot/initrd-tree, cease to exist. Therefore, the
subsequent copying of the old stuff was futile.

You don't need to add -L to your mkinitrd comand unless you created a LVM.

Before I write "HOW-TO recover your system", can you tell me:

1 - if you've already reinstalled

2 - if you also created a LVM (and it's parameters if you did)
 
Old 09-17-2008, 02:19 AM   #5
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Original Poster
Rep: Reputation: 30
Hi Bruce,

Thanks for the info on initrd. I guess simply copying the files wasn't enough.

I have not rebuilt my system yet.

I am using LVM, and I used the following commands to create my volumes:

Code:
pvcreate /dev/mapper/slackluks
vgcreate cryptvg
lvcreate -L 2G -n swap cryptvg
lvcreate -L 55.79 -n root cryptvg

vgscan --mknodes
vgchange -ay
I am now going to go read the man page for mkinitrd ;-)

Thanks,


M.
 
Old 09-17-2008, 06:02 AM   #6
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
Okay, here's what you need to do to get back in to that Slackware system.

First, boot with Slackware CD1 of the DVD.

Second, at the boot prompt just hit enter. Then:
Code:
- Unlock the LUKS encrypted LVM:
     cryptsetup luksOpen /dev/hda2 slackluks (substitute your LVM for /dev/hda2)
- Create the device nodes for the LVM then activate the volumes:
     vgscan --mknodes
     vgchange -ay
- Mount the filesystems:
     mount /dev/cryptvg/root /mnt
     (no need to mount swap)
     chroot /mnt/
That should get you back into your system. Do a "ls -l" to see if you're in,
then you can start to fix it.

First, I'd recreate the initrd image for the Slackware default kernel, then
we can find out what's wrong with your custom kernel, once we have a
working Slackware system.

If you're in, then issue:
Code:
cd /boot
ls -l (make sure you see the default kernel -- vmlinuz-generic-smp-2.6.24.5-smp)
mkinitrd -c -k 2.6.24.5-smp -m ext3 -f ext3 -r /dev/cryptvg/root/ -C /dev/hda2 -L
less /etc/lilo.conf (make sure you still have this stanza for the default kernel:)
     image = /boot/vmlinuz-generic-smp-2.6.24.5-smp (or different if it's symlinked)
       initrd = /boot/initrd.gz
       root = /dev/cryptvg/root
       label = Slack-12.1
       read-only
lilo (if everything in /etc/lilo.conf looks correct)
When you issue the mkinitrd command, it should output something like
"9607 blocks" and nothing more (your blocks won't be the same).

When you issue "lilo" it should output something like:
Code:
root@slackware:/# lilo
Warning: LBA32 addressing assumed
Warning: '/proc/partitions' does not match '/dev' directory structure.
    Name change: '/dev/dm-0' -> '/dev/mapper/slackluks'
Warning: Name change: '/dev/dm-1' -> '/dev/cryptvg/root'
Warning: Name change: '/dev/dm-2' -> '/dev/cryptvg/home'
Warning: Name change: '/dev/dm-3' -> '/dev/cryptvg/swap'
Warning: Unable to determine video adapter in use in the present system.
Warning: Video adapter does not support VESA BIOS extensions needed for
  display of 256 colors.  Boot loader will fall back to TEXT only operation.
Added Slackware *
Added Windows
7 warnings were issued.
Those warnings are harmless -- anything else and you should record it.

Now that should boot you back into your Slackware system. If so, then we
can fix the custom kernel. First, let's just get the default to boot, so
we can always have it to fall back on. Next time we make that initrd, we
will drop the -c switch, to keep our existing modules in the initrd.gz.
 
Old 09-17-2008, 08:17 AM   #7
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Original Poster
Rep: Reputation: 30
Hi Bruce,

Thanks for this info... although something weird has stopped me.

I can get in, create the device nodes and mount the filesystems okay. However, if I cd to /boot, there are no files in there.

I definitely set /dev/hda1 to /boot. When I run:

Code:
mount
I get:

Code:
/dev/mapper/cryptvg-root on / type ext3 (rw)
/dev/hda1 on /boot type ext3 (rw)
(as well as other mount points).

Why would /boot show up as empty? I definitely haven't wiped it!


M.
 
Old 09-17-2008, 11:47 AM   #8
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Original Poster
Rep: Reputation: 30
Okay. I got in, and now I have a rescued 2.6.24.5-smp default kernel... yay!

Now I have to work out why my new custom kernel won't boot :-(

How do I create a new initrd for my custom kernel with blowing away the 2.6.24.5-smp one?

Thanks for your help so far... it's saved me a lot of time.


M.
 
Old 09-17-2008, 12:29 PM   #9
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,194

Rep: Reputation: Disabled
Quote:
Originally Posted by brooky9999 View Post
How do I create a new initrd for my custom kernel with blowing away the 2.6.24.5-smp one?
Like Bruce already told you (and the man page as well if you read it):
If you want to use a single initrd.gz for multiple kernels, you just omit the "-c" parameter to mkinitrd.
The "-c" stands for "create" - it wipes your current /etc/initrd-tree directory (out of which your initrd.gz is created) before re-adding the requested stuff. So, the correct way to proceed is
Code:
mkinitrd -k 2.6.25.4 -m ext3 -f ext3 -r /dev/cryptvg/root/ -C /dev/hda2 -L
(not the absent "-c"). This command would add the 2.6.25.4 kernel modules to your existing initrd.gz ..

Never forget to run
Code:
lilo
everytime you have messed with an initrd.gz! LILO does not read files in your /boot filesystem like GRUB does. The lilo bootloader only knows what block of data to load from your disk because the start of that block is written in the bootloader. If you change initrd.gz then LILO will lose track of it and your computer will not boot - so you run "lilo" before you reboot.
 
Old 09-17-2008, 01:12 PM   #10
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Original Poster
Rep: Reputation: 30
Cheers Eric,

I omitted the -c but my custom kernel still didn't boot.

There's obviously something still missing from it which I need to look into.


M.
 
Old 09-17-2008, 04:02 PM   #11
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
What are the errors you get when your custom kernel won't boot?
 
Old 09-17-2008, 04:35 PM   #12
brooky9999
Member
 
Registered: May 2006
Location: Marlow, UK
Distribution: Slackware 12.2
Posts: 232

Original Poster
Rep: Reputation: 30
I'm getting a bunch of warnings such as:

Code:
Using /lib/modules/2.6.24.5-smp/kernel/fs/mbcache.ko
mbcache: version magic '2.6.24.5-smp SMP mod_unload 686 ' should be '2.6.25.4 SMP mod_unload CORE2 '
insmod: cannot insert '/lib/modules/2.6.24.5-smp/kernel/fs/mbcache.ko' : Invalid module format (-1): Exec format error
Using /lib/modules/2.6.24.5-smp/kernel/fs/ext3/ext3.ko
jdb: version magic '2.6.24.5-smp SMP mod_unload 686 ' should be '2.6.25.4 SMP mod_unload CORE2 '
insmod: cannot insert '/lib/modules/2.6.24.5-smp/kernel/fs/jdb/jdb.ko' : Invalid module format (-1): Exec format error
Using /lib/modules/2.6.24.5-smp/kernel/fs/ext3/ext3.ko
ext3: version magic '2.6.24.5-smp SMP mod_unload 686 ' should be '2.6.25.4 SMP mod_unload CORE2 '
insmod: cannot insert '/lib/modules/2.6.24.5-smp/kernel/fs/ext3/ext3.ko' : Invalid module format (-1): Exec format error
However, I do then get a chance to enter my LUKS passphrase.

After correctly entering it in, I get:

Code:
mount: mounting /dev/crypt/root/ on /mnt failed: Not a directory
ERROR:  No /sbin/init found for rootdev (or not mounted).  Trouble ahead.
        You can try to fix it.  Type 'exit' when things are done.
I created my initd for 2.6.24.5-smp as per your post, and then another (minus -c) for 2.6.25.4. So I'm not sure why it's trying to load the wrong versions of mbcache, jdb and ext3.

I'm guessing that those first errors are giving me the more serious one about not mounting my root volume.

Would I be about right?


M.
 
Old 09-17-2008, 05:55 PM   #13
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,194

Rep: Reputation: Disabled
Quote:
Originally Posted by brooky9999 View Post
I'm getting a bunch of warnings such as:

Code:
Using /lib/modules/2.6.24.5-smp/kernel/fs/mbcache.ko
mbcache: version magic '2.6.24.5-smp SMP mod_unload 686 ' should be '2.6.25.4 SMP mod_unload CORE2 '
insmod: cannot insert '/lib/modules/2.6.24.5-smp/kernel/fs/mbcache.ko' : Invalid module format (-1): Exec format error
Using /lib/modules/2.6.24.5-smp/kernel/fs/ext3/ext3.ko
jdb: version magic '2.6.24.5-smp SMP mod_unload 686 ' should be '2.6.25.4 SMP mod_unload CORE2 '
insmod: cannot insert '/lib/modules/2.6.24.5-smp/kernel/fs/jdb/jdb.ko' : Invalid module format (-1): Exec format error
Using /lib/modules/2.6.24.5-smp/kernel/fs/ext3/ext3.ko
ext3: version magic '2.6.24.5-smp SMP mod_unload 686 ' should be '2.6.25.4 SMP mod_unload CORE2 '
insmod: cannot insert '/lib/modules/2.6.24.5-smp/kernel/fs/ext3/ext3.ko' : Invalid module format (-1): Exec format error
It looks as if you have edited /boot/initrd-tree/load_kernel_modules and used hard-coded kernel versions there. Normally, the initrd would not even try to load kernel modules that did not match the version of the kernel it is running on.
But these errors are harmless (though annoying).
It is not even required to use /boot/initrd-tree/load_kernel_modules by making it executable - it is there to help you if you have to go through hoops to load your modules properly (for instance when you have to pass parameters to the modules).

The other stuff you posted indicates that your initrd may have forgotten to load the driver for your ext3 filesystem. Did you really add these modules (mkinitrd -m ext3)? If so, I can only guess that you edited B]/boot/initrd-tree/load_kernel_modules[/B] (forgetting to add the modules for your new kernel) and made it executable.

Eric
 
Old 09-17-2008, 06:34 PM   #14
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
As for the non-loading custom kernel, you're possibly missing something
in your .config. You need certain crypto cipher modules for DM_CRYPT to
work. For sure you need SHA256, AES, and CBC.

Please post your 2.6.25.4 .config file somewhere for us to see. Also
would not hurt to see:
ls -l /boot
cat /etc/lilo.conf
 
Old 09-18-2008, 09:27 AM   #15
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current
Posts: 184

Rep: Reputation: 17
Maybe it would be easier only to upgrade your kernel/Slackware packages to PV's current state (for example 2.6.24.7-smp) as a 1st step.
That way you'll see if the procedure works.
If so, then compile your own kernel.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with custom kernel k3rnel Debian 9 03-08-2007 01:15 PM
Problems to apply a custom patch kernel 2.6.18-1.2257.fc5 Ronin_tekorei Linux - Kernel 2 01-08-2007 08:08 AM
Custom Kernel Problems Penguin of Wonder Ubuntu 13 03-14-2006 10:20 PM
problems installing custom 2.6.14 kernel (for SATA problems) Ekkume Ubuntu 0 12-29-2005 02:39 PM
Custom Kernel 2.4.27 install problems (sarge) KaraK Debian 2 01-07-2005 10:47 AM


All times are GMT -5. The time now is 04:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration