Having problems with the Gentoo Handbook? If you're still working your way through it, or just need some info before you start your install, this is the place. All other questions go elsewhere.
# ls /mnt/livecd
bin boot dev etc home lib lib64 media mnt opt proc root run sbin sys tmp usr var
It seems this directory is not mentioned in the handbook, and is not used during the installation? I want to know why there is such a loop device?
P.S. This is my first time gentoo try, and as you might already noticed, English is not my native language. Hope I made myself clear enough, thanks in advance!
man loop wrote:DESCRIPTION
The loop device is a block device that maps its data blocks not to a physical device such as a hard disk or optical disk drive, but to
the blocks of a regular file in a filesystem or to another block device. This can be useful for example to provide a block device for a
filesystem image stored in a file, so that it can be mounted with the mount(8) command. You could do
The liveCD/USB requires its own root filesystem. Its actually a whole root filesystem inside a file.
When you boot the liveCD/USB that file is mounted using a loopback mount as root.
Look at the files and directories on the USB drive when its not in use for installing Gentoo.
That answers the question you asked.
The file is compressed, I think its squashfs, to make it faster to download and more importantly, fit onto a CD.
I'm sure that raises more questions than it actually answers.
On to your next Gentoo learning opportunity. :)
Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Now I understand where this loop device come from: when my computer boot from usb drive, grub(or another program?) mount the image.squashfs to /mnt/livecd.
But I do have some new questions: What is the relation between / and /mnt/livecd? I guess / is based on /mnt/livecd and during the booting process, some program added some change to /mnt/livecd (like /etc/portage/make.conf) and made it the new /. And maybe that's why everytime I boot from usb drive, changes I made would lost. If I understand it right, which program(s) did these jobs?
My explanation above was a bit simplistic.
The root filesystem is a file is both compressed and read only. Even though its on a USB stick, it can't be modified in place.
The file its in is a fixed size. There is no room to add files or even make an existing file bigger.
Files are usually updated by makind the new file under a temporary name, deleting the old file then renaming the new file.
Files on a block storage device always take an integer number of blocks. A block is usually 4kB on disk these days. Thus even a one byte file is allocated a whole 4kB block.
This leads to a lot of unusable space. On average, 2kB per file. With a squashfs filesystem in a file, this unusable space is not stored.
You are correct about the boot loader role.
It passes the root filesystem location to the kernel on the kernel command line, then the kernel performs the mount as it starts up.
I said above that the filesystem in a file is read only. That would not be very satisfactory for performing a Gentoo install. Its correct as far as it goes but it doesn't go far enough.
The make it appear writeable, an overlay filesystem is used. That's a part of RAM used to store changes to the filesystem in a file.
Think of the changes in RAM being a layer over the top of the read only filesystem.
When a file is written, the existing file is copied to RAM (this is called copy on write, CoW for short), and the changes are made in the normal way.
When the changed file is read, the RAM is checked first. I'll gloss over directories, which are just files too but the same thing happens.
As you say, because the changes are never saved to your USB stick, they are lost at reboot.
Keep in mind that all this is intended to work with read only media.
Its possible to add a persistence mode, so the changes can be saved across reboots but that feature is not on the minimal CD.
It involves saving the overlay somewhere that has read/write access and restoring during next boot.
Lots of things make use of the overlay filesystem. Logs are written there, look in /var/log/
Changes you make to /etc go there and many more.
Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Thanks for your comprehensive information! I have used other linux distributions for two years but never think about these questions, seems I need more fundamental OS knowledges