Wednesday 28 August 2013

Explain the use of sync and fsck.

If you have to shut a system down extremely urgently or for some reason cannot use shutdown, it is at least a good idea to first run the command:
    # sync 
which forces the state of the file system to be brought up to date.
System startup:
At system startup, the operating system performs various low-level tasks, such as initialising the memory system, loading up device drivers to communicate with hardware devices, mounting filesystems and creating the init process (the parent of all processes). init's  primary responsibility is to start up the system services as specified in /etc/inittab. Typically these services include gettys (i.e. virtual terminals where users can login), and the scripts in the directory /etc/rc.d/init.d which usually spawn high-level daemons such as httpd (the web server). On most UNIX systems you can type dmesg to see system startup messages, or look in /var/log/messages.
If a mounted filesystem is not "clean" (e.g. the machine was turned off without shutting down properly), a system utility fsck is automatically run to repair it. Automatic running can only fix certain errors, however, and you may have to run it manually:

# fsck filesys 
where filesys is the name of a device (e.g. /dev/hda1) or a mount point (like /). "Lost" files recovered during this process end up in the lost+found directory. Some more modern file systems called "journaling" file systems don't require fsck, since they keep extensive logs of file system events and are able to recover in a similar way to a transactional database.

No comments:

Post a Comment