10.10 Commands for Disk Management |
As the commands which manage a hard disk, there is the fsck command which checks and restores a file system, and the du command which investigates the utilization amount of disk or files.
10.10.1 Check and Restore File System
If shutdown is not performed properly such as abnormal termination of the computer, the file management information of the file system may not match the data written to the hard disk. If the file system gets inconsistent, you need to use the fsck command to check consistency and repair it. The fsck command is automatically executed at the time of the system startup after abnormal termination.
This command checks and repairs file systems.
- fsck and journaling function
Since the EXT 3 file system with journaling function has journal information, it can be repaired quickly. On the other hand, since there is no journal information in the EXT 2 file system, it takes much more time to restore because it is necessary to check whether all the management information is correct.
Practice : Check a hard disk |
Repair the EXT3 file system with the fsck command. We specify /dev/sdc3 as the hard disk device file for fsck command.
# fsck /dev/sda3 ↵ Check /dev/sda3
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
opt: clean, 11/70400 files, 6426/140568 blocks Check file system
|
You can check and repair the mounted hard disk, but if the file system is rewritten during repair it may cause more problems. When repairing, it is recommended to execute the fsck command with the partition to be checked unmounted.
10.10.2 Check the directory amount being used
We were able to check the utilization amount of a hard disk. You can use the du command to check the utilization amount of each directories.
It displays utilization amount of specified files or directories.
Practice : Check the utilization amount of specified directories. |
If -s option is attached to the du command, the total of the size of all the files for every directory in the /usr directory will be displayed. (The size of a file will also be displayed if a /usr directory has a file)
# du -s /usr/* ↵ The total of the file size of each directory in the /usr directory is displayed.
24 /usr/X11R6
9184 /usr/arc
307200 /usr/bin
8 /usr/etc
8 /usr/games
158984 /usr/include
1900 /usr/kerberos
927576 /usr/lib
53228 /usr/libexec
248 /usr/local
34540 /usr/sbin
1936436 /usr/share
82480 /usr/src
4 /usr/tmp
|