View: 4731|Reply: 2

Prevent sd card corruption - create read only root FS

[Copy link]

3

threads

7

posts

33

credits

Novice

Rank: 1

credits
33
Published in 2022-8-31 06:08:38 | Show all floors |Read mode
This post was finally edited by Nadalia at 2022-8-31 06:10

I'm looking to prevent sd card corruption.

I thought the best way is to have a readonly fs, so I tried following the instructions here, but it failed on following step:
    $sudo mount -o move /etc /mnt/etc/
    mount: /mnt/etc/root-ro: bad option; moving a mount residing under a shared mount is unsupported.

My goal is to prevent sd card corruption.
1. Is there a better way of creating a readonly fs?
2. Are there other options of reducing corruption? e.g. automatically running fsck?

Hardware: Zero 2
OS: Debian (official Orangepizero2_3.0.6_debian_bullseye_server_linux5.16.17)
If sound and gpio work good on Ubuntu I can move to that OS (unfortunately sound and gpio seem to be problematic on Armbian).

I'm a "simple" programmer and not familiar with mounting/fs/overlay - Any help is very much appreciated.



1

threads

24

posts

107

credits

Registered member

Rank: 2

credits
107
Published in 2022-9-16 03:23:54 | Show all floors
You wont get SD card corruption on an Orange Pi.

The reason is it does NOT uses a FAT32 partition for /boot

The Raspberry Pi, as good as it is, fails because it uses weak windows file systems for the boot partition. The / partition
is a linux ext4 but the boot partition allows windows users to edit the config files.

If you're running a distribution like Armbian, then your system has all the advantages of a raspberry Pi but none of its disadvantages.

In addition, when choosing a SD card for your Orange Pi make sure its from a reliable vendor like Sandisk.

I read write to my Orange Pi zero  most days and it has no problem.

A power cut or failure results in failure to FAT file systems. This happened to my Orange Pi, result  no corruption
just a reboot and in the log was a message about an invalid inode entry that was corrected.

Hope that helps

0

threads

1

posts

10

credits

Novice

Rank: 1

credits
10
Published in 2023-11-29 01:42:33 | Show all floors
This post was finally edited by andrey-sh at 2023-11-29 01:44

I found a good version of instructions only for ubuntu. For debian there was also an attempt to use the overlayroot package, but as far as I understand, other solutions or workarounds need to be used there.

Run the following commands only for Ubuntu based Armbian (official Ubuntu for orange pi zero 2 is also suitable)
  1. sudo apt update
  2. apt-get remove unattended-upgrades
  3. mv /usr/lib/apt/apt.systemd.daily /usr/lib/apt/apt.systemd.daily.DISABLED
  4. apt-get install overlayroot
  5. echo 'overlayroot="tmpfs"' > /etc/overlayroot.conf
Copy code

Use overlayroot-chroot to make edits to the system:
  1. cd /media/root-ro
  2. mount -t proc proc proc/
  3. mount -t sysfs sys sys/
  4. mount -o bind /dev dev/
  5. overlayroot-chroot
Copy code

Check and minimize space in RAM used by overlay files
  1. df -h /media/root-rw
  2. rm -rf /media/root-rw/overlay/var/
Copy code
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list