Skip to contentSkip to conversation

buildroot with SquashFS root file system

Buildroot Emmanuel BOUAZIZ 5 participants 13 messages Dec 6, 2011 – Dec 14, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to run buildroot 2011.11 on an atom based board, booting via PXE.

I've selected the SquashFS 4.x root filesystem (xz compressed), bzImage as the Kernel binary format, and syslinux/pxelinux as the bootloader.
In the system configuration, I checked "remount root filesystem read-write during boot"

In the kernel configuration, I checked Initial RAM filesystem and RAM disk support+XZ, and SquashFS/XZ filesystem support.

On the PXE server, I put these kernel parameters: append vga=0x305 fbcon=scrollback:4096k initrd=rootfs.squashfs

Here is what I get during the boot sequence:

(...)
RAMDISK: squashfs filesystem found at block 0
RAMDISK: Loading 14133KiB [1 disk] into ram disk.../ usb 1-7: new high speed USB device number 3 using ehci_hcd
VFS: Mounted root (squashfs filesystem) readonly on device 1:0 usb 2-2: new full speed USB device number 2 using uhci_hcd can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory Starting logging: OK
Starting mdev...
mdev: /sys/class: No such file or directory
Starting network...
hub 2-2:1.0: USB found
hub 2-2:1.0: 3 ports detected
ifup: can't open '/var/run/ifstate': Read-only file system (...)

I get the exact same result if I try to use a cramfs instead of a SquashFS.

Oddly enough, it works perfectly with a cpio root filesystem, or when I integrate the root filesystem as an initramfs in the kernel image.

I probably missed an important item, but can't figure which. Any help appreciated.

Thanks,

Signature · 1 line
Emmanuel
#1 lore raw
Quoted 36 lines · Emmanuel BOUAZIZ

Hi,

I'm trying to run buildroot 2011.11 on an atom based board, booting via PXE.

I've selected the SquashFS 4.x root filesystem (xz compressed), bzImage as the Kernel binary format, and syslinux/pxelinux as the bootloader.
In the system configuration, I checked "remount root filesystem read-write during boot"

In the kernel configuration, I checked Initial RAM filesystem and RAM disk support+XZ, and SquashFS/XZ filesystem support.

On the PXE server, I put these kernel parameters: append vga=0x305 fbcon=scrollback:4096k initrd=rootfs.squashfs

Here is what I get during the boot sequence:

(...)
RAMDISK: squashfs filesystem found at block 0
RAMDISK: Loading 14133KiB [1 disk] into ram disk.../ usb 1-7: new high speed USB device number 3 using ehci_hcd
VFS: Mounted root (squashfs filesystem) readonly on device 1:0 usb 2-2: new full speed USB device number 2 using uhci_hcd can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory can't open /dev/null: No such file or directory Starting logging: OK
Starting mdev...
mdev: /sys/class: No such file or directory
Starting network...
hub 2-2:1.0: USB found
hub 2-2:1.0: 3 ports detected
ifup: can't open '/var/run/ifstate': Read-only file system (...)

Quoted 8 lines

I get the exact same result if I try to use a cramfs instead of a SquashFS.

Oddly enough, it works perfectly with a cpio root filesystem, or when I integrate the root filesystem as an initramfs in the kernel image.

I probably missed an important item, but can't figure which. Any help appreciated.

SquashFS is a read-only file system.

So which of the "device support" options did you choose? You'll need one that puts devices in something writable, like tmpfs.

Mike

Quoted 2 lines

Thanks,

#2 lore raw
Quoted 5 lines · Michael S. Zick

SquashFS is a read-only file system.

So which of the "device support" options did you choose? You'll need one that puts devices in something writable, like tmpfs.

Hi Michael,
thank you for your answer.

I'm not sure what you mean by "device support" options.
I enabled mdev and in the kernel's generic driver options, I checked "Maintain a devtmpfs filesystem to mount at /dev" and "Automount devtmpfs at /dev after the kernel mounted the rootfs"

regards,

Signature · 1 line
Emmanuel
#3 lore raw
Quoted 4 lines · Emmanuel BOUAZIZ
Quoted 2 lines · Michael S. Zick

SquashFS is a read-only file system.

Quoted 8 lines
Quoted 3 lines

So which of the "device support" options did you choose? You'll need one that puts devices in something writable, like tmpfs.

Hi Michael,
thank you for your answer.

I'm not sure what you mean by "device support" options.

That is what I meant. Just didn't have the right name in mind.

Quoted 4 lines

I enabled mdev and in the kernel's generic driver options, I checked "Maintain a devtmpfs filesystem to mount at /dev" and "Automount devtmpfs at /dev after the kernel mounted the rootfs"

My next guess -

Was the kernel built by Buildroot or did you build it otherwise? If the kernel wasn't built by Buildroot, it may not have the required options set for tmpfs, devtmpfs, automount devtmpfs.

If built outside of Buildroot, what version kernel?

The usual thing for troubleshooting an initramFS system is:
rdinit=/bin/sh
(or whatever path/name you shell program is)

You could try that, but I expect if it can't open /dev/null it will not be able to open /dev/console either. ;-)

Mike

Quoted 2 lines

regards,

#9 lore raw
In reply to Emmanuel BOUAZIZ
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Emmanuel" == Emmanuel BOUAZIZ <[email protected]> writes:

Emmanuel> Hi,

Emmanuel> I'm trying to run buildroot 2011.11 on an atom based board, Emmanuel> booting via PXE.

Emmanuel> I've selected the SquashFS 4.x root filesystem (xz Emmanuel> compressed), bzImage as the Kernel binary format, and Emmanuel> syslinux/pxelinux as the bootloader.

Emmanuel> In the system configuration, I checked "remount root Emmanuel> filesystem read-write during boot"

That doesn't make much sense for a readonly file system like squashfs.

Emmanuel> In the kernel configuration, I checked Initial RAM filesystem Emmanuel> and RAM disk support+XZ, and SquashFS/XZ filesystem support.

Emmanuel> On the PXE server, I put these kernel parameters: append Emmanuel> vga=0x305 fbcon=scrollback:4096k initrd=rootfs.squashfs

An initramfs would be a better option than initrd, but OK. Did you build the kernel with buildroot or manually?

Emmanuel> Here is what I get during the boot sequence:

Emmanuel> (...)
Emmanuel> RAMDISK: squashfs filesystem found at block 0 Emmanuel> RAMDISK: Loading 14133KiB [1 disk] into ram disk.../ Emmanuel> usb 1-7: new high speed USB device number 3 using ehci_hcd Emmanuel> VFS: Mounted root (squashfs filesystem) readonly on device 1:0 Emmanuel> usb 2-2: new full speed USB device number 2 using uhci_hcd Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory

Do you have CONFIG_DEVTMPFS enabled in your kernel? From a quick look at the kernel sources (init/do_mounts_initrd.c) I see that the kernel doesn't mount devtmpfs automatically when an initrd is used, so you'll need to add a wrapper script as /linuxrc which mounts it and execs /sbin/init, similar to how we do it for initramfs (fs/cpio/init):

# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
exec /sbin/init $*
Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw
In reply to Michael S. Zick
Quoted 8 lines · Michael S. Zick

My next guess -

Was the kernel built by Buildroot or did you build it otherwise? If the kernel wasn't built by Buildroot, it may not have the required options set for tmpfs, devtmpfs, automount devtmpfs.

If built outside of Buildroot, what version kernel?

I build the kernel using buildroot. It's version 3.1.4

Quoted 4 lines · Peter Korsgaard

An initramfs would be a better option than initrd, but OK. Did you build the kernel with buildroot or manually?

I'll probably use the initramfs since it already works and you say it's a better option. But I'd like to make the SquashFS work now that I've started, it's frustrating not to succeed :p

I build the kernel with buildroot, it'version 3.1.4

Quoted 22 lines

Emmanuel> Here is what I get during the boot sequence:

Emmanuel> (...)
Emmanuel> RAMDISK: squashfs filesystem found at block 0 Emmanuel> RAMDISK: Loading 14133KiB [1 disk] into ram disk.../ Emmanuel> usb 1-7: new high speed USB device number 3 using ehci_hcd Emmanuel> VFS: Mounted root (squashfs filesystem) readonly on device 1:0 Emmanuel> usb 2-2: new full speed USB device number 2 using uhci_hcd Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory Emmanuel> can't open /dev/null: No such file or directory

Do you have CONFIG_DEVTMPFS enabled in your kernel? From a quick look at the kernel sources (init/do_mounts_initrd.c) I see that the kernel doesn't mount devtmpfs automatically when an initrd is used, so you'll need to add a wrapper script as /linuxrc which mounts it and execs /sbin/init, similar to how we do it for initramfs (fs/cpio/init):

Quoted 7 lines
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
exec /sbin/init $*

Yes it's enabled. I've put that same mechanism in squashfs (modified fs/squashfs/squashfs.mk and added fs/squashfs/init) and added init=/init in kernel parameters but the /init script is not run.

I took a look at the possible kernel parameters and added root=/dev/ram0 rw to the kernel parameters. Now I get a "devtmpfs: mounted" before the /init script is run, and another saying "mount: mounting devtmpfs on /dev
failed: Device or resource busy" when the /init script is run :D

So I removed the /init script, the "can't open /dev/null" problem is gone.

The only remaining problem is that the whole filesystem is read-only despite the 'rw' including /var and /tmp.

regards,

Signature · 1 line
Emmanuel
#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Emmanuel" == Emmanuel BOUAZIZ <[email protected]> writes:

Hi,

Emmanuel> Yes it's enabled. I've put that same mechanism in squashfs Emmanuel> (modified fs/squashfs/squashfs.mk and added fs/squashfs/init) Emmanuel> and added init=/init in kernel parameters but the /init Emmanuel> script is not run.

Initrd uses /linuxrc, not /init.

Emmanuel> The only remaining problem is that the whole filesystem is Emmanuel> read-only despite the 'rw' including /var and /tmp.

That's because you're using squashfs. Squashfs is a readonly filesystem. Either move to initramfs or use ext2 in your initrd.

/tmp should be a tmpfs though (check /etc/fstab), and most of /var symlinks to /tmp/.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw
Quoted 10 lines · Peter Korsgaard

Emmanuel> The only remaining problem is that the whole filesystem is Emmanuel> read-only despite the 'rw' including /var and /tmp.

That's because you're using squashfs. Squashfs is a readonly filesystem. Either move to initramfs or use ext2 in your initrd.

/tmp should be a tmpfs though (check /etc/fstab), and most of /var symlinks to /tmp/.

Oh that's rigth, it's writable, I mixed with another directory that I wanted to write to (/usr/local). I mounted it as tmpfs too and everything's fine now. Thanks a lot for your help :)

Well, I'll switch back to initramfs anyway since it's less tricky.

regards,

Signature · 1 line
Emmanuel
#7 lore raw
Quoted 10 lines · Emmanuel BOUAZIZ
Quoted 6 lines · Peter Korsgaard

Emmanuel> The only remaining problem is that the whole filesystem is Emmanuel> read-only despite the 'rw' including /var and /tmp.

That's because you're using squashfs. Squashfs is a readonly filesystem. Either move to initramfs or use ext2 in your initrd.

Quoted 9 lines
Quoted 3 lines

/tmp should be a tmpfs though (check /etc/fstab), and most of /var symlinks to /tmp/.

Oh that's rigth, it's writable, I mixed with another directory that I wanted to write to (/usr/local). I mounted it as tmpfs too and everything's fine now. Thanks a lot for your help :)

Well, I'll switch back to initramfs anyway since it's less tricky.

You do not have to put your entire run-time file system in the initramfs, only what you need to establish the full run-time file system. I.E: Your full run-time file system can remain as a squashfs file. You just have to provide the "init" scripting to get it loaded and mounted while in the early user space of the initramfs.

See: EarlyUserSpace in the kernel documentation tree; and maybe look at how some "LiveCD" systems handle the setup.

Mike

Quoted 1 line

regards,

#8 lore raw
Quoted 8 lines · Michael S. Zick

You do not have to put your entire run-time file system in the initramfs, only what you need to establish the full run-time file system. I.E: Your full run-time file system can remain as a squashfs file. You just have to provide the "init" scripting to get it loaded and mounted while in the early user space of the initramfs.

See: EarlyUserSpace in the kernel documentation tree; and maybe look at how some "LiveCD" systems handle the setup.

I'll take a look at that, thank you!

Signature · 1 line
Emmanuel
#10 lore raw
In reply to Emmanuel BOUAZIZ
Quoted 1 line · On Tuesday 06 December 2011 16:20:35 Emmanuel BOUAZIZ wrote:

On the PXE server, I put these kernel parameters: append vga=0x305 fbcon=scrollback:4096k initrd=rootfs.squashfs

Hm, my assumption that you would only use an initramfs with a
cpio archive was clearly wrong. So perhaps we should execute the ROOTFS_CPIO_ADD_INIT hook unconditionally for all filesystems?

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  31BB CF53 8660 6F88 345D  54CC A836 5879 20D7 CF43
#11 lore raw

Le Tue, 13 Dec 2011 18:18:53 +0100,
Arnout Vandecappelle <[email protected]> a ?crit :

Quoted 3 lines

Hm, my assumption that you would only use an initramfs with a
cpio archive was clearly wrong. So perhaps we should execute the ROOTFS_CPIO_ADD_INIT hook unconditionally for all filesystems?

I'd prefer not to. I don't want this wrapper script in all filesystems just to solve the initramfs problem, because it is useless for the filesystem is not used as an initramfs filesystem.

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#12 lore raw
In reply to Arnout Vandecappelle
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 1 line · Arnout> On Tuesday 06 December 2011 16:20:35 Emmanuel BOUAZIZ wrote:
Quoted 1 line

On the PXE server, I put these kernel parameters: append vga=0x305 fbcon=scrollback:4096k initrd=rootfs.squashfs

Arnout> Hm, my assumption that you would only use an initramfs with a Arnout> cpio archive was clearly wrong. So perhaps we should execute the Arnout> ROOTFS_CPIO_ADD_INIT hook unconditionally for all filesystems?

This is initrd, not initramfs (which isn't really recommended anymore). As far as I can see, devtmpfs does get mounted for initrd's (init/do_mounts.c:prepare_namespace()).

Signature · 1 line
Bye, Peter Korsgaard