linuxdebianraspberry-piinitrdsquashfs

Mount Squashfs as Root in initramfs Raspbian


I'm currently trying to make my raspbian boot from a squashFS image through initramfs. The squashfs image is on file system /dev/mmcblk0p1, so I mount this prior to mounting the Image.

Unfortunately I'm stuck at mounting the SquashFS Image file.

I tried mounting through

mount -o loop

but I always get

mounting /dev/loop0 on /mnt/root failed: No such device

So I tried to mount it through loop manually. The problem is, that mounting the /dev/loop0 fails with the same Error as above.

This is my init so far:

#!/bin/busybox sh
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
#create loop devices
mknod /dev/loop0 b 7 0
mkdir /mnt/root
# Mount the boot partition
mount -o ro /dev/mmcblk0p1 /mnt/boot
sleep 5
# Mount the root FS with losetup
echo "Mounting with losetup"
losetup /dev/loop0 /mnt/boot/SYSTEM
mount /dev/loop0 /mnt/root -t squashfs
echo "Done"
#mount -o ro,loop -t squashfs /mnt/boot/SYSTEM /mnt/root

# Use Fallback mounting failed
if [ ! -e /mnt/root/home ]
then
echo "MOUNTING SDA1"
mount /dev/sda1 /mnt/root -t ext4
fi

# Clean up.
umount /proc
umount /sys
umount /mnt/boot

# Boot the real thing.
exec switch_root /mnt/root /sbin/init

Checking

losetup /dev/loop0

tells me, that the squashfs Image has been attached to loop0.

Does somebody know where to start?


Solution

  • I came across your question because I ran into the same thing today while building my own initramfs. I did some more digging and found this:

    http://www.silas.net.br/doc.notes/unix/linux/busybox-troubleshooting.html

    Then it dawned on me that I hadn't built squashfs into the kernel or loaded the module. After I did that, everything worked!

    In case you haven't, make sure your kernel supports squashfs.