Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do I preserve changes I make to files when running an operating system that is booted - using GRUB2 - from a file that contains a file system.

I managed to get GRUB2 to boot an image file that resides on a HDD. So far so good, very useful for booting into FreeDOS for various non-Linux utilites. What I wish is that if I create a file - or change it - in this running OS, that it is written back to the image file, so that the next time I boot this image file, I can pick up where I left off, instead of starting over again with the same image that was booted the first time.

share|improve this question
add comment

1 Answer

Memdisk (that's what you're using, right?) works by replacing the BIOS disk driver by its own code which changes the in-memory copy instead of reaching down to the disk. The bootloader (Syslinux, Grub or whatever else you're using) does the work of loading the image from disk, and it does not remain in memory once Memdisk has started.

In order to get the changes back onto the disk, you would need to add disk and filesystem support to Memdisk. That's not impossible in principle, but it's a significant development effort, and I'm not aware of anyone working on it.

What you can do is make a small FAT partition on your disk, copy your disk image onto it before rebooting, and copy the disk image back afterwards if you want it to persist.

share|improve this answer
    
Interesting suggestion about copying memory content to the disk. Would you know how to achieve this in practice? I have some ideas about how this could be accomplished if the live OS running is Linux, but how to write the in-memory file system to a file on the disk using Windows, I have no clue how to achieve. –  runeks Nov 14 '11 at 13:05
    
@runeks As I said, it's a significant development effort. Memdisk is not running under Linux or Windows, it's running directly on the machine — it's its own special-purpose operating system. –  Gilles Nov 14 '11 at 16:24
    
I see. I was thinking of doing it from the OS though. For example in Linux, mounting a hard drive partition, creating a new file system in a file on this partition, mounting this file system, and copying the content of the root file system of the running OS to this file. Then booting from this file the next time. It could be automated in some script to be done on shut down. I guess I just need to try it out to see if it works, would be interesting if the same could be done for Windows somehow. –  runeks Nov 16 '11 at 11:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.