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
ext4 which are writable. In a bootable USB, this reside in the root of the drive.
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.
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
You can mount it using commands like
sudo mount ./filesystem.squashfs /mnt -o loop
Union mounting is a way of combining multiple directories into one that appears to contain their combined contents. Source