Redirected from page "DebianInitrd"

Clear message

Note: I found these instructions a little outdated for the current Sid. the DistroAndHardwareSetup/Ubuntu_Breezy_Badger worked well for me as of early 2006.

Note2: The instructions work again (April 02006) for sid - just use the first downloadable initrd-script. YMMV.

Note3: Prepackaged debian kernels up from 2.6.17 use yaird to configure initrd, for more information see on the bottom of this page

Incorporating modular Software Suspend support into the 2.6 Debian kernels is relatively easy (2.4 modular Software Suspend was not available at time of writing). Note - unless you require Software Suspend to be built as modules, it is much less painful to build them directly into the kernel (making this page largely irrelevant). If you wish to proceed anyway, here goes...

Steps:

  1. Apply the patches for Software Suspend 2.0.0.103 or later against your favourite 2.6 kernel.
  2. Use make-kpkg with the --initrd option to create a kernel image package.

  3. Ensure you have installed the initrd-tools package.
  4. Drop the below script into /etc/mkinitrd/scripts/.
  5. Install your kernel with dpkg.

eg:

/usr/src$ tar xjf kernel-source-2.6.10.tar.bz2
/usr/src$ cd kernel-source-2.6.10
/usr/src/kernel-source-2.6.10$ /tmp/software-suspend-2.1.7-for-2.6.10/apply

Check everything applies cleanly (it should).

/usr/src/kernel-source-2.6.10$ cp /boot/config-`uname -r` .config
/usr/src/kernel-source-2.6.10$ make menuconfig

Select Power Management Options -> Software Suspend 2. Select Modules (press M) for "Software Suspend 2", "Swap Writer", "LZF image compression", and "Text mode console support" (bootsplash if you so desire - but you will need to modify the script below to load that module too).

/usr/src/kernel-source-2.6.10$ make-kpkg --revision swsusp.1 --rootcmd fakeroot --initrd kernel-image
[... kernel builds ...]
/usr/src/kernel-source-2.6.10$ cd ..
/usr/src$ dpkg -i kernel-image-2.6.10_swsusp.1_i386.deb
[... package installs ...]

Initrd script

Click to download the script

Click to download the older script (not working for 2.2-rc8 and newer)

Click to download the old script with module support - not needed for recent Suspend2 versions

Make sure this script is called /etc/mkinitrd/scripts/swsusp2 (no special characters like a dot ...) and is executable. It only works with swap partitions, not swap files. For swapfiles, you will need to set the resume2= parameter in GRUB/LILO manually. Also note that if you are using swap partitions, this script alleviates the need to specify a resume2= parameter on the kernel command line.

If you are using a version prior to 2.1.2, then you will need to change do_resume in the script to activate.

Didn't work for me (on kernel 2.6.12). I found a script that works here: http://www.mm.bme.hu/~szazs/IBMtpT42.html

#!/bin/sh
cat <<EOF >>$INITRDDIR/script
if [ -z "\$noresume" ]; then # be careful with the 'dollar' sign
    echo >/proc/software_suspend/do_resume
    # IMPORTANT: use the line below for version 2.2-rc8 and newer
    # echo >/proc/suspend2/do_resume
    umount -n devfs
    umount -n proc
fi
EOF

Neither the script from suspend2.net nor the script above worked for me so I took following way:

$ mkinitrd -k -o /boot/initrd.img-2.6.14.3 2.6.14.3
$ cd /tmp/mkinitrd.*
$ echo "echo > /proc/suspend2/do_resume" >> initrd/linuxrc
$ mkcramfs initrd/ /boot/initrd.img-2.6.14.3

Ok, this last one works for me, BUT I had to create the swap device inside initrd image. Using the steps above, do it before the mkcramfs command:

$ cd initrd/dev
$ mknod hda b 3 0
$ mknod hda1 b 3 1

where hda1 is your swap partition or the partition where you will save the resume image. Change it if you are using another partition. 18-01-2006 -- TiagoVaz

Getting yaird to work

I have yaird 0.0.12 here YMMV. Edit the file /etc/yaird/Default.cfg, after the first line that loads modules, here is my diff:

                MODULE          mousedev
                MODULE          evdev
+               MODULE          sata_nv
+               MODULE          sd_mod
+               MODULE          scsi_mod
+               MODULE          libata
+
+               TEMPLATE        resume
 
                #
                # NETWORK -- Insert modules for all ethernet devices

Please note that loading all those modules is necessary only for SATA disks. My swap partition is /dev/sda1 (on sda harddrive), so I need to load those modules, otherwise Supsend2 will not be able to see the swap partition. If you have a swap partition on ATA drive, then you can skip loading those modules.

Next, you have to edit the file /etc/yaird/Templates.cfg, here is my diff:

2.6.17:

        END TEMPLATE

+       TEMPLATE resume
+       BEGIN
+               SCRIPT "/init"
+               BEGIN
+                       !if [ -z "$noresume" ]
+                       !then
+                       !  echo swap:0801 > /proc/suspend2/resume2
+                       !  echo > /proc/suspend2/do_resume
+                       !fi
+               END SCRIPT
+       END TEMPLATE

        TEMPLATE insmod

2.6.18 is a little different:

+                       !  echo swap:0801 > /sys/power/suspend2/resume2
+                       !  echo > /sys/power/suspend2/do_resume

You can add this code anywhere between templates. I have added it before TEMPLATE insmod, but it's not important. It is very important to write a correct name for swap device in my case it was:

swap:0801

That is magic name for /dev/sda1 - yaird cannot access /dev filesystem so we have to access /dev/sda1 by using this magic number, and this number will change from kernel to kernel! So you have to determine it with following command:

echo `perl -e "@a=stat '/dev/sda1';printf 'swap:%04x', \\$a[6]"`

But remember to replace /dev/sda1 with your swap device. Then you can put this magic number into /etc/yaird/Templates.cfg with the diff presented above.

After those changes are done a simple reinstall of linux-image will apply your modifications:

sudo dpkg -i ./linux-image-2.6.17-2-k7_2.6.17-6_i386.deb

Now you can hibernate and it will work. There is no need to modify grub's menu.lst file. Yaird takes care of that by calling suspend2 when needed.

cat

None: DistroAndHardwareSetup/DebianInitrd (last edited 2007-10-10 21:26:09 by 193)