Skip to content Skip to sidebar Skip to footer

Raspberry Pi Read Only File System Error

Introduction

The power to boot a Raspberry Pi from a read-simply file system can exist advantageous for a variety of reasons and I've previously written a number of posts that look at utilise cases and implementation approaches.

A key challenge is then making changes, ofttimes this requires a reboot to change from read-simply to read-write, and so the changes are made, then the read-only setting is reintroduced with another reboot - this can become tedious when developing a solution.

Preparation

Fix the pi for read-simply with OverlayFS using my Mini Guide: Read only Raspberry Pi (without NFS) - at the time of writing this still works with RasberryPI OS, formerly Raspbian.

Basic Changes

Different the built-in Raspberry Pi process to enable OverlayFS the steps above keeps the read just file arrangement visible as a mount:

          [email protected]:~ $ df -h Filesystem      Size  Used Avail Use% Mounted on devtmpfs        1.8G     0  one.8G   0% /dev tmpfs           383M   88K  383M   1% /mnt/run /dev/mmcblk0p2   29G  one.2G   26G   v% /ro root-rw         1.9G  101M  1.8G   6% /rw overlayfs-root  one.9G  101M  1.8G   vi% / tmpfs           1.9G     0  ane.9G   0% /dev/shm tmpfs           1.9G  eight.5M  one.9G   ane% /run tmpfs           v.0M  4.0K  5.0M   1% /run/lock tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup /dev/mmcblk0p1  253M   63M  190M  25% /boot tmpfs           383M     0  383M   0% /run/user/1000                  

/ro is the root sectionalisation, and it is currently mounted equally read-only:

          [email protected]:~ $ mount -five | grep /ro /dev/mmcblk0p2 on /ro type ext4 (ro,relatime)                  

As ro suggests, nosotros can't make whatever changes to it:

          [e-mail protected]:~ $ touch on /ro/dwelling house/pi/test.txt impact: cannot touch on '/ro/habitation/pi/test.txt': Read-only file organisation                  

To brand bones changes we can only remount that in read/write mode:

          sudo mount -o remount,rw /ro                  

The command above should succeed silently, which can be verified with:

          [email protected]:~ $ mount -v | grep /ro /dev/mmcblk0p2 on /ro type ext4 (rw,relatime)                  

Where it was previously read-only (ro) it's now read/write (rw) and we can brand a exam file:

          affect /ro/dwelling house/pi/test.txt                  

We tin can also see immediately that the file is available:

          [email protected]:~ $ ls /habitation/pi/ examination.txt                  

OverlayFS is presenting a writable layer over the read-simply file organisation, so whatever underlying changes are visible immediately (unless there'south also a modification in the temporary read/write layer).

Now the file arrangement tin exist remounted in read-only mode:

          sudo mount -o remount,ro /ro                  

A quick reboot will also get it back to read-only mode.

Avant-garde Changes

There are other changes that anticipate the root file organization and the associated directory construction existence available at the / mount point (rather than /ro).

One such example would be installing software packages using apt.

For almost actions that expect root to exist at / we can utilize chroot which tin run commands or provide an interactive shell using a given binder as /.

          [email protected]:~ $ sudo chroot /ro [electronic mail protected]:/#                  

From here we can run apt update or apt install amongst other things. A "chrooted" environment has access the the majority of the host features including the network and the Internet.

We can then return to the parent file organization by exiting the trounce then return to the original country by remounting in read-only mode.

Some changes do not get picked up and so easily and a logout or reboot may be required which will also ensure we are back in read-simply mode.

A helper script

When developing a software stack or configuration for deployment it may be necessary to make lots of little tweaks in response to testing then wrapping the whole process in a script tin can make life a lot easier, specially if the script lives on the SD carte du jour as is always available.

Set the file arrangement to read/write fashion and create a using your editor of choice: sudo vi /ro/usr/bin/rwshell, then paste the following script:

          #!/bin/bash set -eastward sudo mount -o remount,rw /ro sudo chroot /ro sudo mount -o remount,ro /ro                  

And be sure to arrive executable: sudo chmod +x /ro/usr/bin/rwshell.

Sometimes a change in the chrooted read/write root might hold a file open up, in the instance below it appears a service is started and the remount to read-only fails:

          [email protected]:~ $ mount -v | grep /ro /dev/mmcblk0p2 on /ro type ext4 (ro,relatime) [electronic mail protected]:~ $ rwshell  [email protected]:/# apt install sysstat Reading package lists... Done Building dependency tree        Reading land information... Washed The post-obit additional packages will be installed:   libsensors-config libsensors5 Suggested packages:   lm-sensors isag The following NEW packages will be installed:   libsensors-config libsensors5 sysstat 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. Need to get 594 kB of athenaeum. After this operation, 1,662 kB of boosted deejay infinite will exist used. Do you desire to go along? [Y/northward]  --- snip --- Creating config file /etc/default/sysstat with new version update-alternatives: using /usr/bin/sar.sysstat to provide /usr/bin/sar (sar) in auto way Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/organization/sysstat.service. --- snip --- [electronic mail protected]:/# exit mountain: /ro: mount betoken is busy. [email protected]:~ $ which sysstat [e-mail protected]:~ $ mountain -v | grep /ro /dev/mmcblk0p2 on /ro type ext4 (rw,relatime)                  

For robustness the script could be updated to reboot instead of remount or notice the error and conditionally reboot.

Quick & Easy Read only (a side note)

The raspi-config tool can at present enable OverlayFS.

It is less useful for this article as the underlying read-only root file system is not exposed which means it is not possible (or at to the lowest degree piece of cake) to remount it in read/write mode.

          [email protected]:~ $ df -h Filesystem      Size  Used Avail Utilise% Mounted on udev            i.8G     0  1.8G   0% /dev tmpfs           383M  5.3M  378M   2% /run overlay         one.9G  101M  1.8G   6% / tmpfs           one.9G     0  ane.9G   0% /dev/shm tmpfs           v.0M  4.0K  5.0M   1% /run/lock tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup /dev/mmcblk0p1  253M   63M  190M  25% /kicking tmpfs           383M     0  383M   0% /run/user/m                  

To enable it open up raspi-config, go to Functioning Options, then select Overlay File Arrangement. It also provides options to protect the boot volume.

Notation: In older versions of raspi-config the Overlay File System option is under Advanced Options.

raspi-config
Performance Options
Enabling the Overlay File System

johnsonbetteramer.blogspot.com

Source: https://blockdev.io/easy-changes-on-a-read-only-raspberry-pi/

ارسال یک نظر for "Raspberry Pi Read Only File System Error"