Linux – Is it possible to run any distro from RAM from within an .iso saved on an NTFS file system

isolinuxlinux-kernelramsyslinux

Running entirely from RAM been done on various distros such as Slax, DamnSmallLinux, and newer Ubuntu versions, and since I have 8GB it seems reasonable that I could run many distros entirely from RAM (as long as I select one that has the ability).

I would like to do this with OpenELEC (or any distro), and with a further complication: I'm a .NET developer, work and primarily use Windows, which means NTFS and FAT32 are my preferred file systems. Until the day comes if and when Windows can natively read/write ext partitions, this won't change. Ext2fck won't even install in Windows 8, so there's no convincing me of the 'merits' of having drives and partitions in an unreadable format to my daily operation.

There's also things like syslinux, vmlinuz, extlinux and the like that can load .iso files into RAM and effectively bootload them. To add icing on the cake, Windows' bootloader will allow me to add these as options in the native Windows boot menu, which I have done for UBCD 5.11, and will even work for virtual file systems like .vhd, etc.

So, here's my dream:

I want to combine all three into one. I want to take an installed ext2/ext3/ext4 partition, in this case an install of OpenELEC, compress it into an .iso, and create an entry in my boot menu that will either do this directly, or pass it to syslinux or the like that will do the following:

Extract the .iso completely into RAM as an ext2/3/4 partition and boot into that OS in RAM. I'll then mount my NTFS hard drive for the /STORAGE portion of the OpenELEC install with ntfs-3g.

Then, as a bonus, on exit I'd have the system recompress itself to an .iso, and if successful replace the initial .iso thereby persisting my changes across boots (provided the shutdown was successful). It wouldn't have to copy itself from memory, either: it could copy any files/changes it wanted to track (if some were not available) back onto the drive it booted from, if present, then compress that back into an .iso.

Slax, DSL and Ubuntu can boot to RAM and persist changes, so I know it's possible if your OS supports it. I'm wondering if this can be made into a 'works for any distro you want'. Slax saves your changes in an ext directory /slax/changes if it's on an ext partition, or as changes.dat otherwise (for NTFS/FAT32). This solution could work too, I suppose, but would probably require more interaction with the hosted OS to coordinate this than using the .iso.

So, how close can I get?

Are there easy solutions for this already out there? Would I have to write a custom 'SYSLINUX'/'ISOLINUX'/'EXTLINUX'/'VMLINUX? What would be required to make this happen, and if it's possible already how do I get started?

Best Answer

There's an EXE installer for Puppy Linux which boots from an .iso on FAT32, NTFS or Linux filesystems (i.e. ext2/ext3/ext4, xfs, etc.) using syslinux and runs in RAM using unionfs/aufs with full access to persistent storage (disk, SD, flashdrive, etc.).

Other ISOs can be mounted, from commandline or script of course, as well as by clicking on them in the included ROX-Filer file manager. One convenient use of this is to selectively access or restore files from an old version instead of having to roll back everything.

The original Puppy Linux distribution ISO, which itself is an usually an ext3/4 filesystem, is kept on the lowest layer of the aufs stack. Changes are recorded in the topmost layer and flushed to disk periodically (configurable) to a "savefile". On boot, the original ISO is loaded to RAM and mounted read-only, then the savefile is loaded and mounted read-only to overlay it and an empty read-write layer mounted for any new changes. To preserve a history of changes, just setup automatic or manual coping of the savefile ISO to an archival directory.

The O/S "layering" of unionfs/aufs along with multi-mounting of filesystems are the core technologies at work here, so if Puppy Linux doesn't work for you, look for other distros using them.

There are quite a number of installation options available for Puppy Linux including a Windows EXE Installer which is a separate package that sets up the Windows boot loader for dual-boot.

Related Question