After much research, I'm up and running. I'll gradually edit this to make it a thorough guide, then I'll copy it to the wiki. Damn, that took awhile ... but I sure learned a lot doing it. There's little risk as long as you keep an extra copy of your backup zip (mydata.tgz) and a spare, working iso or GRUB entry.
Here's what I learned:
Down sides:
- resuming takes almost as long as reboot ... or maybe that's a compliment to the stock boot time!
- no luck yet with compression. s2disk works fine, but resume can't find the image.
Summary follows, though this has only been tested by me (1.1rc2, 1.1rc3; Evo N410c laptop). Here's what works for me:
Rebuilding uswsusp1. Get the source code from
http://suspend.sourceforge.net/download.shtml2. Get suspend.tce, and install/load that (you need the libx86 and liblazy libraries).
3. configure, make, make install. See the wiki about building extensions. The instructions below assume you built suspend-0.8 and installed it using DESTDIR=/tmp/package.
Unzip tinycore.gz (from the iso) and patch itSee the wiki about remastering. You'll need to know about cpio, tar, and advdef
1. Unpack your tinycore.gz (initrd). If you use a CD/ISO, you'll have to mount it and pull out tinycore.gz.
To unpack it, do something like:
cp /path/to/tinycore.gz /tmp/tinycore.gz
cd /tmp
mkdir extract
cd extract
sudo zcat /tmp/tinycore.gz | sudo cpio -i -H newc -d
2. Change/update /etc/tc-config. I have to run mkswap when a swap size isn't found. Based on tc-config from 1.1rc2, I had to:
--- /tmp/extract/etc/init.d/tc-config Sat Feb 7 19:26:57 2009
+++ /etc/init.d/tc-config Sat Feb 7 19:03:56 2009
@@ -388,12 +395,13 @@
rm -f /etc/sysconfig/tc.resume 2>/dev/null
RESUME=`basename $RESUME`
SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
- [ -z "$SWAP_SIZE" ] && /sbin/swapon /dev/"$RESUME" && SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
- [ -z "$SWAP_SIZE" ] && exit 1
- MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
+ [ -z "$SWAP_SIZE" ] && /sbin/mkswap /dev/"$RESUME" && /sbin/swapon /dev/"$RESUME" && SWAP_SIZE=$(cat /proc/swaps | grep "$RESUME" | awk '{print $3}')
+ if [ -n "$SWAP_SIZE" ]; then
+ MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/{print $2}')
if [ $SWAP_SIZE -gt $MEM_SIZE ]; then
grep -q disk /sys/power/state && echo "disk" > /etc/sysconfig/tc.resume
fi
+ fi
fi
if [ -n "$SECURE" ]; then
3. install the resume binary. You built it as part of the suspend-0.8 package (above). Should be something like:
cp /tmp/package/usr/local/sbin/suspend/resume/resume /tmp/extract/resume
4. install the snapshot device. Something like:
sudo mknod /tmp/extract/dev/snapshot c 10 231
5. The /etc/suspend.conf file (from the suspend-0.8 package you built) tells the s2disk and resume tools where to store your hibernate image. You need to edit that file, then install it to /etc/suspend.conf. In particular, edit the "resume device =" line. I recommend setting "image size = 0" as that minimizes the hibernate image. Takes more time going down, but seems to save a bit coming up. After you edit that, copy it to /tmp/extract/etc/:
cp /tmp/package/usr/etc/suspend.conf /tmp/extract/etc/suspend.conf
6. change /etc/inittab by adding on ::sysinit:/resume before ::sysinit:/init
7. pack up /tmp/extract into a new initrd. Again, see the wiki about remastering for details. Something like:
sudo find | sudo cpio -o -H newc | gzip -2 > "/tmp/tinycore_with_hibernate.gz"
8.Copy your patched initrd (tinycore_with_hibernate.gz) to your TC boot directory (wherever that is ...), or make a new ISO if you're doing that. Again, review the remastering howto at the wiki.
edit GRUB menu.lst1. back up your old menu.lst (to menu.lst.old ... perhaps)
2. Add a stanza for your new tinycore_with_hibernate.gz initrd
3. Add kernel arg resume=/dev/[your swap drive]
4. save your new menu.lst
Test it out1. reboot. If needed select your new initrd from the GRUB menu.
2. if you didn't already, you need to load pci-utils, suspend
3. check to see that your changes made it. You should have /etc/suspend.conf, /resume, your /etc/inittab should have changes, and your /etc/init.d/tc-config should be updated ...
4. cross your fingers and run sudo s2disk!
If it goes down fine ... restart your computer and see if resume picks up your image. If not, I suggest wrapping /resume in a script that calls resume then sh (/bin/sh is available at that time). Check to see if resume runs, if your /etc/suspend.conf files reads right, etc ...
Personally, I have:- a small wrapper for the resume binary (so my inittab calls that wrapper - it tells me when it looks for a resume image but doesn't find it
- a short hibernate script/wrapper (it runs some pre-hibernate scripts, then calls s2disk, then runs post-resume scripts after coming back online)
To Do:- Fix the compression thing (it doesn't work)
- Unload tcz extensions before hibernate, then reload on resume (script it)
Hope this helps! Good luck =D