8

Recently, I needed to test various kernel boot-options with a live system and had to install a program to check system information on every boot (I did not have a USB drive available and the CD was the more reliable choice at that moment).

After a handful of installations, I began to wonder, where the program is actually "saved", since the CD does not have a persistent area and it's also possible to create USB drives without one. Also, it's possible to download files or make screenshots with a non-persistent live system and temporarily save them in the user directories.

Where are these files actually saved? Are they loaded into the RAM, so the maximum available memory for the live system is actually the RAM capacity of the machine? Are installed programs stored in the CPU cache or somewhere else entirely? Or is that information possibly written on empty space of the CD medium? It obviously can't be unallocated hard drive space, since live systems also work with fully encrypted or even completely without hard drives installed.

2 Answers 2

11

The live system that comes with the Ubuntu ISO is an Ubuntu installation in a compressed file called filesystem.squashfs. This file has a filesystem of SquashFS1 which is comparable to the ISO filesystem of CDs & DVDs, which can be mounted and used.2

This file is in the /casper/ directory of the CD. You can even mount this file same way you can mount ISO files.

This file gets mounted and loaded into memory during boot to be used as a live system. But the full file doesn't get loaded at once, but only the required portions/programs on-demand.

A Live System can create/change files of the media with the help of a Persistent File. The persistent file used in Ubuntu is named casper-rw and contain filesystem like ext3 or ext4 which are writable. In a bootable USB, this reside in the root of the drive.

This casper-rw persistence file is union mounted as a overlay filesystem, which means both the read-only filesystem.squashfs and read/writable casper-rw are mounted on /. Any files that are changed or created are saved in this writable filesystem of casper-rw. Thus effectively creating the illusion that the Live CD is writable, where actually they aren't.

So, answering your questions -

Where are these files actually saved?

Answer given above.

Are they loaded into the RAM, so the maximum available memory for the live system is actually the RAM capacity of the machine?

I suppose, by memory you are referring the Space. Your question is "So the maximum available space for the live system is acutally the RAM capacity of the machine"?

No. Maximum available Storage for a Live System is the size of the Persistent File (If there is any) + Swap Space (If they exists already) + RAM (It it needs to be used as Storage until reboot)

Are installed programs stored in the CPU cache or somewhere else entirely?

If you install program in Live system without a Persistent File, those will be in your Memory. If you Reboot, all will be lost. However, if you're using casper-rw persistent file, those will be saved in that file and will be available after next reboot (Provided that you didn't delete that file)

Or is that information possibly written on empty space of the CD medium?

No, It doesn't write on the CD Medium. As explained in the previous answer.

Hope you get your answers.


Notes:

  1. SquashFS - It is a read-only file system that lets you compress whole file systems or single directories, write them to other devices/partitions or to ordinary files, and then mount them directly (if a device) or using a loopback device (if it is a file). Source

  2. You can mount it using commands like sudo mount ./filesystem.squashfs /mnt -o loop

  3. Union mounting is a way of combining multiple directories into one that appears to contain their combined contents. Source

7
  • Casper is a friendly little ghost of a filesystem.
    – cat
    Aug 21, 2016 at 4:31
  • 1
    Thank you for your detailed explanation. I haven't seen that you added answers to the individual questions in your response. That explains it fairly well. However, I did not fully understand the section on casper -rw, especially the meaning of "Thus effectively creating the illusion that the Live CD is writable, where actually they aren't. ", but I guess I just have to read up on that. You answered the question though, since a persistent file is not available on the CD medium and a swap-file can logically only exist in the RAM, that's where the information was stored in my case. Aug 23, 2016 at 10:12
  • 1
    I'm explaining Illusion part. The Read/Only files are mounted on /. You see them like /usr/, /var/, /home etc. in Live CD, you can't create, change files that persists. Yes, you can create, change, but that will go away as they are really in RAM. This is same in Live USB without persistence file or casper-rw file
    – Anwar
    Aug 23, 2016 at 10:20
  • 1
    But, In Live USB with persistence file this too is mounted on /. So, when you create a file in your /home directory, that file actually stored on the casper-rw file, but You think, that is the content of the CD. If you open casper-rw, you'll get all the changed/updated files there in respective location. Since this is getting mounted over the original read-only one, thus creating the Illusion
    – Anwar
    Aug 23, 2016 at 10:20
  • 2
    Another thing is, Your saying "A swap-file can logically only exists in the RAM" is not correct. Swap is a partition or a file stored in Disk and get mounted to be used while booting. The beautiful thing is, if your disk has already a Swap partition, your live ubuntu will recognize it and use it. But yes, it is volatile and cleaned when you reboot @Prototype700
    – Anwar
    Aug 23, 2016 at 10:24
10

It says non-persistent. So they do not "persist" (continue to exist) between reboots. What happens is that a part of the RAM is used as a RAM disk. Essentially, a part of your RAM is used to simulate a disk. That's all there is to, really. That's why you can create files on your /home/ubuntu during a LiveCD session. They just won't survive (=persist) after reboot.

I don't have a LiveCD handy, but try typing df -h in the terminal next time and look for the / mount point. Look at the device. It will most likely be something like tmpfs. (This one liner should give you the line you're interested in: df -h | grep \/$ )

Some reading about RAM disks.

1
  • 3
    These days, it's likely to be aufs or some other overlay filesystem -- they're easier to set up than a classic tmpfs configuration.
    – Mark
    Aug 21, 2016 at 2:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .