-- this is a raw text document i wrote when installing an hibernation part on my thinkpad x30 i will make a howto of this as soon as possible here below is a raw version -- why ? 1. hibern if forced shutdown attempted 2. hibern if battery low (while in sleep it will wake the lappy + do the hibern) 3. os independant (note about windows) as long the os supports sleep mode it will work, and as long the os is concerned the laptop is just going into sleep. as soon it does, the bios takes over and handles the hibernation. + note about passwords in bios and disk password 1. we need netbsd boot disks so we grab boot1.fs and boot2.fs i am using an usb floppy drive (thinkpad X models dont have internal floppy disks). it appears as /dev/sd0 so i use /dev/sd0d to dump boot1.fs and boot2.fs there. i like to specify the size and count to make sure i am warned if dd can't put all the boot1.fs and boot2.fs contents on each disk: (insert boot disk 1) dd if=boot1.fs of=/dev/sd0d count=1 bs=1440 1+0 records in 1+0 records out 1474560 bytes transferred in 175.714 secs (8391 bytes/sec) (insert boot disk 2) dd if=boot2.fs of=/dev/sd0d count=1 bs=1440 1+0 records in 1+0 records out 1474560 bytes transferred in 175.714 secs (8391 bytes/sec) (interesting in how consistant the reported speed is for two different disks, up to 0.001 ms) 2. we need to create the hiberation disk i have done a dd dump of the floppy itself grab is _here_ 3. in order to create the hibernation partition, we need to calculate its size. you have two methods here. a. you start with an empty disk and use the hibernation floppy to create an hibernation partition. then you restart on the netbsd boot disks and check the size of the partition : this is the size you will have to keep free in order to create an hibernation partition after creating your netbsd partitions. note: the hibernation partition has to be cylinder aligned. you must not look at the size in bytes but to the size in cylinders this is a bit more lengthy but you get the exact number of cylinders required without wasting any disk space (for perfectionists) b. you reserve enough disk space for ram + a conservative value so the hibernation floppy wont complain. this might leave you with some unused space disk at the end of the disk, not a big problem those days. i have calculated the ram used for hiberation according to ram inside the thinkpad. when i leave 512 mb inside the hibernation partition is XXX when i leave 1024 mb inside the hibern part is XXX of course, the hibernation floppy does cylinder alignment but it is possible to calculate the disk space required : asdsad i use method a. i only have to do it once to know the required size, once and for all. so i don't mind booting, creating hibernation, booting on netbsd to check the size required and install netbsd and leaving at the end of the disk enough space for hibernation partition so i can after netbsd partitions are created boot on the hibernation floppy, install the hibernation partition and restart on netbsd to intall it properly (later additionnels netbsd partitions just use existing partitions and update content unless you do upgrades directly from netbsd itself which i do) you have to be patient to use this method. it does guarantee no space lost on disk and you only do it once even if you do other netbsd (or another os) installs later. when you do create the hibernation partition, the floppy puts it on disk but not at the end of disk. this can be a problem so i like to keep it at the end of the disk. so i create it on empty disk, record the size in _cylinders_ then remove it. create my bsd partitions minus cylinders required, then reboot on hibern floppy to create it again, this time it will be at the end of the disk and without wasting any disk space. then i reboot on bsd again, proceed with install + boot blocks install. we boot netbsd disk1, then disk 2 we select english, unchanged keyboard (us for me) then we leave sysinst. now we have to main commands to handle the disk fdisk and disklabel we are interested in fdisk here for this work just fdisk wd0 and see the result : # fdisk wd0 Disk: /dev/rwd0d NetBSD disklabel disk geometry: cylinders: 193821, heads: 16, sectors/track: 63 (1008 sectors/cylinder) total sectors: 195371568 BIOS disk geometry: cylinders: 1023, heads: 240, sectors/track: 63 (15120 sectors/cylinder) total sectors: 195371568 Partition table: 0: NetBSD (sysid 169) start 63, size 195371505 (95396 MB, Cyls 0-12921/96/1), Active 1: 2: 3: Bootselector disabled. -- ok here we have a 100 mb disk. the bios geometry is a bit special because the way the C/H/S is encoded by the bios. the bios, in order to boot, does emulate a MS-Dos 21h call which only uses a few bits to encode the C/H/S so that's why cylinders is 1024 only and goes from 0 to 1023 and the bios plays on heads (virtual value here) in order to report disk size. The NetBSD disklabel geometry is closer to reality (closer but with no real guarantee: this is especially true with modern disks that don't really show your their real physical condition. some have reserved parts for security purposes or DRM-bloated stuff and they remove those parts from any outside view even when checking the disk geometry at what we think is low-level) Here I have a NetBSd partition using the whole disk, and no boot selector since there's nothing else. Let's purge the disk of any partitions now # fdisk -i -u wd0 n <- (we dont change idea of what bios thinks) 0 <- (we edit partition 0) sysid : 0 <- (0 removes the partition) for each partition to remove, type its number, type 0 to have it removed. at the end you should have : Partition table: 0: 1: 2: 3: Bootselector disabled. <- y to update bootcode from /usr/mdec/mbr y to write new partition table now we boot the hibernation floppy to check which size is required for hibernation. that hibernation floppy was made for ibm by phoenix (which did design the thinkpad bios) it will work on those models : 27 Sep 2000 v4.50 *This release supports the following ThinkPad computers: - A20m, A20p, A21e, A21m, A21p, A22m, A22p, A22e - A30, A30p - A31, A31p - T20, T21, T22, T23 - T30 - T40, T41, T42, T43 - X20, X21, X22, X23, X24 - X30, X31 - TransNote - R40 - R40e if you got any other model go check the lenovo thinkpad matrix driver and download the one you need. i have a tar.gz archive with original .exe installer (if you want to create your own hibern floppy from the original v4.50 disk with readme + lenovo webpage about the floppy saved from firefox) best is to download the .img file and dump it to a floppy because the .exe required you to use windows or ms-dos to create the hibernation floppy. any unix with dd and a floppy driver will handle the .img file which will give you the very same floppy anyway. of course using the .img makes you not agree with the licence of use, its terms. so if you are a lawyer and prone to such bullshit, make my day and download the .exe and have fun with it. ok so we boot the hibernation floppy. two choices there: 1. Create partition 2. Reboot i got 1024 mb on my x30. my model has a video card which uses part of it for video ram (stolen video memory that's called) for 1 Gb ram it requires a minimum of 1048579 Kb 1 Gb is 1048576 bytes so it uses 3 bytes (a marker probably to identify the partition to the bios in addition to its sysid). Well, take your ram, in bytes, add 3 to 5 and round up to cylinders until you are over this number when reserving disk space. in order to avoid loosing precious time, use a full 5k bytes. ram size in bytes + 5k bytes should be enough (on a 100 Gb disk, 1 Gb rounded to cylinders just add 2k bytes) make sure cylinders -> bytes is at least this value and that's the space you need to reserve if you want to do it fast (this howto deals with a method that leaves no disk space unused because hackers tend to be very cautious about even a few bytes left unused on their disks... dont ask why. you have to be a perfectionist hacker to understand this i guess). Requires at least 1048579 Rounded to cylinders that's 1050840 Kb (2264 bytes over, thus we use 5k bytes if you want to make it fast) i let it create the partition (which is damn slow) and reboot under netbsd to check how many cylinders it did use : 140 100 Gb = 12921 Cyl so we have to keep 140 for the hibernation floppy. fdisk does display this info : # fdisk wd0 [...] 3: IBM Thinkpad hibernation (sysid 160) start 1, size 2116799 (1034 MB, Cyls 0/0/2-140) of course, with a start at 1 this won't let you install anything on the disk. so we purge this partition and we can reboot under NetBSD. There, we reserve 140 Cyl for hibernation, and use everything else for NetBSD (well, unless you are sharing the disk with more than one OS). Once you have created the partitions, don't proceed with NetBSD's install. Just create the partitions minus required Cyls, format them and reboot on the hibernation floppy disk to create the hibernation partition. Then, reboot again under NetBSD and do a standard installation, and have it end with the bootblocks install. And you're done. don't forget that because netbsd will see two partitions, it will automatically select a boot selector. you have to configure this when you create the partitions by giving a nice name to your NetBSD partition (like NetBSD) and make it default and dont give a name to hibern partition. Best is to remove the boot selector and have it boot NetBSD directly of course. Do as your prefer. I have to admit I like to see "1: NetBSD" appear when I turn on the laptop so I keep the boot selector on disk (and for other reasons I wont explain here but that's hacker stuff) when you have deleted the hibernation partition, launch sysinst, select customize and not "use whole disk" and change display to Cyls (by using "e: Change input units (sectors/cylinders/MB) remove the required Cyls for hibernation partition and give everything else to NetBSD. Just make sure you got the required Cyls free when you have finished creating your partitions. I usually create 1 Gb partitions for root, var, use memory for /tmp (32-64 Mb is ok, use 64 if you can) and everything else in /usr since I will later on move /home to /usr/home and keep a link from /home to /usr/home (as any good admin should do) Well. Change input units to Cyl, check the size above where it says "Total disk size" Mine shows "Total disk size 12921 cyl." I remove the 140 needed for hibernation, and give everything else (12781 cyl.) to NetBSD. Use entry "a" and put this info: a: kind: NetBSD b: start: 0 cyl c: size: 12781 (*) d: end: 12781 (**) e: active: Yes f: install: Yes g: bootmenu: NetBSD h: default: Yes (*) 12921 - 140 = 12781 (disk cyls - hibern cyls) (**) calculated for you Make sure you put to "Yes" the active, install and default options. You can put any name on "bootmenu" that's the name that will appear in the bootmenu. Be proud : use NetBSD there. the next step lets you install or not the bootselect code. if you only have NetBSD and hibernation partition on disk, you dont need it. I keep it for other reasons but you don't need to. Continue with sysint, use option to set partition sizes. I use the following setting : MB Cylinders Sectors Filesystem 1024 2081 2097648 / 1024 2081 2097648 swap 64 131 132048 tmp (mfs) 91286 185471 186954768 /usr 1024 2081 2097648 /var 0 0 0 /home (I will remove /home and install it in /usr/home with a /home -> /usr/home link after install) You let sysinst newfs each partition and you stop there. Leave sysinst, reboot on hibernation floppy and create the hibernation partition. Once done, reboot on NetBSD, proceed with install, dont change fdisk part, use "Use existing partitions" and just tell sysinst which mount goes for each partition. From now on, pressing Fn+Hiberation logo on keyboard will have the Bios send a "sleep" call to the OS, then it grabs control and saves ram onto disk (CPU context, etc. is saved) Now you can get in the Bios and tell it to (1) hibernate if battery is going to die (2) hibernate if power button is pressed (to avoid forced shutdown if a moron goes next your laptop) files i used for this howto: boot1.fs boot2.fs (NetBSD 3.1) hibernation_v450.img (dd dump. use any unix dd with no conversion 8-bits to recreate)