16

The rootfs is a squashfs image and my bootloader is loading it into some address in SDRAM. What parameters do I need to pass to the kernel so It can mount the rootfs from there? Squashfs support is built-in and it already works with

root=/dev/mtdblock2 rootfstype=squashfs  

for booting from the flash.

EDIT: This is a MIPS based embedded device, using a custom bootloader. Normally, the bootloader extracts the compressed kernel from the flash into the SDRAM, and then kernel mounts /dev/mtdblock2 as the rootfs. I am trying to improve the bootloader so it can download an image to its RAM and boot without writing to the flash.

I cannot figure out how to make Linux mount a filesystem image in the RAM as the rootfs.

  • Please describe better, what are you trying to achieve, if you already know squashfs works. How do you you know that it works? What happens? And most importantly, what doesn't work the way you want? – rozcietrzewiacz Dec 21 '11 at 10:17
  • 1
    Also, what bootloader does the device use? – rozcietrzewiacz Dec 21 '11 at 10:20
  • I think if you use memdisk (from SYSLINUX) as kernel, it loads the whole image in memory and then boots from it – golimar Apr 12 '12 at 8:03
10

I would use an initramfs. (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt)

Many Linux distributions use an initramfs (not to be confused with an initrd, they are different) during the boot process, mostly to be able to start userspace programs very early in the boot process. However, you can use it for whatever you want.

The benefit of an initramfs over an initrd is that an initramfs uses a tmpfs filesystem while an initrd uses a ram block device. The key difference here is that for an initrd, you must preallocate all the space for the filesystem, even if you're not going to use all that space. So if you don't use the filesystem space, you waste ram, which on an embedded device, is often a scarce resource. Tmpfs is a filesystem which runs out of ram, but only uses as much ram as is currently in use on the filesystem. So if you delete a file from a tmpfs, that ram is immediately freed up.

Now normally an initramfs is temporary, only used to run some programs extremely early in the boot process. After those programs run, control is turned over to the real filesystem running on a physical disk. However, you do not have to do that. There is nothing stopping you from running out of the initramfs indefinitely.

  • So I've actually been trying to setup a system that runs "out of the initramfs indefinitely". The system is up for the most part, but I've had some problems - I'm wondering if you might be able to shed some light? Question posted here – dtmland Jul 1 '15 at 17:18
0

Are the rd_start and rd_size options sufficient?

It seems the ARM port may have a syntax for the initrd option:

root=/dev/ram0 rw initrd=0x87000000,8M 
0

I use the phram driver for this purpose: it emulates an MTD device using physical memory, meaning you can use exactly the same rootfs image for testing/development that you are later going to burn to the real flash. The necesary magic on the kernel command line would be something like

phram.phram=rootfs,0x100000,9Mi root=/dev/mtdblock0 memmap=9M\$100000

Note that you also need the memmap argument to make sure the kernel doesn't try to use that memory for itself. 9MB is how big my rootfs is (or was). The \ before $ is needed in my bootloader, may not be in yours. The address I've chosen there is arbitrary, because I don't know how physical memory is laid out on your device, so pick one that makes sense for you. I assume you previously used tftp or something to load your rootfs in at that address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.