RootFS types, creation and booting - linux

If you are developing anything on embedded Linux you need a Rootfs to boot Linux. Rootfs has always been a issue for me. I need some help.
My target system is ARM, U-Boot Linux simple.
a) I have seen a rootfs.tar.gz file which is copied from SD card to say 0x60000000 and then a
bootm 0x40000000 0x50000000 0x60000000
-Does U-Boot uncompresses the rootfs image?
-How does Linux know which type of rootfs it is?
b) If bootarg is passed as root=/dev/mmcblk1p1, how does Linux know which type of rootfs it is?
c) sudo qemu-debootstrap --arch=armel precise ./precise/ creates directories with bin and other entries. How do I create a tar.gz out of it?

In bootm you are specifying the system to where it can take the image of kernel.
Regarding filesystem, your filesystem reside in root=/dev/mmcblk1p1.
So copy the rootfs.tar.gz file in mmc and extract that .gz in mmc.

Related

How to mount NTFS in linux without fuseblk?

I need to check some data in linux kernel while mounting NTFS, but if I use
mkfs.ntfs
or
mkntfs
and then
mount -t ntfs ...
The string containing info about file system in kernel is "fuseblk", not "ntfs" that i need.
Maybe that's because of "ntfs-3g" packs that i installed, as i know it contains fuse drivers.
How to mount NTFS without fuse?
I tried to change options in "mount" or "mkfs", but nothing helped.
I just deleted ntfs-3g packages and it worked as i wanted... Stranger things.

How do I get an initrd made out of a cpio archive loaded as the root device by grub2 in a distro-agnostic way?

I'm building an LFS (Linux From Scratch) system in a VM and so far I've managed to get a workable, desktop system, booting from a known device, /dev/sda1 in my case. I'm now trying to make a live system that boots from an ISO image. Instead of using /dev/sr0 as the root, which I've already established is possible (and, since it's more likely to be used from a USB stick than an actual CD-ROM, is too inflexible) I've set my mind on booting it into an initrd root. The idea is to use that as the system's root instead of using it as a temporal root to load the "real" root, and since it's already in memory, it saves me the trouble of setting up a tmpfs root, copy all the files, and switch to it.
I had been previously been experimenting with a squashfs image as I had seen that Ubuntu seemed to use that and has what I needed: a small sized root, being faster to load, using less memory, and is fast (xz is SSLLOOWW to extract and gzip is slow to load). At first I was having trouble booting it, so i switched to the cpio based initrd. After some initial trouble due to missing files on the archive I did manage to boot it.
I left that aside for the time being (around a month ago) to do other tasks on the system. I lost the original GRUB2 settings and kernel config so went about doing it again but Ive been running into a brick wall. I'm hoping someone here might know what I'm missing.
When I boot up I never see any message about the loading of the initrd file, it goes straight into the loading, uncompressing and booting up of the kernel. And this ends up in a kernel panic with the message
VFS: cannot open root device "(null)" or unknown-block (1,0): error -6
Please append the correct "root=" boot option; here are the available partitions:
No partitions are shown and following that is the "kernel panic" message, just repeating the first line. If I use the "rootfstype=ramfs" I get:
VFS: mounted root (ramfs filesystem) readonly on device 0:15.
devtmpfs: error mounting -2
Essentially, it's mounting an EMPTY ramfs file system as root, so mounting the devtmpfs fails because the /dev entry doesn't exist. But certain I used that boot option before.
Here's my GRUB 2 config:
menuentry = "LFS (inird test)" {
linux /boot/kernel/initrd/linux ro rdinit=/etc/init
initrd /boot/kernel/initrd/root.cpio.gz
}
Yes, /boot/kernel/initrd/ directory entry exists, linux is the kernel (the bzimage file produced by compiling the kernel), and root.cpio.gz is my compressed initrd root cpio archive.
Here's my kernel's .config file (sorry can't paste it here).
If any more info is needed, don't hesitate to ask. That you.
OK, I managed to solve the problem! Apparently, it wasn't the kernel's configuration, GRUB2, or even the bootup sequence. It was the initrd archive itself. Deep in the bowels of the Linux kernel's configuration lied the answer: the archive must be built using cpio's --newc option. The one I built manually lacked this option, so the kernel was ignoring the archive and just proceeding with the normal boot procedure.
This came about because I managed to stumble across an older script I used to build them and saw all the options in it for cpio. I checked the much more recent script I hastily put together and double-checked the kernel documentation (as well as the init/do_mounts.c and init/initramfs.c files) and realized what was going on. I tried it with the corrections and the system now happily boots into the initrd with no problem! :D

Read only Initramfs Linux system

I have an embedded board which I am running Linux on it. Linux is booted via uboot. The full Linux image is build as Initramfs. When the system is booted I find that the root FS is read write. My understanding is that the Initramfs should be by default read only. Right?
I have tried to change boot parameter in uboot as well to have it read only, but it had no effect. I wonder what to do to make the Initramfs read only by default?
The full Linux image is build as Initramfs.
That's a poorly worded, if not inaccurate, description.
An initramfs uses a cpio archive file, which is not an image file.
The cpio archive file can be linked into the Linux kernel image.
An initramfs "image" is always a cpio archive file, and not a filesystem image.
My understanding is that the Initramfs should be by default read only. Right?
Wrong.
It makes no sense to mount the initramfs as a read-only filesystem.
When the initramfs is created and mounted, it's an empty filesystem.
If it was mounted read-only, then the initramfs could not be populated with its cpio archive, and the initramfs would remain an empty filesystem.
The suggestion to use a kernel command line parameter such as root=/dev/ram ro indicates a confusion between (deprecated) ramdisk and ramfs.
See Linux kernel Documentation/filesystems/ramfs-rootfs-initramfs.txt
I wonder what to do to make the Initramfs read only by default?
You can remount it to be read-only.
See http://lkml.iu.edu/hypermail/linux/kernel/0908.1/01693.html
and
https://serverfault.com/questions/463828/linux-initramfs-read-only

Buildroot - System doesn't boot - /dev/ttyS0 no such file

I m using buildroot to create a filesystem for a Raspberry Pi. I have uncompressed the filesystem image in the Root partition of my SD card but I can't boot the operative system. I get the following errors:
Can't open /dev/null no such file or directory
Can't open /dev/ttyS0 no such file or directory
Which line of the configuration tool should I enable or modify in order to boot the system?
EDIT
I've followed the steps provided by Thomas Petazzoni and used a preconfigured version of buildroot. Now the system works but I still don't know which option in the kernel configuration tool was causing the problem.
You don't have devtmpfs enabled in your kernel.
Also, you should start by using the raspberrypi_defconfig in Buildroot instead of rolling your own. Do:
make distclean
make raspberrypi_defconfig
make
And then follow the instructions in board/raspberrypi/readme.txt to know how to use the resulting images.

mount rootfs on loopback

I have a rootfs boot image that I want to test by mounting on my local file system. How can I do this ?
EDIT: The file was a rootfs.img but it turned out I did not have the correct filesystem support in my custom kernel. pjz's answer works once the fs support is there.
Need more info - what kind of image is it?
is it a file that's a filesystem? if so you mount it like:
mount -o loop rootfs.img /mnt/rootfs
if it's a subdir of your filesystem that you'r exporting via nfs, you can simulat ethe environment you've created by chrooting to it:
chroot /path/to/nfs/rootdir/

Resources