Snapshots of System State in Linux? 8
Anonymous Coward asks: "VMware provides the capability to save the state of a VMware session to a file and to later reload it to resume from where was left off, as if the (virtual) machine never was turned off. Is there a way to do this on a real Linux machine, i.e., capturing the state of the machine (the whole memory space, CPU registers, etc.) to a file and restoring it later (assuming the same hardware)? This is useful for, say, kernel debugging or fast boot (i.e., saving the machine state at some point after the kernel has been initialized and just resuming from that point on in case of reboot)." Most laptops do exactly this when they suspend to disk, however most of that is done via the laptops firmware.
Software Suspend (Score:1)
In theory yes (Score:5)
In theory this can be do. It isn't that hard either, just walk through all the data structures in the kernel and write them to disk. For most memory, just tell the swaper to swap that task out and all your tasks have their registers saved automaticly.
Now for the problem: when saving state you need to save more then just the CPU. Getting the simple case to work is probably very easy. However every hardware part needs to be re-initialized to the same state it was in before. Somethings won't care, (keyboard likely) others are easy to work around. (just act like a virtual console switch). Others can be very hard to (think of scsi drivers where some program is reading from a file)
Don't forget that you can't save the state of your disk driver while you are writing that state out, unless you are careful to avoid half written registers.
This is an interesting and doable project. If you want it do it. Remember this is was linux is about: scratching your own itch and then sharing with others. If you get this working great, if not you will have least learned.
Just use VMWare! (Score:2)
Linux on your host. VMWare runs on Linux. Linux runs inside of VMWare on a Linux host.
I didn't say it'd be elegant but it sure works...
Yes. (Score:5)
Software Suspend for Linux 2.2.x [sch.bme.hu]
It will save the state of your machine to the swap space and on bootup recognize the saved state and restore it. No BIOS or fimware junk nessacary
Re:win2k can do it well... it is possible (Score:1)
its allright, i wouldn't want too much karma, cause then i'd have to be a whore
win2k can do it well... it is possible (Score:4)
this combined with what happens on the display would lead me to believe that win2k/xp does the hibernation in software, and win98 either uses the firmware, or really crappy software.
you would probably need to have an interface to re-initialize the network cards, because there is a high probability of being on a different network when you resume. this might be a compelling reason to integrate dhcp into the kernel (bootp and arpd are in there allready) or it might not be. you would probably also want to flush everything in the write cache to disk, and drop your read caches into the bit bucket to reduce the size of the memory you actually have to save.
as for exactly how it would work, i'm not exactly sure, but i strongly believe it is possible. somebody suggested using swap space for that, but that wouldn't work if you didn't have enough free space for everything in ram. a dedicated partition at least the size of your physical ram would probably be the best solution considering ease of programming, and typical ratio of memory to diskspace.
if this hasn't been done well by the time i get to senior year in college, this would be a great senior design project for me i think.
Not without special firmware... (Score:5)
Re:win2k can do it well... it is possible (Score:4)
- preparing to standby (similar, text: hibernate)
- stopping to schedule time to tasks
- sending kind of SIGSTANDBY to any driver
-> the driver saves state
- switching to sane environment (640x480x4)
- saving whole memory uncompressed to disk
- powering off
Reload:
- check for valid hibernation file
- load whole memory minus around 1-4 pages from
file, leaving out area in 1st MB for load-task
(is always reserved by kernel)
- regetting CPU state (LOADALL???)
- sending kind of SIGREINIT to any driver (start
with keyboard, vga, etc.)
-> driver gets old state and re-inits any card
* except ESS1371
which btw neither has ACPI nor APM !!)
* but ESS1869 (laptop) works
* even PCMCIA and NE2000(ISA w/ jumper) network
- display->refresh();
- start to schedule tasks, BUT ask for login
(console unlock) first, just as my icewm does
on Ctrl-Alt-Del "Lock Workstation" (hey, win2k
contains parts of icewm...)
--