# [SOLVED] suspend2, initrd & kernel can't find sata boot disk

## lovecraft

Hello,

I am trying to get suspend2 to work on my system.  Currently, I'm running a non-suspend2 kernel: gentoo-sources-2.6.17-r8, which I believe requires an initrd.  This all works "just fine", thanks to genkernel.

However, I'm now trying to configure suspend2-sources-2.6.19-r3, and it seems the system (initial RAM disk, I presume) can't find my /dev/sda2 boot partition:

```
!! Block device /dev/sda2 is not a valid root device..

!! The root block device is unspecified or not detected.

   Please specify a device to boot, or "shell" for a shell...

```

My platform:

  amd_64x2

  ASRock 939Dual_VSTA Socket 939 ULi M1695

  WD SATA Raptor is /dev/sda

  etc...

After typing "shell", I do an lsmod and get a list like this (hand copied):

```
nfs

lockd

sunrpc

jfs

raid10

raid1

raid0

dm_mirror

dm_mod

sl811_hcd

usbhid

ff_memless

ohci_hcd

uhci_hcd

usb_storage

ehci_hcd

usbcore

```

In the working system, here's an edited list of loaded modules:

```
% lsmod | egrep -v '^(snd|i2c)'

Module                  Size  Used by

nfsd                  282224  17 

exportfs                7232  1 nfsd

radeon                122848  2 

drm                    97704  3 radeon

rtc                    11232  0 

ns558                   5952  0 

gameport               19664  2 ns558

parport_pc             45800  0 

parport                46796  1 parport_pc

uli526x                19860  0 

radeonfb              112320  1 

sg                     37736  0 

xfs                   603584  0 

nfs                   258608  0 

lockd                  77136  3 nfsd,nfs

sunrpc                191368  12 nfsd,nfs,lockd

jfs                   188432  0 

reiserfs              264128  1 

raid10                 27072  0 

raid1                  26496  0 

raid0                   9344  0 

dm_mirror              25536  0 

dm_mod                 71312  1 dm_mirror

sl811_hcd              15616  0 

ohci_hcd               23684  0 

uhci_hcd               27536  0 

usb_storage            95744  0 

usbhid                 58016  0 

ehci_hcd               34824  0 

usbcore               154976  9 snd_usb_audio,snd_usb_lib,sl811_hcd,ohci_hcd,uhci_hcd,usb_storage,usbhid,ehci_hcd

```

Here's some relevant lines from my grub.conf:

```

title Gentoo Linux 2.6.17 trimmed

      root (hd0,0)

      kernel /kernel-genkernel-x86_64-2.6.17-gentoo-r8 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda2 udev

      initrd /boot/initramfs-genkernel-x86_64-2.6.17-gentoo-r8

# Trial genkernel suspend2

title Linux 2.6.19 (suspend2)

      root (hd0,0)

      kernel /kernel-genkernel-x86_64-2.6.19-suspend2-r3 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda2 udev

      initrd /boot/initramfs-genkernel-x86_64-2.6.19-suspend2-r3

```

Prior to this current machine, I went about life blithely ignorant of initrds and such because my system didn't seem to need one.  This one seems to need one; I'm not exactly sure why.  My main problem then is: how to I configure aspects of this initial ramdisk?  Is this a completely manual operation?  What's missing from my current initrd and how do I get it in there?  And what is "linuxrc" all about?  Finally, why do I need an initrd at all?  Perhaps can get along without it?

Any and all pointers appreciated.

thanks,

lovecraft

----------

## Pseudonimo

 *Quote:*   

>  system (initial RAM disk, I presume) can't find my /dev/sda2 boot partition

 

I'm confused, your grub.conf is configured for a boot drive in (hd0,0). So which is the boot partition, and which is the real root?

Anyway this fortunately is very simple. See this:

```
title Linux 2.6.19 (suspend2)

      root (hd0,0)

      kernel /kernel-genkernel-x86_64-2.6.19-suspend2-r3 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda2 udev

      initrd /boot/initramfs-genkernel-x86_64-2.6.19-suspend2-r3 
```

So what's going on is that grub will boot the kernel in (hd0,0) using the environment options mentioned after kernel, inside the initrd below. 

The initrd is simply a small linux system, that's used to setup a larger system. Some people use it to decrypt the root device. The linuxrc is going to be the first script to be executed. Open it and you'll see it tries to use the real_root option to mount etc... If you read the linuxrc everything will become easier to debug. I'm writting a new one for genkernel that boots encrypted livecd's, it's very similar to the one in initrd:

http://mega.ist.utl.pt/~nhqb/gentoo/catalyst/linuxrc-old

To open your initrd see the gentoo wiki entry on fbsplash (i think it's there), or the luks.

----------

## wynn

If you're using initramfs (and not the old initrd) you don't need the kernel command line arguments "root=/dev/ram0" or "ramdisk=8192" as it uses root_fs which has no backing store so arguments to do with ramdisk are ignored. The kernel also doesn't need ramdisk support unless you have some other use for it.

You also don't need "init=/linuxrc" as the kernel defaults (for initramfs) to running /init and /linuxrc is a symlink to /init.

genkernel now runs mdev from BusyBox instead of udev so the final "udev" isn't needed either.

----------

## Pseudonimo

But genkernel uses initrd right?

----------

## wynn

 *Pseudonimo wrote:*   

> But genkernel uses initrd right?

 Not recent versions: to check a version, see if it creates an "initramfs" file â if it does then it isn't using initrd. The GRUB command line starts "initrd" but it still passes the kernel an initramfs file to unpack.

initramfs is "the wave of the future" (TM) and the kernel developers want to move all the kernel code to mount a root filesystem to a builtin initramfs. 

Documentation/early-userspace/buffer-format.txt has *Quote:*   

>  Starting with kernel 2.5.x, the old "initial ramdisk" protocol is getting {replaced/complemented} with the new "initial ramfs" (initramfs) protocol.  The initramfs contents is passed using the same memory buffer protocol used by the initrd protocol, but the contents is different.

 and Documentation/filesystems/ramfs-rootfs-initramfs.txt has more details.

The kernel will still handle the old "initial ramdisk": in fact, if the kernel configuration has ramdisk support in it, a special bit of code will be compiled in to check whether the "initrd" image is "initial ramdisk" or "initial ramfs".

If you are writing a new linuxrc you may be interested in the examples in HOWTO Initramfs

----------

## Pseudonimo

Thank you! That means the genkernel man page is misleading, I'll have a look and patch a bug. But the linuxrc doesn't seem to change, I wrote a patch against the latest sources.

----------

## wynn

The current genkernel initramfs directory layout goes to a lot of trouble to be backwards compatible: it has /init (the same as /usr/share/genkernel/linuxrc unless you specify your own version), /linuxrc which is a symlink to /init and /sbin/init which is another symlink to /init.

I suppose /init changes a bit from version to version but it's more of a framework on which you can hang things.

You should probably be looking at the latest unstable genkernel than the stable one, it looks as though it will be in production soon.

You might also be interested to know that the unstable genkernel version now appends the different cpio files it generates to the final image: the stable version creates five or more cpio archives and concatenates them together, that is, they are separated by TRAILER records and cpio will only unpack the first one. With the new version, cpio will unpack all of them.

----------

## lovecraft

Hi,

Thanks for info, but none of this is helping.

1) how can I figure out what I need to add to the initramfs?

2) where does this get done?  Where do I put the files?  Is there some directory somewhere that you can add modules to that go into an initramfs image?

3) why do I need to write a "new" linuxrc, just to add a module to the image?  The only linuxrc on my system came with genkernel and is under /usr/share/genkernel/linuxrc.  Am I supposed to edit that?

4) how do I decide whether I can get by without one? Why would I need one with my existing hardware?  How do I get rid of needing this?

lovecraft

----------

## Pseudonimo

Ok, making it simple, just ignore our posts, except from the first two. Please share /etc/fstab.

You said: *Quote:*   

> Currently, I'm running a non-suspend2 kernel: gentoo-sources-2.6.17-r8, which I believe requires an initrd. 

 

Wrong, gentoo-sources don't need a initrd  :Razz: .

```
kernel /kernel-genkernel-x86_64-2.6.19-suspend2-r3 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda2 udev 
```

Make sure this is all in one line (don't know if the one you posted got a break from the site or if it's broken).

I never used that kernel, but after looking a bit here: http://www.suspend2.net/HOWTO-2.html

http://gentoo-wiki.com/HOWTO_Software_Suspend_v2#initrd.2Finitramfs_with_Suspend2

It looks like you don't need initramfs (?). 

```
Initrd/Initramfs's with Suspend2

Using an initrd/initramfs with Suspend2 is possible, but you will have to trigger a resume yourself in your linuxrc/init. To do this, you MUST either modify your distro's initrd/ramfs generation routines or edit your linuxrc (or init) script yourself to contain the line

    echo > /sys/power/suspend2/do_resume 

Either way, this call must come BEFORE your initrd/ramfs mounts your filesystem. If the line is missing, your system will not resume. If the line comes after mounting file systems, you will most likely suffer from filesystem corruption. You have been warned.

This will work with most initrd setups produced by the various mkinitrd's. If you however use a kernel command-line containing something like

    root=/dev/ram0 init=/linuxrc 

as is described in linux/Documentation/initrd.txt, it will not work. You're probably better off porting your setup to use an initramfs instead.

You can now recompile your kernel with Suspend2...
```

ps: Where did you find that avatar?  :Wink: 

----------

## lovecraft

 *Pseudonimo wrote:*   

> Ok, making it simple, just ignore our posts, except from the first two. Please share /etc/fstab.
> 
> 

 

Here you go:

```
/dev/sda1      /boot      ext2      noauto,noatime   1 2

/dev/sda2      /      ext3      noatime      0 1

/dev/sda3      none      swap      sw      0 0

/dev/sda5      /usr      ext3      noatime      0 0

/dev/sda6      /tmp      ext3      noatime      0 0

/dev/sda7      /var      ext3      noatime      0 0

/dev/sda8      /home      ext3      noatime      0 0
```

 *Quote:*   

> Wrong, gentoo-sources don't need a initrd .

 

Okay, must be because I was using genkernel.  I'll try getting by without it.

 *Quote:*   

> 
> 
> Make sure this is all in one line (don't know if the one you posted got a break from the site or if it's broken).

 

Thanks, it is all on one line.

Re: need for initrd/initramfs, I'll be working on getting rid of that now.  The switch to the AMD-64x2 and the mobo I have made me confused I guess.

Thanks for all the help!  I'll report back as soon as I get to try some of your tips.

 *Quote:*   

> 
> 
> ps: Where did you find that avatar? 

 

Chameleons UK "Strange Times" album cover   :Cool:   It seems to go well with "lovecraft" as a username.

----------

## lovecraft

Hi,

So I tried to eliminate using initrd or initramfs from my kernel.  Here now is my grub config:

```
# Trial genkernel suspend2

title Linux 2.6.19 (suspend2)

      root (hd0,0)

      kernel /kernel-2.6.19-suspend2-r3 ro root=/dev/sda2 resume2=swap:/dev/sda3 udev
```

But when booting, I get the "BIG FAT WARNING" and the message, 'Failed to translate "/dev/sda3" into a device id', then the following message:

```
If you want to use the current suspend image, reboot and try

again with the same kernel that you suspended from. If you want

to forget that image, continue and the image will be erased.

```

There's a 25 second delay, then the kernel attempts to go on.  At that point, it panics because it can't find /dev/sda2, my boot partition.

So this tells me that the kernel can't find my SATA boot disk.  I must be doing something dumb; I'm sure there are many people out there with SATA boot disks these days.  Do I need to have SCSI emulation compiled in?  I thought that was deprecated.  What part of the kernel configuration addresses SATA support?  In my first posting, I listed all modules loaded in my working (non-suspend2) kernel; what is it I need compiled into the kernel to avoid this?

very confused, but appreciative of help,

lovecraft

----------

## wynn

Have a look at [FAQ] KC13: I just installed a new kernel and it won't boot: this shows what you need to enable for a SATA root filesystem.

Note that there are 2 SATA sections, one for 2.6.18 and earlier (still the first) and the other for 2.6.19 and later (3).

----------

## lovecraft

Thanks for the clue.  I've looked in many places but forgot the FAQs in the Gentoo forums.  This led me right to what I needed to change.

lovecraft

----------

