Hi,

I have invented an installation procedure for SUSE 10.1 that allows the user to
integrate s2disk (s2both) with powersaved and put the resume binary into the
initramfs image created by mkinitrd.

The instruction is appended and the scritpt and patches referred to in it are
attached.  Some file paths are hardcoded, but I don't think it's a big deal.

Comments welcome.

Greetings,
Rafael


-- 
This document describes how to install the s2disk (s2both) and resume tools
on SUSE Linux 10.1 quickly.  Of course you can do it in a more sophisticated
way, but then you'll need to figure out a couple of things yourself.

I assume you have read Section I of the HOWTO in the main source directory.
If not, please do it now and get back here when you're ready.

1. Install the Marc Lehmann's libLZF library (optionally), libgcrypt-devel
(optionally) and build the s2disk and resume as described in Section I (b)-(d)
of the HOWTO, but _do_ _not_ install the resume initrd.  Make sure that
suspend.conf and s2disk will be installed in /etc/ and /usr/local/sbin/ ,
respectively.

2. Copy the resume binary to /usr/local/sbin/ .

3. Go to the scripts/suse-10.1/ directory and run

# ./modify-system-files.sh

(as root).  It will use the two patches in the scripts/suse-10.1/ directory,
mkinitrd.patch and do_acpi_sleep.patch, to modify /sbin/mkinitrd and
/usr/lib/powersave/do_acpi_sleep .

This will make powersaved use s2disk for suspending to disk and mkinitrd
put the resume binary into the initrams images created by it.

4. Configure and build the kernel, as described in /usr/src/linux/README.SUSE
(this file is in the kernel-source package, so you need to have it installed).
However, initially it's better to use a vanilla kernel.org kernel, so you'll
need to download one (at least 2.6.17, but there have been quite a lot of
suspend-related fixes recently, so it probably is a good idea to use the
newest possible kernel, either "stable" or from the -rc series).

To configure the new kernel, you can use your running kernel's configuration
file, in which case you'll have all of the necessery modules built.  For this
purpose:

(a) become root, go to the /usr/src/linux/ directory (it will only be present
if the kernel-source package is installed) and run

# make cloneconfig

(b) become normal user, unpack the kernel source wherever you want, for
example somewhere in your home directory, and go to the new kernel source
directory,

(c) run

$ cp /usr/src/linux/.config .

(d) run

$ make oldconfig

Now, you probably will be asked many questions related to the new kernel's
configuration, but it generally is safe to leave the default settings,
unless you know what you're doing.

(e) run

$ make

or, if you have an SMP system and you want the kernel to compile faster,

$ make -j N

where N is a small integer (on my dual-core box N=5 seems to be the best).

5. Become root, go to the new kernel source directory and run

# cp arch/x86_64/boot/bzImage /boot/vmlinuz-<version> && \
cp System.map /boot/System.map-<version> && make modules_install

where <version> is the version of your new kernel (eg. 2.6.18-rc2).

6. Run

# mkinitrd -k vmlinuz-<version> -i initrd-<version>

7. Add the new kernel entry to /boot/grub/menu.lst , i.e.:

(a) Find the entry of your default kernel (it should be the first one, with
the title "SUSE Linux 10.1") and copy it, _without_ the preceding comment,
to the top (ie. right after "gfxmenu (hd0,0)/message").

(b) In the new entry, replace "vmlinuz" with "vmlinuz-<version>" and
"initrd" with "initrd-<version>" and save the file.

Now, the head of your /boot/grub/menu.lst should read like this:

# Modified by YaST2. Last modification on Thu Jul 20 23:09:44 CEST 2006

color white/blue black/light-gray
default 0
timeout 8
gfxmenu (hd0,0)/message

title SUSE Linux 10.1 (2.6.18-rc2)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-rc2 root=/dev/sda1 vga=0x31a resume=/dev/sda2 
splash=silent showopts
    initrd /initrd-2.6.18-rc2

###Don't change this comment - YaST2 identifier: Original name: linux###

title SUSE Linux 10.1
    root (hd0,0)
    kernel /vmlinuz root=/dev/sda1 vga=0x31a resume=/dev/sda2 splash=silent 
showopts
    initrd /initrd

8. Test if the new kernel boots.  If it does, you also should be able to
suspend using s2disk and resume should be run automatically from the initrd
during system startup, if needed.

9. It may be needed to add SUSPEND2DISK_SKIP_RESUME_CHECK="yes" if powersaved
complains that the resume partition is not set and refuses to suspend.

10. If you want to use s2both instead of s2diks, you will need to replace
"s2disk" with "s2both" in do_acpi_sleep.patch before running
./modify-system-files.sh in step 2.

Of course, you will also have to build s2both and install it, but for this
purpose you only need to run

$ make s2both

instead of "make s2disk" and

$ make install-suspend

instead of "make install-s2disk" when building the suspend tools.  Please note,
however, that pciutils-devel has to be installed for this to work.

Attachment: modify-system-files.sh
Description: application/shellscript

--- a/do_acpi_sleep	2006-07-20 03:45:02.000000000 +0200
+++ b/do_acpi_sleep	2006-07-25 18:27:42.000000000 +0200
@@ -54,6 +54,8 @@ OPT="--hctosys"
 # where is the s2ram binary installed?
 S2RAM="/usr/sbin/s2ram"
 S2RAM_LOG=/var/log/suspend2ram.log
+S2DISK="/usr/local/sbin/s2disk"
+S2DISK_LOG=/var/log/suspend2disk.log
 
 # blank the "suspend console"
 deallocvt 63
@@ -68,20 +70,25 @@ fi
 
 case "$1" in
     suspend2disk)
-	IMG_SZ=0
-	read IMG_SZ < /sys/power/image_size	
-	$MYECHO /sys/power/state disk
-	RET=$?      # 28=ENOSPC, "not enough swap."
-	#
-	# the logic here is:
-	# if image_size > 0 (without kernel support, IMG_SZ will be zero),
-	# and we got ENOSPC, then try again with image_size set to zero.
-	if [ $RET -eq 28 -a $IMG_SZ -ne 0 ]; then # try again with minimal image size
-		echo 0 > /sys/power/image_size
-		$MYECHO /sys/power/state disk
+	if [ -x $S2DISK ]; then
+		$S2DISK >> $S2DISK_LOG 2>&1
 		RET=$?
-		echo $IMG_SZ > /sys/power/image_size
-        fi
+	else
+		IMG_SZ=0
+		read IMG_SZ < /sys/power/image_size	
+		$MYECHO /sys/power/state disk
+		RET=$?      # 28=ENOSPC, "not enough swap."
+		#
+		# the logic here is:
+		# if image_size > 0 (without kernel support, IMG_SZ will be zero),
+		# and we got ENOSPC, then try again with image_size set to zero.
+		if [ $RET -eq 28 -a $IMG_SZ -ne 0 ]; then # try again with minimal image size
+			echo 0 > /sys/power/image_size
+			$MYECHO /sys/power/state disk
+			RET=$?
+			echo $IMG_SZ > /sys/power/image_size
+        	fi
+	fi
 	[ "$SUSPEND2DISK_RESTORE_CLOCK" == "yes" ] && $HWCLOCK $OPT
 	;;
     suspend2ram)
--- a/mkinitrd	2006-07-17 13:53:21.000000000 +0200
+++ b/mkinitrd	2006-07-27 13:24:46.000000000 +0200
@@ -1405,6 +1405,8 @@ mkinitrd_kernel() {
     cp_bin /sbin/udevtrigger $tmp_mnt/sbin/
     cp_bin /sbin/udevsettle $tmp_mnt/sbin/
     cp_bin /usr/bin/udevinfo $tmp_mnt/sbin/
+    cp_bin /usr/local/sbin/resume $tmp_mnt/sbin/
+    cp -a /etc/suspend.conf $tmp_mnt/etc/
 
     mkdir -p $tmp_mnt/etc/udev/rules.d
     # Create our own udev.conf
@@ -1630,6 +1632,9 @@ mkinitrd_kernel() {
 	|mknod /dev/console c 5 1
 	|mknod /dev/null c 1 3
 	|mknod /dev/kmsg c 1 11
+	|mknod /dev/snapshot c 10 231
+	|mknod /dev/random 1 8
+	|mknod /dev/urandom 1 9
 	|mkdir /dev/pts
 	|mkdir -m 1777 /dev/shm
 	|ln -s /proc/self/fd /dev/fd
@@ -1705,9 +1710,6 @@ mkinitrd_kernel() {
 	|	rootdev=\${o#nfsroot=}
 	|	rootdev_cmdline=1
 	|	;;
-	|    resume=*)
-	|	resumedev=\${o#resume=}
-	|	;;
 	|    journal=*)
 	|	journaldev=\${o#journal=}
 	|	;;
@@ -1778,8 +1780,9 @@ mkinitrd_kernel() {
 	|fi
 	|
 	|# Verify manual resume mode
+	|resumedev=$(grep -i 'resume device' /etc/suspend.conf | sed -e 's/.*=[ \t]*//')
 	|if [ "$resume_mode" != "off" -a -n "\$resumedev" ]; then
-	|    if [ -w /sys/power/resume ]; then
+	|    if [ -x /sbin/resume ]; then
 	|	echo "Trying manual resume from \$resumedev"
 	|	resume_mode=1
 	|    else
@@ -2396,7 +2399,7 @@ mkinitrd_kernel() {
 	|	    devn=
 	|       fi
 	|       if [ -n "$major" -a -n "$minor" ]; then
-	|	    echo "$major:$minor" > /sys/power/resume
+	|	    /sbin/resume
 	|	    major=
 	|	    minor=
 	|	else
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to