Buildroot: How to make rootfs.ext2 not read-only - linux

Hi I am working on building a disk image which can run PARSEC benchmarks on QEMU, I got everything working, but when I run a benchmark I get it tells me that it can't generate files because it is a read-only file system. Is there an option to disable this in Buildroot menuconfig?
Thanks all !

There is an option remount root filesystem read-write during boot in the System configuration menu in make menuconfig. It defaults to on. If you disable it, the root filesystem will be readonly.

Related

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

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.

Install chromium to Linux disk image?

I'm sure this has been asked before but I have no clue what to search for
I am trying to create a custom Linux image (for the Raspberry Pi) - I am currently manipulating the filesystem of the .img but I've discovered it's not as simple as dropping in the binary :( if only...
What is the accepted way to "pre-install" a package on a disk image where you can only manipulate the filesystem and ideally not run it first? Am I best to boot up, install, and then create the image from that, or is there a way of doing it beforehand in the same way you can change configuration settings etc?
Usually, when I have to change something in a disk image, I do the following:
sudo mount --bind /proc /mnt/disk_image/proc
sudo mount --bind /sys /mnt/disk_image/sys
sudo mount --bind /dev /mnt/disk_image/dev
These action are needed as this folder are create during boot process, mounting them in your system image will emulate a full boot. Then, you can chroot on it safely:
sudo chroot /mnt/disk_image
You're now able to issue commands in the chroot environment:
sudo apt-get install chromium
Of course, change /mnt/disk_image to the path where you have mounted your filesystem. apt-get will only works on Debian based system, change it according to your distribution.
You could find problem connecting to the internet and it can be cause by DNS configuration. The best thing you can do, is to copy your /etc/resolv.conf file in the remote filesystem as this file is usually changed by dhcp and it's empty on chroot environment.
This is the only solution that gives you full access to the command line of the system you're trying to modify.
This is an untested idea:
The dpkg tool, which can install .deb packages, has a --root option which can set a different filesystem than the local / path.
From the man page:
--instdir=dir
Change default installation directory which refers to the
directory where packages are to be installed. instdir is
also the directory passed to chroot(2) before running
package’s installation scripts, which means that the
scripts see instdir as a root directory. (Defaults to /)
--root=dir
Changing root changes instdir to dir and admindir to
dir/var/lib/dpkg.
If you mount your image and pass its mountpoint as --root, it should work.
There are things like the Ubuntu Customization Kit which allow you to create your own version of the distro with your own packages.
Crunchbang even has a utility like this, which is the distro I have personally selected for experimenting with my Pi.

Beaglebone Angstrom: how to enable read only root file system

I am developing applications on Beaglebone board with Angstrom Linux distro.
I tend to mount root file system as read only because, it is not robust on readable/writeable configuration across power offs.
Can you make suggestions about how to mount root file system as read only?
What are the steps for mounting root file system read only and then turn it back to readable/writable?
With these step i tend to get a more robust file system.
Regards
You would need to edit the boot arguments that you pass to the kernel to use ro instead of rw for mounting the root file system. For example root=/dev/mmcblk0p1 ro. They are modifiable via the uboot environment variables
On a similar Angstrom-based system, I got the same "must specify the filesystem type" message.
After trying a few different things, I was able to remount root as ro using:
busybox mount -o remount,ro /
I have to admit I'm not certain why calling busybox directly worked when the "mount" command (which is a link to busybox) did not work, but I didn't have time to dig further.

Can oprofile be made to use a directory other than /root/.oprofile?

We're trying to use oprofile to track down performance problems on a server cluster. However, the servers in question have a read-only file system, where /var/tmp is the only writeable directory.
OProfile wants to create two directories whenever it runs: /root/.oprofile and /var/lib/oprofile, but it can't, because the filesystem is read-only. I can use the --session-dir command line option to make it write its logs to elsewhere than /var/lib, but I can't find any such option to make it use some other directory than /root/.oprofile.
The filesystem is read-only because it is on nonwriteable media, not because of permissions -- ie, not even superuser can write to those directories. We can cook a new ROM image of the filesystem (which is how we installed oprofile, obviously), but there is no way for a runtime program to write to /root, whether it is superuser or not.
I tried creating a symlink in the ROM that points /root/.oprofile -> /var/tmp/oprofile, but apparently oprofile doesn't see this symlink as a directory, and fails when run:
redacted#redacted:~$ sudo opcontrol --no-vmlinux --start --session-dir=/var/tmp/oprofile/foo
mkdir: cannot create directory `/root/.oprofile': File exists
Couldn't mkdir -p /root/.oprofile
We must run our profilers on this particular system, because the performance issues we're trying to investigate don't manifest if we build and run the app on a development server. We can't just run our tests on a programmer's workstation and profile the app there, because the problem doesn't happen there.
Is there some way to configure oprofile so that it doesn't use /root ?
I guess it should be as simple as overriding the HOME environment variable:
HOME=/tmp/fakehome sudo -E opcontrol --no-vmlinux --start --session-dir=/var/tmp/oprofile/foo
If that doesn't work out, you could have a look at
unionfs
aufs
to create a writable overlay. You might even just mount tmpfs on /root,or something simple like that.
It turns out that this directory is hardcoded into the opcontrol bash script:
# location for daemon setup information
SETUP_DIR="/root/.oprofile"
SETUP_FILE="$SETUP_DIR/daemonrc"
Editing those lines seemed to get it working, more or less.

Resources