LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Linux Answers > Applications / GUI / Multimedia
User Name
Password

Notices


By hyperlink1uk at 2004-03-11 13:16
Hi ALL

I decided to write this howto, to stop people from running into the problems I did. In this howto I will explain how to patch your kernel for:

SuSE 9.0
Running Kernel 2.6.3
With Hibernation
and Bootsplash

Then how to configure hibernation and bootsplash and how to get them both to work with each other


Patching The kernel


Hibernation patches

I know the 2.6 kernels have a swsusp patch but it did not work for me.
I used the patches available at http://swsusp.sourceforge.net
Download the new 2.6.3 kernel from kernel.org and extract to /usr/src

You can get the first patch here
http://prdownloads.sourceforge.net/...le.bz2?download
& the second here
http://prdownloads.sourceforge.net/...le.bz2?download

Extract both of these to anywhere on your computer using bunzip2

cd /usr/src/linux-2.6.3
patch -p1 < /pathtopatch/software-suspend-linux-2.6.3-test6-whole
patch -p1 < /pathtopatch/software-suspend-core-2.0-whole


BootSplash patch

Get the patch from here
ftp://ftp.suse.com/pub/people/stepa....1.4-2.6.3.diff
patch -p1 < /pathtopatch/bootsplash-3.1.4-2.6.3.diff

Ok, hopefully you got no hunk errors when patching

Configuring the Kernel

Type cd /usr/src/linux-2.6.3
Type make xconfig

compile the following into the kernel

For Hibernation you need these options to be set
Code:
 PowerManagement Options -----> Software Suspend 2--------> Swap Writter
 PowerManagement Options -----> Software Suspend 2--------> Compile in debugging output
 PowerManagement Options -----> Software Suspend 2-------->Relaxed /proc/swsusp permissions
For bootsplash you need these options to be set
Code:
 Device Drivers ------> Graphics Support------->VESA VGA
 Device Drivers ------> Graphics Support------->Bootsplash Configuration------>Bootup splash screen
OSS

Ok, I had a nightmare with ALSA stopping my computer coming out of hibernation. Unless you really need alsa, compile the driver for your sound card for the open sound system.

Compiling the Kernel

Type the following commands to compile the kernel and modules
mkproper
make bzImage
make modules
make modules_install

You have now compiled your kernel and installed the modules, install your kernel and System.map file as follows:

cp /usr/src/linux-2.6.3/arch/i386/boot/bzImage /boot/bzImage-2.6.3
cp /usr/src/linux-2.6.3/System.map /boot/System.map-2.6.3

Creating Initrd

Type mkinitrd -k bzImage-2.6.3 -i initrd.img-2.6.3
If in the output you see a line indicating a bootsplash image
has been put into your initrd, skip the next part, if not try the following:

Configuring mkinitrd

<Warning this bit can be dangerous, although it worked fine on my system>

If like me, mkinitrd did not put your image files into the initrd, try this:


I edited mkinitrd as follows to get it to compile in my bootimage.

open /sbin/mkinitrd in your fav txt editor and find this code :

Code:
 if [ -n "$splash" -a -x /sbin/splash.bin ]; then
 if [ -f /etc/sysconfig/bootsplash ]; then
 . /etc/sysconfig/bootsplash
 fi
 bootsplash_picture_dir="$root_dir/etc/bootsplash/themes/$THEME"
 
 echo -ne "Bootsplash:\t"
 if [ -d $bootsplash_picture_dir -o -L $bootsplash_picture_dir ]; then
 for size in ${splash//,/ }; do
 bootsplash_picture="$bootsplash_picture_dir/images/bootsplash-$size.jpg"
 cfgname="$bootsplash_picture_dir/config/bootsplash-$size.cfg"
 if [ ! -r $cfgname ] ; then
 echo "disabled for resolution $size"
 elif [ ! -r $bootsplash_picture ] ; then
 echo "no image for resolution $size"
 else
 echo "$THEME ($size)"
 /sbin/splash.bin -s -f $cfgname >> $initrd_image
 fi
 done
 else
 echo "no theme selected"
Replace this code with the following:
Code:
 if [ -n "$splash" -a -x /sbin/splash.bin ]; then
 if [ -f /etc/sysconfig/bootsplash ]; then
 . /etc/sysconfig/bootsplash
 fi
 bootsplash_picture_dir="$root_dir/etc/bootsplash/themes/SuSE"
 
 echo -ne "Bootsplash:\t"
 if [ -d $bootsplash_picture_dir -o -L $bootsplash_picture_dir ]; then
 for size in ${splash//,/ }; do
 bootsplash_picture="$bootsplash_picture_dir/images/bootsplash-$size.jpg"
 cfgname="$bootsplash_picture_dir/config/bootsplash-$size.cfg"
 if [ ! -r $cfgname ] ; then
 echo "Enabling BootSplash:Applying 2.6.3 Fix: Bootsplash forced"
 /sbin/splash.bin -s -f /etc/bootsplash/themes/SuSE/config/bootsplash-1024x768.cfg >> /boot/initrd.img-2.6.3 
 elif [ ! -r $bootsplash_picture ] ; then
 echo "no image for resolution $size"
 else
 /sbin/splash.bin -s -f /etc/bootsplash/themes/SuSE/config/bootsplash-1024x768.cfg >> $initrd_image
 fi
 done
 else
 echo "no theme selected"
Change "bootsplash-1024x768.cfg" in above code to the file for your resolution

Now try again to make your initrd

Type the following:

mkinitrd -k bzImage-2.6.3 -i initrd.img-2.6.3

You should see a line saying ?a bootsplash has been put in by overriding the built-in settings?

Updating Grub

Update /boot/grub/menu.lst with the new bzImage-2.6.3 kernel and initrd.img-2.6.3

Also to the kernel line add the following

resume2=swap:/dev/hdxx vga=791 splash=silent desktop

Replace /dev/hdxx with your swap partition.

****Now REBOOT into your new kernel****

If all went well then carry on to the next part, if not go back and check you did everything right.

HIBERNATION SETUP

The hibernation software is good, but not all of your system drivers will get restored and some services need restarting. For me, and I guess most people, the following will work:


WARNING
If you are using the nvidia binary driver switch back to the nv open source driver by editing the line
driver=nvidia to driver=nv
in /etc/X11/XF86Config

See the end of the Howto for more information about the problems with the binary driver.


Download the following
http://prdownloads.sourceforge.net/...end.sh?download
run suspend.sh --install

Now open /etc/suspend.conf

Delete the whole file and replace with this:
Code:
 
 #-*-mode: sh-*-
 # Configuration of software suspension
 #
 
 # If your graphic device is not able to return properly from suspend
 # you can switch to textconsole before suspend and return to your
 # X-console after resume.
 # If you use an nvidia card, you can set this to nvidia. This
 # will try to restore your 3D upon resume. This trick may be useful
 # for other cards.
 # Default: "no"
 SWSUSP_LEAVE_X_BEFORE_SUSPEND="no"
 
 
 
 # Some services (e.g. network) may cause some hangs if they are not
 # stopped before a suspend/resume cycle. You can set
 # SWSUSP_RESTART_SERVICES to a list of services to stop before suspend
 # and automatically restart after resume.
 # If suspending results in killing some application because of lack
 # of memory, you may also add here some of your launched services,
 # so as to save memory. Good candidates are httpd, nfsserver, sendmail, etc.
 # Default: " postfix alsasound gpm xntpd nfs network"
 SWSUSP_RESTART_SERVICES=" postfix gpm network kbd acpid"
 
 # Some services may need to be stopped before a suspend/resume cycle.
 # You can set STOP_SERVICES_BEFORE_SUSPEND to a list of services to stop
 # before suspend. These services will NOT automatically be restarted after
 # the resume, use SWSUSP_RESTART_SERVICES instead if you want this
 # behaviour.
 # Default: ""
 SWSUSP_STOP_SERVICES_BEFORE_SUSPEND="alsasound"
 
 # Conversely, you can set START_SERVICES_AFTER_RESUME to a list
 # of services to start after resuming.
 # Default: ""
 SWSUSP_START_SERVICES_AFTER_RESUME=""
 
 # Those are programs that prevent from suspending. If they are
 # running and --force or --kill option aren't used, suspension
 # is aborted.
 # Default: ""
 SWSUSP_NON_COMPATIBLE_PROGS=""
 
 # You can ask to killall these applications before suspend.
 # Default: none
 SWSUSP_STOP_PROGS_BEFORE_SUSPEND=""
 
 # You can ask to run some applications before suspend using this variable.
 # For instance, it may stop your VPN.
 # Default: none
 SWSUSP_START_PROGS_BEFORE_SUSPEND=""
 
 # You can ask to run some applications after resume using this variable.
 # For instance, it may restart your ADSL connection.
 # Default: none
 SWSUSP_START_PROGS_AFTER_RESUME="/root/run"
 
 # If the following mount points cannot be unmounted, 
 # then suspension is aborted unless --force or --kill
 # option is used on command line
 # Default: "/floppy /cdrom /var/adm/mount"
 SWSUSP_UMOUNTS="/floppy /cdrom /var/adm/mount"
 
 # These mount points should be mounted after suspend
 # They should appear in /etc/fstab
 # Default: none
 SWSUSP_REMOUNTS=""
 
 # If the following interfaces cannot be stopped, 
 # then suspension is aborted unless --force or --kill
 # option is used on command line
 # Default: "eth0"
 SWSUSP_DOWNIFS="eth0"
 
 # These interfaces should be started after suspend
 # With "auto" the interfaces stopped before suspension
 # will be started in reverse order.
 # Default: "auto"
 SWSUSP_UPIFS="auto"
 
 # Some modules should be unloaded before a suspend/resume cycle. You
 # can set UNLOAD_MODULES_BEFORE_SUSPEND to "yes" if you want
 # unused modules to be removed from kernel space before suspend. 
 # This will be done after stopping services.
 # With "no", nothing will be done before suspension.
 # With "auto", it only does "rmmod -a" to clean modules
 # which are marked "(autoclean)" in lsmod. 
 # 
 # Default: "yes"
 SWSUSP_UNLOAD_MODULES_BEFORE_SUSPEND="yes"
 
 # These modules should be unloaded after stopping services but
 # before suspending.
 # Default: 
 SWSUSP_REMOVEMODS=""
 
 # These modules should be loaded after suspend
 # Gentoo users can use "modules.autoload" here to read modules out of
 # /etc/modules.autoload (this requires other Gentoo-specific scripts)
 # Default: 
 SWSUSP_INSERTMODS="es1371"
 
 # Use SWSUSP_FORCE_SUSPEND_MODE to reset the behaviour of
 # suspension. If empty, this let the suspension
 # behaviour unchanged. Otherwise, these values will cause:
 # echo "0 $SWSUSP_FORCE_SUSPEND_MODE" > /proc/swsusp/all_settings"
 #
 # This is simply a quick way of setting your favourite swsusp
 # parameters. To determine the value of SWSUSP_FORCE_SUSPEND_MODE,
 # tweak the files in /proc/swsusp to your heart's content, and then
 # use . The value of
 # SWSUSP_FORCE_SUSPEND_MODE will be all but the first number. eg,
 # # cat /proc/swsusp/all_settings
 # 0 2048 0 100
 # means you should have SWSUSP_FORCE_SUSPEND_MODE="2048 0 100"
 #
 # Alternatively, you can use the keyword "acpi" to use the
 # /proc/acpi/sleep interface in place of /proc/swsusp/all_settings
 #
 # Default: "0", i.e. halt, escape disabled. extra settings are untouched
 SWSUSP_FORCE_SUSPEND_MODE="0"
 
 # If you have problems with hardware clock drift amplified by
 # suspension, try to set SAVE_CLOCK_ON_SUSPEND to "yes". The
 # kerneltime will being saved before suspending. If you have
 # network access, best is to set this variable to yes and add
 # xntpd in services to start/stop below. If you haven't such
 # a service permanently available, it is better to leave it
 # to no, so that hardware clock remains as a reference for
 # the system.
 # Default: "no"
 SWSUSP_SAVE_CLOCK_ON_SUSPEND="no"
 
 # On some hardware, the power is cut off before the disk has 
 # flushed his own hardware cache. Insert the device of your
 # swap partition here (e.g. /dev/hda) if you want to issue
 # hdparm -W 0 <device>
 # before suspension.
 # Default: none
 SWSUSP_DISABLE_HW_DISK_CACHE=""
 
 # This specifies the VT on which logging will occur if --silent
 # is not enabled. This is also the VT which will be switched to
 # if SWSUSP_LEAVE_X_BEFORE_SUSPEND is enabled.
 # Default: 9
 SWSUSP_VT="9"
Replace es1371 with the OSS driver for your sound card


To bring up all the modules and services that you need, you could add them to suspend.conf, however I do it with a simple bash script.

Create a file in /root, called run
Code:
 Add the following information to the file.
 #! /bin/bash
 /sbin/splash -s -u 62
	modprobe ide-cd
	modprobe cdrom
	modprobe ide-scsi
	modprobe ehci-hcd
	modprobe uhci-hcd
	modprobe hid
	modprobe usb-storage
	modprobe ext3
	modprobe sr-mod
	modprobe parport-pc
	modprobe lp
	modprobe evdev
	modprobe usblp
	modprobe es1371
 	/etc/init.d/boot.scsidev start
 	/etc/init.d/boot.proc start
 	/etc/init.d/microcode start
 	/etc/init.d/pcscd start
	/etc/init.d/setserial start
 	/etc/init.d/boot.idedma start
Make the file executable. This is normally done by right clicking the file, going to properties, and selecting the advanced tab in KDE. You need to replace es1371 with the module for your sound card. Also ext3 should be replaced with the filesystem on your root device, i.e. ext2 etc. The last one; boot.idedma, can freeze up, this is why I run this process after I have come out of hibernation. Beware, on my system, failure to reactivate boot.idedma results in system slow down and crashes.

<----Optional Needed On OSS Systems---->

Ok, if you took my advice and switched to the OSS sound server, you need to apply this fix. I have only just discovered this, it could be a problem with my sound card or a general problem. Anyway, this worked for me.

Upon resume, OSS can play DVDs and CDs but as soon as you try to play a local file it locks up with an error about snd-pcm.

In order to fix this problem you need to rmmod a number of modules, as normal this can be configured within the suspend.conf file. However, I prefer to have a separate file that does this.

As the root user type visudo

Now add the following to this file
Code:
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod es1371
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod snd-pcm-oss
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod snd-pcm
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod snd-timer
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod snd-mixer-oss
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod snd
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod ac97-codec
	%users ALL=(ALL) NOPASSWD: /sbin/rmmod soundcore
	%users ALL=(ALL) NOPASSWD: /home/username/.soundfix/run
You need to change es1371 to match the oss sound module for your sound card, you might not need the ac97-codec as well but it does not hurt to have it there anyway. Also replace ?username? with your username.

Save this file in the normal way (Press esc, then type :wq and press enter)

Now login as a normal user and type:

mkdir .soundfix
then:
vi run

add the following to that file
/code]
sudo /sbin/rmmod es1371
sudo /sbin/rmmod snd-pcm-oss

sudo /sbin/rmmod snd-pcm
sudo /sbin/rmmod snd-timer
sudo /sbin/rmmod snd-mixer-oss
sudo /sbin/rmmod snd
sudo /sbin/rmmod ac97-codec
sudo /sbin/rmmod soundcore
[/code]

Again you need to replace es1371 with the module for your sound card for OSS


Ok that's it, as root type /usr/local/sbin/hibernate
Your computer should then hibernate and shutdown
Boot back up into your new kernel

****WARNING: Make sure you boot into your new swsusp enabled kernel, otherwise you could screw your whole filesystem up.**************************************************************

If you really want to use your nvidia binary driver go along to the swsusp.sourceforge.net web site and look at the FAQ section for more info.

Use this Howto at your own risk, software suspend could corrupt your whole file system.

EXTRA: Allowing normal users to Hibernate without using a password

As root type visudo

then add the following:

%users All=(ALL) NOPASSWD: /usr/local/sbin/hibernate

save the file as normal.

Now a normal user can hibernate the computer by issuing the command:

sudo /usr/local/sbin/hibernate


Ok Thats it for now.... As i find more modules that need restoring, or ones that I have said do that don't, I will update this FAQ. I would be greatfully for any feedback.


  



All times are GMT -5. The time now is 02:08 PM.

Main Menu
Advertisement
Advertisement
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
Open Source Consulting | Domain Registration