0

I am using embedded linux (built using LTIB).

I am unable to make changes to /etc directory. Basically I want to add a start-up script to /etc/rc.d/init.d

/etc/ seems to be mounted as rwfs

output of df -h:

Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.0G    376.9M      2.4G  13% /
tmpfs                   424.2M     36.0K    424.1M   0% /dev
shm                     424.2M         0    424.2M   0% /dev/shm
rwfs                    376.0M      5.1M    370.9M   1% /mnt/rwfs
rwfs                    376.0M      5.1M    370.9M   1% /tmp
rwfs                    376.0M      5.1M    370.9M   1% /var
rwfs                    376.0M      5.1M    370.9M   1% /etc

I have tried :

umount /etc/ 
touch /etc/dummy  --> just for the sake of checking
reboot
(after boot-up)
ls -lth /etc/dummy ---> file is missing

This is an image which I boot from an SD card. On one of the SD cards, after I did the above umount /etc, and then placed a dummy file as mentioned above, on the next boot as expected /etc goes back to be mounted as tmpfs but the dummy file was available. But on another SD card when I try the same, dummy file is not available.

Any suggestions?

Output of mount (before using umount /etc/):

root@freescale /etc$ mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw,relatime,errors=continue)
proc on /proc type proc (rw,relatime)
sys on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
shm on /dev/shm type tmpfs (rw,relatime)
rwfs on /mnt/rwfs type tmpfs (rw,relatime,size=385024k)
rwfs on /tmp type tmpfs (rw,relatime,size=385024k)
rwfs on /var type tmpfs (rw,relatime,size=385024k)
rwfs on /etc type tmpfs (rw,relatime,size=385024k)

Output of mount (after umount /etc):

rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw,relatime,errors=continue)
proc on /proc type proc (rw,relatime)
sys on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
shm on /dev/shm type tmpfs (rw,relatime)
rwfs on /mnt/rwfs type tmpfs (rw,relatime,size=385024k)
rwfs on /tmp type tmpfs (rw,relatime,size=385024k)
rwfs on /var type tmpfs (rw,relatime,size=385024k)
New contributor
kman is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    have you tried mount -o remount,rw /etc? – Eugen Rieck Jan 11 at 13:16
  • @EugenRieck: Yes I have tried, it comes back saying "mount: can't find /etc in /proc/mounts" – kman Jan 11 at 13:39
  • Please ask a specific question. "Any suggestions?" is not specific. My answer assumes the real question is "why?" See How to Ask. – Kamil Maciorowski Jan 11 at 14:04
2

This line from the output of mount

rwfs on /etc type tmpfs (rw,relatime,size=385024k)

says /etc is in fact tmpfs. Now from Wikipedia:

tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but stored in volatile memory instead of a persistent storage device.

And

Everything stored in tmpfs is temporary in the sense that no files will be created on the hard drive; however, swap space is used as backing store in case of low memory situations. On reboot, everything in tmpfs will be lost.

This is exactly what happens in your case.

Embedded systems use tmpfs for /etc and few other directories to make them writable for any program that needs it, but in the same time

  • to avoid filesystem corruption when any writing is in progress and the device is powered off by pulling the plug;
  • to avoid OS corruption when you do something wrong by playing in the console.

"Big" systems may be rescued by booting from USB, running fsck etc. Here it's highly desirable to just restart with verified configuration.

In general the OS may provide a way to commit changes, write them to a non-volatile memory from where they will be restored at the next reboot. Or it may neither provide a way nor such restoration process at all.

  • this is an image which I boot from an sd card. On one of the sd card, after I did 'umount /etc', and then placed a dummy file inside it. On the next boot 'etc' goes back to be mounted as tmpfs but the dummy file was available. But on another sd card when I try the same, it doesn't work. – kman Jan 11 at 13:54
  • @kman What is your point? Note I don't know details of your embedded system, e.g. how it populates /etc after mounting tmpfs there. – Kamil Maciorowski Jan 11 at 14:00
  • Just added my above comment to the description above - just to ensure I have described the problem fully. What is not clear at this point is - as you say "In general the OS may provide a way to commit changes, write them to a non-volatile memory from where they will be restored at the next reboot. Or it may neither provide a way nor such restoration process at all." --- how is this working on one sd card but not on the other. – kman Jan 11 at 14:00
  • @kman My bet is you did something in a different way. – Kamil Maciorowski Jan 11 at 14:05

Your Answer

kman is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.