News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Possible to boot filesystem in SD card with read-only access?

Started by kjl, September 07, 2018, 09:28:40 PM

Previous topic - Next topic

kjl

Hey everyone, so I was facing the issue discussed here: https://forum.trenz-electronic.de/index.php?topic=795.0 (basically SD card not available once kernel starts) and added the following code to the Device Tree as recommended:
&sdhci1 {
    // disable-wp;
    no-1-8-v;

};

However, I need read-only access, which is somehow disabled. I tried adding "ro" into the earlycon for u-boot, but write is still allowed.
This line is also printed while booting:
Quote[    3.271144] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)
[    3.279164] VFS: Mounted root (ext4 filesystem) readonly on device 179:34.
[    3.286498] devtmpfs: mounted
[    3.289508] Freeing unused kernel memory: 512K (ffffffc000c40000 - ffffffc000cc0000)
INIT: version 2.88 booting
[    3.400822] random: fast init done
Starting udev
[    3.622014] udevd[1643]: starting version 3.2
[    3.656081] udevd[1644]: starting eudev-3.2
[    4.078810] FAT-fs (mmcblk1p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[    4.110404] EXT4-fs (mmcblk1p2): re-mounted. Opts: data=ordered
It is possible that something forced the re-mounting, and it becomes write-able after that re-mounting. But I have no idea why it would remount.
Is it possible to bypass the SD card availability issue while still retaining Write-Protected status?

Thank you.
Ken

Oleksandr Kiyenko

Hello,

to run Linux with a read-only root filesystem some linux subsystems should be modified. For example special files which located in root filesystem and modified during a boot process.
Unfortunately petalinux not suitable for that by default. There is a lot of information on the internet how to modify Linux for that, but I don't have an exact recipe for petalinux.
Some information
https://wiki.debian.org/ReadonlyRoot
https://forums.xilinx.com/t5/Embedded-Linux/read-only-rootfs/td-p/645209

Best regards
Oleksandr Kiyenko

kjl

Thank you for the response! So a possible solution is to do this:
1. In /etc/fstab, change /dev/root / auto default 1 1 to /dev/root / auto ro 1 1
2. In /etc/default/rcS, change ROOTFS_READ_ONLY=no to ROOTFS_READ_ONLY=yes
3. run sync
4. restart computer

Also if you want to mount any /dev as read-only and mount -r /dev/<devname> /mnt does not work,
try mount /dev/<devname> /mnt then mount -o remount,ro /dev/<devname> /mnt