You are not logged in.

#1 2013-10-21 01:03:20

MetaMan
Member
Registered: 2011-08-08
Posts: 43

[Solved]How Does the Arch ISO use SquashFS?

I have spent almost all day searching around, and thought I should make a post.

From what I understand, the Arch Linux ISO boots using syslinux by somehow mounting the root-image.fs.sfs for the proper architecture as root, and then continuing on as normal. Even though SquashFS is read only, there is some system in place that allows you to "modify" the filesystem by saving the modifications in RAM, which of course are lost at boot.

I have been trying to replicate the process using GRUB. I currently have a flashdrive formatted as FAT32 with MBR GRUB, a kernel, an initrd, and a SquashFS filesystem image of a basic Arch install.

GRUB is configured to set it's root to the FAT32 filesystem of the flashdrive via UUID, and is able to boot the kernel. However, the kernel complains about not having a root, as I have no idea how to tell it where my SquashFS file is. By looking at the syslinux files included with the Arch ISO, the only reference I see to the SquashFS files are the "archisobasedir=arch" and "archisolabel=ARCH_XXXXXX" kernel parameters, or what I assume are kernel parameters.

How do I tell the kernel where my SquashFS file is?
How do I make the SquashFS root rewritable, as it is with the Arch ISO?

Thanks!

Last edited by MetaMan (2013-10-22 12:45:36)


http://localhost/signature.txt
Error 403: Forbidden

Offline

#2 2013-10-21 01:41:24

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [Solved]How Does the Arch ISO use SquashFS?

This is done using dm-snapshot, bootloader does not care. Just use archiso hook to do the same thing.

Linux kernel only mounts a rootfs(a special case of tmpfs), unpacks initramfs (archiso.img) archive, then via script (init)...

0) mount filesystem where squashfs file is present (this is done via archisolabel= boot param)
1) squashFS is attached to a loop device (root-image.fs.sfs)
2) loop device is mounted
3) inside the loop dev, there is a ext4 image (root-image.fs)
4) this image is attached to another loop dev (read-only)
5) a tmpfs is mounted
6) a file of the same size of the root-image.fs is created on tmpfs
7) this file is attached to another loop dev (read-write)
8) a device-mapper snapshot is made with both loop device from steps (4) and (7)
9) dm-snap is mounted for real-root usage.
10) switch root to real-root and enjoy!

Last edited by djgera (2013-10-21 01:44:31)

Offline

#3 2013-10-21 01:56:20

MetaMan
Member
Registered: 2011-08-08
Posts: 43

Re: [Solved]How Does the Arch ISO use SquashFS?

I smiled when I saw your list started with zero. tongue

djgera wrote:

Just use archiso hook to do the same thing.

Is there documentation that goes into the specifics of this process? What do I have to do beyond setting the archisolabel boot parameter?


http://localhost/signature.txt
Error 403: Forbidden

Offline

#4 2013-10-21 03:36:42

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [Solved]How Does the Arch ISO use SquashFS?

haha, 0 was the "edited" step!

No documentation. But steps are easy:

1) dump ext4 fs to a file named my-root.fs
2) compress root-image.fs on a squashfs named my-root.fs.sfs and put on filesystem where you want ${FS}/arch/${ARCH}/
3) create an aitab that references my-root.fs.sfs and place on ${FS}/arch
4) create a initramfs image with "archiso" hook plus needed kernel modules added via hooks or manually, then copy it with vmlinuz to ${FS} at some place.
5) add an entry to your bootloader for this kernel/initramfs and append the boot param "archisolabel=${LABEL_OF_FS}"

enjoy wink

Offline

#5 2013-10-21 15:38:12

MetaMan
Member
Registered: 2011-08-08
Posts: 43

Re: [Solved]How Does the Arch ISO use SquashFS?

I had to install the "archiso" package in order to be able to use the archiso hook with mkinitcpio.

djgera wrote:

6) a file of the same size of the root-image.fs is created on tmpfs

Is this file an actual copy of the image, or is it what's used to store write operations to root? If so, can I set it to not be the size of the image? I plan on my SquashFS file being pretty big, and don't want to run into issues on low-memory computers.

Thanks a lot!


http://localhost/signature.txt
Error 403: Forbidden

Offline

#6 2013-10-21 16:26:29

MetaMan
Member
Registered: 2011-08-08
Posts: 43

Re: [Solved]How Does the Arch ISO use SquashFS?

Also, booting is failing, complaining that vfat is an invalid filesystem type.

Last edited by MetaMan (2013-10-21 19:27:06)


http://localhost/signature.txt
Error 403: Forbidden

Offline

#7 2013-10-21 23:18:13

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [Solved]How Does the Arch ISO use SquashFS?

About the sizeof(root-image.cow) ==sizeof(root-image.fs) does not care, is just a sparse file. Of course if you say to archiso put this file on a filesystem other than tmpfs (cow_device=), to enable persistent mode, and such filesystem does not support sparse files, this is a problem but is solved setting a percent with (cowfile_size=).

boot failed where?

Offline

#8 2013-10-22 00:07:21

MetaMan
Member
Registered: 2011-08-08
Posts: 43

Re: [Solved]How Does the Arch ISO use SquashFS?

The boot fails when it attempts to mount the flashdrive as root (/dev/disk/by-label/yadayadayada) with the error "Error: vfat is an invalid filesystem type", or something along those lines. Fat32 should work, right?

Last edited by MetaMan (2013-10-22 00:07:50)


http://localhost/signature.txt
Error 403: Forbidden

Offline

#9 2013-10-22 00:56:21

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [Solved]How Does the Arch ISO use SquashFS?

Oh, this is because you did not added vfat module to the initramfs. I guess you have enabled autodetect hook, this is wrong. Minimal mkinitcpio.conf hooks should be: "base udev archiso block filesystems".

Offline

#10 2013-10-22 01:07:00

MetaMan
Member
Registered: 2011-08-08
Posts: 43

Re: [Solved]How Does the Arch ISO use SquashFS?

Thank you, removing the autodetect hook fixed the issue and results in a booting system.

djgera wrote:

About the sizeof(root-image.cow) ==sizeof(root-image.fs) does not care, is just a sparse file. Of course if you say to archiso put this file on a filesystem other than tmpfs (cow_device=), to enable persistent mode, and such filesystem does not support sparse files, this is a problem but is solved setting a percent with (cowfile_size=).

Hmmm... I'm having a little trouble understanding that, I'll try asking a more direct question.

Is it an issue if my squashfs image or the ext2 image inside of it are bigger than the amount of RAM available on the system I am booting my flashdrive on?

Last edited by MetaMan (2013-10-22 02:34:56)


http://localhost/signature.txt
Error 403: Forbidden

Offline

#11 2013-10-22 07:04:50

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [Solved]How Does the Arch ISO use SquashFS?

Nice, you are welcome smile

No, not an issue. The only issue comes when you perform many many writes (for example installing packages).
You can see the actual usage of such file with du -h /run/archiso/cowspace/persistent_${FS_LABEL}/${ARCH}/root-image.cow (on tmpfs by default)

Last edited by djgera (2013-10-22 07:05:04)

Offline

#12 2013-10-22 12:45:05

MetaMan
Member
Registered: 2011-08-08
Posts: 43

Re: [Solved]How Does the Arch ISO use SquashFS?

Thanks a lot. I'll mark this as solved, and hope this helps someone else in the future.


http://localhost/signature.txt
Error 403: Forbidden

Offline

Board footer

Powered by FluxBB