BEFN$?FN Ask Klaus! 8JB BC8LJ

suspend mode? I’ll give you a short over- is large enough to hold the content of view on what needs to be done to use your computer’s memory (see Listing 1). suspend to RAM and suspend to disk The example in Listing 1 shows that here. this computer has about 1.2GB RAM, Klaus Knopper is the creator of To use suspend to disk, you need to and 1.9GB of swap, so suspend to disk Knoppix and co-founder of the enable this feature in the kernel. (I as- is possible. sume that this is already done in In your setup, if the available swap LinuxTag expo. He currently Ubuntu.) See Figure 1. space is lower than RAM plus swap in For suspend to disk, the kernel also use, then suspend to disk will just fail works as a teacher, program- needs to know how and where to store and you would have to repartition the mer, and consultant. If you have the content of your notebook’s RAM hard drive for a larger swap partition to while it is in power-off mode. make it work. a configuration problem, or if The “where” part is configured at the As soon as swap and the boot com- kernel boot command line. Mine looks mand line are set up, you can start the you just want to learn more like this: suspend procedure by telling the kernel about how works, send to freeze then store the running system $ cat /proc/cmdline to disk. your questions to: ... resume=/dev/hda3 ... Before this, sending a couple of commands is a good idea, just in case klaus@linux-magazine. com With this preset boot option, the kernel that unwritten data gets lost because of a knows that the partition, which possibly failed wake up later. (Sending only one contains a suspended system, is the third might not be sufficient because of its partition on the first IDE hard disk in my asynchronous nature.) You must be root setup. On boot, the kernel will automati- for this procedure: 8jljn`k_?Xi[p cally try to restore a saved session from My Asus M2V-MX-based desk- this partition when this option is pres- # sync; sync; sync top suspends well in Windows ent. To modify the boot kernel command # echo shutdown > /sys/power/disk Vista, but it does not suspend line, you have to change the APPEND # echo disk > /sys/power/state in Ubuntu Hardy. I have changed S3 and line in your ’s setup (/etc/. ACPI versions in the BIOS to see if that conf for LILO, with LILO being called Now the kernel should switch to text works. Although it causes some differ- after a change, or /boot/grub/grub.cfg or console mode and display what it’s ences in behavior, the system still does menu.lst for the grub bootloader). As a doing. In case of failure, you will see an not work in Ubuntu. What should I do? last resort, you can type the option in error message in the output of dmesg. the bootloader’s interactive Some information is missing in mode. Listing 1: Free swap space

your description that could help On the swap partition, which 01 $ grep MemTotal /proc/meminfo will also become the “hiber- solve the problem. 02 MemTotal: 1295172 kB Do you mean “suspend to RAM” nate” partition, you need to re- 03 (STR) or “suspend to disk” (S2D)? serve space about the size of 04 $ cat /proc/swaps Is the problem that suspend just does your RAM. 05 Filename Type Size Used Priority not do anything, or is the problem that So, please check to see 06 /dev/hda3 partition 1959920 664036 -1 the notebook does not wake up from whether your free swap space

58 ISSUE 96 NOVEMBER 2008

058-060_ask-klaus.indd 58 11.09.2008 15:09:43 Uhr Ask Klaus! BEFN$?FN

Depending on how well ACPI works on your notebook, using

# echo platform > 5 /sys/power/disk # echo disk > 5 /sys/power/state

instead of the previous suggestion might work even better because the ACPI BIOS might know how to switch peripheral devices to suspend mode in order to wake up correctly later. After freezing processes, the kernel will write the entire system state to the swap partition and power off the system. On next boot, the kernel will search for a hibernate signature on the swap =`^li\(1JZi\\ej_fk]ifdk_\b\ie\Zfe]`^i\^Xi[`e^jljg\e[kf[`jb% partition and load the suspended system from there if at all possible. read from it. For example, if hard disk LJ9N`i\c\jj9ifX[YXe[ Some things that could go wrong controller drivers are not statically I have a three USB wireless when resuming: compiled into the kernel, the kernel broadband Huawei HSDPA 1. Some hardware does not reinitialize might not have a chance to initialize CE0682 modem. I cannot get it properly when being awoken from the resume procedure later if the ini- to work on the Fedora 8. Can you ex- suspend, so your system freezes. This tial ramdisk containing the drivers plain why it is difficult to add any USB result is known to happen with non- does not explicitly do this. modem to the Fedora, Red Hat, and suspendable sound drivers. Again, the boot/ kernel log shown by Ubuntu platforms? To be on the safe side, make sure that dmesg might give a hint about what in your own suspend/ resume script, went wrong. I’m afraid that only the original all drivers known to be unstable after To suspend to RAM (if supported), use hardware manufacturer knows wake up are unloaded. mem instead of disk in the suspend com- why they only provide Windows Example (before suspend): mands above. drivers for their hardware. If the Apparently, you don’t need a suspend “modem” has a DHCP mode in which it fuser -k /dev/dsp 5 partition for this; standby could also be distributes addresses to an Ethernet-net- # Stop sound output an option, which will only reduce power worked computer automatically, you rmmod snd_intel8x0 5 consumption of some devices but not re- should be able to use it without any spe- # Unload onboard sound driver ally suspend the system: cial drivers. For closed, proprietary USB protocols that only the hardware manu- 2. Because of the way the kernel has # echo mem > 5 facturer knows about, it is a very tire- been configured in a specific distribu- /sys/power/state some – and in no way cost-effective – tion, the swap partition might not be task to develop a driver via reverse engi- accessible early enough to be able to or neering. Therefore, almost nobody will do this for free. # echo standby > 5 A company’s strategic decision to sell /sys/power/state hardware that works only for a specific does not have a rea- Instead of using the newer /sys/power/... sonable technical solution. The best ad- interface, you can also try the ACPI sleep vice I could give is to return the appar- states control file: ently defective device as a warranty case (it does not work, does it?) and claim # echo 4 > 5 your money back. /proc/acpi/sleep 5 # Suspend-to-disk GlggpfeG\e;i`m\ I am a university student and an or amateur Linux user. Can you tell me how to install mbr.bin on # echo 3 > 5 my pen drive? I want to boot a version of /proc/acpi/sleep 5 Pendrivelinux from this device. Is it pos- # Suspend-to-ram sible to install from Puppy 3.10? It never

NOVEMBER 2008 ISSUE 96 59

058-060_ask-klaus.indd 59 11.09.2008 15:09:45 Uhr BEFN$?FN Ask Klaus!

works when I try to find it with the Listing 2: Pen drive example instruction: 01 # fdisk -l /dev/sdc

02 Disk /dev/sdc: 8021 MB, 8021606400 bytes locate mbr.bin 03 16 heads, 32 sectors/track, 30600 cylinders Also, I would like to know whether it is 04 Units = cylinders of 512 * 512 = 262144 bytes possible to install SysLinux with the 05 Disk identifier: 0x10d72c95 following command: 06 07 Device Boot Start End Blocks Id System

08 /dev/sdc1 * 16 30600 7829568 c W95 FAT32 (LBA) syslinux -s /dev/sda1

I have already visited pendrivelinux. com been flushed to disk or enforce it by call- default linux and followed the instructions, but I al- ing sync or the eject commands below. timeout 10 ways have problems from my After this, check to see whether the prompt 1 pen drive. partitioning of the pen drive is still OK. label linux Another problem is that the machines To let the kernel know that partitioning kernel linux I have access to only have 256MB of data has been changed, you might have append initrd=minirt.gz 5 RAM, so I can’t boot into Ubuntu 7.10 to reconnect the drive. The easiest way root=/dev/ram0 or 8.04. If I understand things correctly, to do so is with with these versions of Ubuntu, it is pos- Linux kernel (linux) and sible to install LILO and SysLinux. # eject /dev/sdc (minirt.gz) must be copied to the same # eject -t /dev/sdc partition containing the bootloader. The Making a FAT16/ FAT32-format- Linux filesystem itself can be located on ted USB pen bootable only takes or you can physically remove and re- a separate partition, formatted with a a few commands. In this exam- insert the drive. Linux filesystem such as , , or ple, the pen drive is present as /dev/sdc Instead of installing a custom master ReiserFS, if it is not installed as a loop- (Listing 2). boot record, I recommend that you first back image file. This partition table is already perfect try a standard one: In the case of installing Knoppix on a for “boot from USB hard disk” BIOS pen drive, you would just copy the mode. The first partition is of FAT(32) # ms-sys -s /dev/sdc KNOPPIX directory to the FAT(32) parti- type and marked as “bootable.” tion of the pen drive, which contains all If just the “bootable” flag for the first For installing the SysLinux bootloader on the data and programs: partition is missing, it can be added with: the first partition, the command is: # mkdir -p /media/sdc1 # sfdisk -A1 /dev/sdc # syslinux /dev/sdc1 # mount -t vfat -o 5 shortname=winnt /dev/sdc1 5 Usually, you do not need a special boot Note that you really have to type the par- /media/sdc1 record like the mbr.bin you asked about. tition name here, not the entire device # cp -rL syslinux.cfg 5 But if your computer needs one and you name. linux minirt.gz KNOPPIX 5 have found a customized boot record file SysLinux is a kind of “DOS program,” ... /media/sdc1/ recommended for a specific purpose (it just written to a specific, bootable loca- # umount /media/sdc1 should be a maximum of only 488 tion on the partition; therefore, you can- bytes), you can install this custom boot not just “mount and copy” ldlinux.sys to Please note the shortname=winnt record by just copying it over to the de- the drive. mount option, which will create file vice file: For USB pen drives, the -s[low] option names on the FAT partition with lower- of SysLinux should not be necessary; and uppercase spelling, just as in the # cat mbr.bin > 5 however, if not even the Sys- original file name. Most Live distribu- /dev/sdc Linux boot command line tions are picky about upper- and lower- is displayed, but the case in file names. You must wait for a while pen drive seems to After all files needed to run the distri- until new data has be accessed, it is bution have been copied (and you have worth a try. created a Linux partition containing the SysLinux requires a con- distribution’s filesystem), you should be figuration file, syslinux.cfg, able to boot from the pen drive. ® which tells SysLinux what kind of operating system to start and, pos- sibly, also to load a ramdisk. Send your Linux questions to The following is an example of sys- klaus@linux-magazine. com. linux.cfg contents:

60 ISSUE 96 NOVEMBER 2008

058-060_ask-klaus.indd 60 11.09.2008 15:09:47 Uhr