[beaglebone] read only file system with Angstrom

Hello Dear Members,

I have SD card corruption problems in my beaglebone. As a solution, I want to set up read only filesystem.
I have read lots of documents and tried many things like editing fstab but I could not get my current filesystem read only.
Firstly, is it possible to mount filesystem of Angstrom read-only? If yes please can you just make suggestions about how to do it?

I would be thankful if anyone makes suggestions about it. SD card corruption becomed a nightmare for me.

With thanks and regards

Hi,

I managed to get the filesystem read-only:

  • first, the filesystem is loaded read-only by the kernel anyway
  • there is a service that remounts the filesystem to r/w => remove that service
  • in fstab you need to have /tmp and /var/run mounted as tmpfs

hope that helps

Hi Özen,

Can you elaborate a bit more on your SD card corruption issue? What
brand of cards are you using and what filesystem? Any ideas what
triggered the corruption (e.g. sudden power fail). I am also
concerned about this problem.

TY,
Fred

Hi Dear Rico and Fred,

Firstly, I am really thankful for your responses. This short ideas gave me lots of insights.
I am using the standard SD cards sent by cicuitco. They are Kingston Class4 SD card.

I am using standard Angstrom distribution’s filesystem. Corruption occures in rootfs side.

In my application, there is a tcp/ip connection and an image processing program (opencv).
Yesterday I found that I am saving a captured image to my /home/root/Desktop directory for each 5 seconds.
Maybe it causes the over write and sdcard corruption. So I will save the captured image to /dev/shm directory.
By the way I will keep my file in ram. I will review my project in the manner of memory usage and then I will make tests.

On the other hand, for Angstrom systems I think we have to achieve a more stable filesystem. I am planning to
get read-only filesystem for both avoiding corruptions coming from power issues and software issues.

My error is like that:

[ 15.661254] mmcblk0: error -110 transferring data, sector 1802385, nr 128, cmd response 0x900, card status 0x200b00
[ 19.912536] mmcblk0: error -110 transferring data, sector 1802496, nr 17, cmd response 0x900, card status 0x0
[ 19.923004] end_request: I/O error, dev mmcblk0, sector 1802496

With the light of Rico’s response I understand that,

→ I have to change the bootargs of uboot to root=/dev/mmcblk0p1 ro instead of rw
-> I have to find the`` service (rcX?) that remounts the filesystem to r/w and I should remove that service
-> I have to change my /etc/fstab to mount /tmp and /var/run to mount them as tmpfs

Do I have to modify /etc/fstab to mount the filesystem read only? I know how to modify it but whenever I modify it to mount filesystem read only, it does not mount. Maybe it is because of the bootargs and the service that change the fs to rw.

Thank you for all, I will dig the problem.

Regards,
Özen

2012/12/3 fred basset <fredbasset1000@gmail.com>

Hi Özen

  1. In the bootloader, you have to mount the partition that contains your filesystem ro, but that was already the case in my bootlader so I did not have to change that.
  2. In /lib/systemd/system/remount-rootfs.service I just commented out the the line that starts with “ExecStart” so the root filesystem does not get remounted as rw
  3. in fstab, you dont have to change the rootfs entry, but you have to make sure that fstab contains these two lines:

tmpfs /tmp tmpfs defaults 0 0
tmpfs /var/run tmpfs defaults 0 0

By the way, that works for the console image of Angstrom, if you’re using the image containing gnome, this might not working.
Of course, your home folder is now read only too and you cannot store data in there.

Hi Rico,

I am really really proud of you. Thank you!
In the current case I have followed your instructions and get my rootfs read-only. Thank you again and again.

As you mentioned my home folder is also read only and I have no non-volotile writable memory region left but I have a plan.
In the current case I have two memory regions (boot and rootfs). I will make three memory regions (boot,rootfs,data)
The third memory region(data) will be mounted as rw. Hence I will get a non-volatile writable region also. I think this will work.

Thank you for all Rico!

Regards.

2012/12/4 Rico <rico.cadetg@gmail.com>

Hello Özen,

thats exactly what I did :slight_smile:
I^ve created another partition on the sd card and mount that rw to have non-volatile memory, that works very well. Beside of that, I have a tool on the read-only filesystem that tries to mount the rw partition and tries to start my application, which is on the rw partition. If this fails, I format the rw partition from within that tool and start a backup tool which is located on the ro partition as well.

This is really a very smart scenario Rico. I will also follow that :slight_smile:

Read only filesystem gives a solid solution across corruptions. But on the other side I have faced a problem with writing GPIO’s. Because all the root filesystem is read only, I can not write GPIO states. This is a very bad problem for functionality an today I am digging about how to change GPIO state. If I find a solution, I will write it here.

Thank you for all!
Have a nice day

Regards
Özen

2012/12/5 Rico <rico.cadetg@gmail.com>

Hi-

This is really a very smart scenario Rico. I will also follow that :slight_smile:

There is a really easy way to keep root ro in /etc/fstab, see my
commented fstab:
------------------------8<--------------------------

# Mount root read only
rootfs / auto ro 1 1

# Mount a third partition to /home
/dev/mmcblk0p3 /home auto defaults,noatime 0 0
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0

# Mount some tmpfs, as you need, but keep the size as small
# as possible, we have no swap and the BB has only limited
# memory. Keep the files small e.g. in /var/log as e.g. Webservers
# may produce huge logfiles.... You might add to crontab
# 1 * * * * head logfile > tempfile ; tempfile > logfile
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777,size=1m 0 0
tmpfs /var/log tmpfs defaults,noatime,mode=0755,size=1m 0 0
tmpfs /var/log/apt tmpfs defaults,noatime,size=1m 0 0
tmpfs /var/run tmpfs defaults,noatime 0 0

------------------------8<--------------------------

If you need tho make some changes to your root filesystem you can turn
it to rw with:
mount -o remount,rw /

Regards
Dieter

Hi Onzen,

Any luck in the GPIO solution when trying to mount the root filesystem as read-only? I am also considering to put the whole of the rootfs as readonly but just like you I am also using the GPIO via the normal write(), read() operations.

I apologize that I digged up such an old post, but I would like to know if you have solved the problem since.