Mount ext2 as totally readonly system from busybox - linux

I'm using ext2 FS on my embedded device (busybox) with readonly mode. But, when I check FS if its true readonly system. I found strange things: When I type cat /proc/mounts
rootfs / rootfs RW 0 0
/dev/root / ext2 ro,relatime,errors=continue 0 0
...
But in: /boot/grub/menu.lst
kernel=/boot/bzimage root=/dev/sda1 ro
in fstab:
/dev/root / ext2 ro,noatime,nodiratime,errors=remount-ro 0 1
in inittab:
null::sysinnit:/bin/mount -a
/bin/mount:
rootfs on / type rootfs (RW)
/dev/root on / type ext2 (ro,relatime,errors=continue)
I can't understand why rootfs mounted as RW (in case /proc/mounts and /bin/mount), and why arguments for mounting from fstab doesn't correspond to arguments in/bin/mount?

rootfs is the initial root filesystem at /. It is in RAM only, and is unreachable after /dev/root has been mounted over it.
/usr/src/linux/Documentation/filesystems/ramfs-rootfs-initramfs.txt

Related

Not able to find /opt /var /tmp in lsblk RHEL 8.1

Am Not able to find /opt /var /tmp in lsblk RHEL 8.1.Can you please help me.
[xxx#exxx ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 64G 0 disk
+-sda1 8:1 0 500M 0 part /boot/efi
+-sda2 8:2 0 500M 0 part /boot
+-sda3 8:3 0 2M 0 part
+-sda4 8:4 0 60G 0 part
+-rootvg-rootlv 253:5 0 60G 0 lvm /
lsblk
lsblk is used to display details about block devices and these block devices(Except ram disk) are basically those files that represent devices connected to the pc. It queries /sys virtual file system and udev db to obtain information that it displays. And it basically displays output in a tree-like structure. This command comes pre-installed with the util-Linux package.
That is the reason you are unable to saw the directories /opt, /var and /tmp
/opt is for “the installation of add-on application software packages”.
/var is a standard subdirectory of the root directory in Linux and other Unix-like operating systems that contains files to which the system writes data during the course of its operation.
/tmp directory is a temporary landing place for files.

How change the filesystem or all catalog /etc/ from RO-ReadOnly to RW?

I have a question I have a RO filesystem that is readonly. What I need to change in the file fstab in order to be able to edit system files or the all /etc/ directory editing. I can edit only fstab.
fstab file:
/etc # cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount pt> <type> <options> <dump> <pass>
/dev/root / ext2 rw,noauto 0 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts defaults,gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs mode=0777 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
I do not know much about Linux, so I will be grateful for your help.
Try the following version and it should work independent of the contents of /etc/fstab:
mount -o remount,rw /dev/xxxx /
Instead of /dev/xxxx, use whatever device is valid for your drive.

How to mount an rsync-copied partition combined from two source partitions

My PC is running ArchLinux. My PC has two hard disks, /dev/sda and /dev/sdb. sda is the source disk and contains all my files. sdb is the destination disk and is currently empty. My purpose is to make a copy of sda to sdb, and also make sdb another bootable ArchLinux installation.
sda has three partitions: sda1 for /boot, sda2 for /, sda3 for /home. Here is its /etc/fstab:
/dev/sda2 / ext4 rw,relatime,data=ordered 0 1
/dev/sda1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2
/dev/sda3 /home ext4 rw,relatime,data=ordered 0 2
I formatted sdb to two partitions only: sdb1 for /boot and sdb2 for /. I used rsync to copy sda1 to sdb1, as well as sda2 and sda3 to sdb2. And then I also updated the UEFI bootloader and /etc/fstab:
/dev/sdb2 / ext4 rw,relatime,data=ordered 0 1
/dev/sdb1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2
The problem is, when I booted from sdb, both sdb1 and sdb2 were automatically mounted, but /home is empty. My personal home directory was not found under /home. Why is that?
Later I rebooted from sda and then manually mounted sdb2 and confirmed that my personal home directory was in /home.
I figured out the problem. I forgot to update /boot/loader/entries/arch.conf, so the gummiboot bootloader actually loaded /dev/sda2 instead of /dev/sdb2. And because sda2 did not contain /home/, so /home/ was not found.

UBIFS mount in busybox via fstab does not recognize relatime option

I am getting this error when I try to mount my UBIFS filesytem:
mount -o remount,rw /config
UBIFS error (pid 1265): ubifs_parse_options: unrecognized mount option "relatime" or
missing value
The content of my fstab is :
root#drgos:~# cat /etc/fstab
# WARNING: this is an auto generated file, please use uci to set static filesystems
/dev/ubi0_0 /config ubifs ro 0 0
And when I type mount the result is :
root#drgos:~# mount
rootfs on / type rootfs (rw)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=512k)
none on /dev/pts type devpts (rw,relatime,mode=600)
/dev/ubi0_0 on /config type ubifs (ro,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
I do not understand why I have the option relatime since that one is not present in my fstab!
I am using BusyBox v1.11.2 (2014-01-13 09:35:41 CET) multi-call binary.
These options are dependent on the Linux kernel version. relatime is a general mount options. relatime is the default for newer Linux kernels. Other filesystems may quietly ignore unknown options, whereas ubifs is failing. You can try mount -o remount,rw,noatime,norelatime /config. Your mount command shows the /config directory is mounted with relatime; this is information that busybox mount applet collected.
This information is collected with the getmntent_r() function. If busybox is dynamically linked, then the 'C' library may be giving this information as part of the *mnt_opts* string.
The idea with mount -o remount,rw,noatime,norelatime /config is to try and over-ride this information so that UbiFs will be happy with its mount options. The other way is to simply umount and then mount again manually.
umount /config
mount -t ubifs /dev/ubi0_0 /config
This way previous mount information will not be retrieved.

Ordering of /proc/mounts and /etc/mtab

Does anyone know whether /proc/mounts is guaranteed to be in the order in which devices are mounted?
For instance:
[root#machine proc]# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/sda1 /boot ext3 rw,data=ordered 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/dev/root /boot ext3 rw,data=ordered 0 0
In the above case, can I be sure that /boot will currently show /dev/root rather than /dev/sda1, which is currently hidden.
I'm guessing the same answer should be true of /etc/mtab.
I'm on RHEL 5.5.
The mount points in /proc/mounts are in mounted order. If you mount a new file system it gets appended to the list of filesystems, essentially obscuring the original mount point.
There are absolutely no guarantees about the content of /etc/mtab, it is purely managed by the userland mount command, so can be bypassed or rewritten arbitrarily, plus you can use the '-n' option to mount will actually omit placing entries in the /etc/mtab, thus making it incorrect relative to the kernel.
As a silly question, why do you need this information?

Resources