Linux can not save changes if power off and then on?
Hi, i'm facing a werid thing in my arm-linux system:
After i do some changes to the linux file, for example, modification to /etc/inittab, chmod +x to xxx.sh, using i2ctools to set RTC values...I can see the changes are taken effect. However, after that, If i power my device off and then power on, some files will return to the original status that were before the changes. What's more werid is that instead of power off the device, if I reboot the device using shell command, then the changes will remain effective, files will not return to the original status that were before the changes. |
Are you issuing a sync command before powering off so the changed blocks in memory are written to disk?
|
I dont know there is such thing as sync.
Thanks a lot for the tip. I've checked the man sync. It says 'sync' writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. But why simple commands such as 'chmod +x' will be treated as a delayed reads and writes? Would it be the problem of my slow CPU and something wrong with the data bus? Quote:
|
Hi there,
Quote:
And so most systems just prepare this write operation in a buffer in memory and hold it back for some seconds (or even minutes), while subsequent updates only affect the buffered data in memory. Some time later, when the system is idling, it actually writes the modified data to disk. So, to make sure every change is actually saved to disk, you either have to wait some time while the system is idle (but you don't know how long actually), or you have to force that by issuing a sync command. A controlled shutdown or restart implicitely does a sync. [X] Doc CPU |
Can you provide some details on your ARM device? What is its make / model.
|
Its a tao3530-OMAP3530 chip.
What's superising me is that i'm using i2cset to set RTC time, and even this is buffered, need to use sync command. Quote:
|
The best way to prevent problems is to shut the system down before removing power.
It doesn't matter HOW many "sync" commands you give... some buffers will not be written. Think about it - there are log file buffers that get updated... using the sync command itself causes a buffer to be updated... after the system call is given... All sync does is MINIMIZE the damage, it doesn't remove all of it. |
are we certain that /etc/inittab is not in ram?
a simple Code:
df -h |
Very good point.
Quote:
|
---------- Post added 09-06-13 at 09:06 AM ----------
[/COLOR]How to confirm that? I'm having the following output of df -h root@devkit:~/tests# df -h Filesystem Size Used Available Use% Mounted on ubi0:rootfs 460.5M 337.7M 118.0M 74% / none 115.5M 92.0K 115.4M 0% /dev tmpfs 115.5M 72.0K 115.4M 0% /var/volatile tmpfs 115.5M 0 115.5M 0% /dev/shm tmpfs 115.5M 0 115.5M 0% /media/ram /dev/mmcblk0p1 70.4M 2.9M 67.5M 4% /media/mmcblk0p1 /dev/mmcblk0p2 3.6G 2.2G 1.2G 65% /media/mmcblk0p2 /dev/mmcblk0p2 3.6G 2.2G 1.2G 65% /mnt Quote:
|
sorry, I should have posted this extended version first time round
Code:
df -T -h /etc/inittab I did a little reading on ubi0 http://www.linux-mtd.infradead.org/faq/ubifs.html looks like sync, and some time is what you need |
Another thing if you're writing application programs would be to fork() a child, have the child perform the file action, wait in the parent for the child to complete. Like this:
Code:
pid_t pid; I find it faster than a full file system sync call. Again, for programming practice versus the shell. Correct shutdowns are helpful. But on things like an ARM, it's likely embedded and therefore can be shut down by someone pulling the battery. Hence in a lot of cases, it's best to protect files as much as you can. |
Waiting for a copy to complete does NOT guarantee that the blocks are on disk. All it means is that the process has completed transferring the buffers to the system.
NOT that the buffers are on disk. That is why it is faster than a sync system call. It doesn't wait for the buffers to be flushed to disk. It would be like turning off a printer before the last page has ejected... Sure, it has been printed... but has it been fixed... Most embedded systems don't have a disk... so there is nothing to flush. |
All times are GMT -5. The time now is 05:29 AM. |