28

September
2012

Persistent changes

When Slax runs from CD, it has no chance to write anything to it. CD/DVD is read only. Thus if you reboot, everything is lost (unless you wrote it to a hard drive). On the other hand, if Slax is started from USB device like Flash Disk, it may be a good idea to save all changes the user made to the system and restore it the next time the OS boots; and with Persistent Changes, this is possible.

There are several ways how to implement persistent changes. One of the methods is loop-mounted filesystem image (a big file). Here the advantage is we can put the file on any filesystem (like FAT) and it will work properly and fast. But the disadvantage is significant - the size of the loop-mounted filesystem must be fully allocated beforehand, even if the user doesn't need so much. FAT filesystem doesn't support 'holes' thus if you create a 1GB empty file for persistent changes on FAT, it will really consume 1GB of disk space.

Fortunately there is POSIXOVL. I'm not the inventor of it, that's Jan Engelhardt, who has been paid to develop it (guess who paid him ;)). Thanks to posixovl, we can 'overmount' any directory, even on FAT filesystem, and make it posix-compatible (so it supports fifos, device files, and so on). This way, the changes to system files (made by the user) are remembered in just the particular affected files, which are copied (after modification) to the posixovl-mounted directory. Any disk space on the USB drive is allocated only when necessary.

I've successfully compiled posixovl statically with uClibc for all my target architectures (x86 32bit and 64bit), and implemented Persistent Changes to Live Kit (and thus to Slax). If you boot such system, you can create and modify all files and directories and your changes will be preserved even if you reboot. You can check /slax/changes/ directory to see how are the files physically stored.

You can test persistent changes (works only when you put Slax to a writable drive such as USB flash drive)

  • Slax 7.0 core with persistent changes - TAR 32bit
  • Slax 7.0 core with persistent changes - TAR 64bit
  • User comments
    Andrea A Johnson 2012-10-12 07:32

    Happen to be trying to find this and learned much more than anticipated in this article. Thanks.

    Ankush Tech Creator 2020-06-07 08:53

    Hi Thomas, thanks for the great OS.
    I just installed slax 9.11 on my 160gb hdd from windows using rufus using a NTFS file system. On booting slax the filemanager shows only 3.8gb storage is available of which 2.9gb is free.
    I wanted to use the entire disk. Please tell if it can be done.
    This is my email : ankush4singh@gmail.com