Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Technology

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.
This discussion has been archived. No new comments can be posted.

Snapshots of System State in Linux?

Comments Filter:
  • by Anonymous Coward
    I was thinking of this too, save the whole state to the hard drive so Linux can boot a whole OS/GUI in seconds etc. Anyone remember ICEpic on the Commodore 64? Same concept. If the unused areas of memory were cleared to 0 (on free or as a background task, as planned in some "security" updates"), just dump the whole memory image through a fast compressor to the hard disk. On bootup, load the whole image back etc. *HARD* part is the devices (peripherals), as they will have to be fully initialised again (for cold boot etc). It would be nice not to have to uninstall modules and the insmod them again, rather just send a Kernel "reinit" signal. At any rate, very possible, and very very nice - get to it chaps! :-)
  • by bluGill ( 862 ) on Friday April 27, 2001 @11:14AM (#261640)

    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.

  • 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...

  • by The Iconoclast ( 24795 ) on Friday April 27, 2001 @10:56AM (#261642)
    I found this about a year ago, and couldn't get it to work, but it seems a lot better now.

    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

  • well if i hadn't double posted it might have helped too :)

    its allright, i wouldn't want too much karma, cause then i'd have to be a whore :)
  • On my laptop, windows 2000 (and xp) can 'hibernate' to a file and on boot resume where it left off, in theory it can do it in win98 as well, but the suspend/hibernate/resume doesn't seem to work properly in win98

    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.
  • by krismon ( 205376 ) on Friday April 27, 2001 @10:07AM (#261645)
    I don't think it can be done without special firmware, or something in the BIOS. VMware is doing exactly what laptops are doing, VMware writes to a file in the host, and newer laptops write to a special partition. It sucks.. but possibly the only thing you can do is to put laptop brains on your desktop/server board... which may or may not be that easy to do, it certainly may be easier to convince one of the smaller board manufacturers to do this.
  • by mirabilos ( 219607 ) on Saturday April 28, 2001 @11:51AM (#261646) Homepage
    Win98 I don't know, but for NT5 it works by:
    - 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 :-( (on my dual-PPro-200MMX
    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...)


    --

Real Programmers don't eat quiche. They eat Twinkies and Szechwan food.

Working...