Centos disk management and maintenance

1. df command: df command is used to check the disk space occupation of the linux system;
format: df [option]
-h outputs the file system partition occupation in an easy-to-understand format,
-k outputs the file system partition occupation in units of kb Situation
-m Outputs the file system partition occupancy in MB;
-i lists the inodes information of the file system partition;
-T displays the
common combinations of file system types of disk partitions : df -h; df -i; df -T;

2.du command: du command is used to display the disk space occupied by files or directories;
format: du [options] file or directory
-sh displays the file or directory size in a humanized format, such as 300MB, 1.2GB
-ks Display file or directory size in MB

           常用组合:   #du -sh /usr/*   ; #du -ks ./* | sort -n (按大小排序)

3. The fsck command: The fsck command is used to check the file system and try to repair errors.
Format: fsck [-t <file system type>] [device name] "-t <file system type>" specifies the file system type to be checked. Under normal circumstances, this option may not be added.
Note: When executing the fsck command to repair a file system, the disk partition corresponding to this file system must be in the unmounted state. It is extremely unsafe to repair the disk partition in the mounted state, and the data may be damaged.
Example: # fsck -y /dev/sda10 (After adding the -y option, if there is a need to manually confirm the repair, it will automatically enter yes to repair. When the file system structure is damaged, it is recommended to use the y option to let the command automatically repair) .

#fuser /data1 (Check which process data1 is occupied by) [#yum install psmisc (install fuser command module)]

4.mount /umount command: mount and unmount the specified file system.

  mount [选项] [-L<标签(即设备别名)>] [-o <选项>]  [-t <文件系统类型>]   [设备名]  [挂载点]
   umount  [挂载点]  (卸载)
  选项:  -r   以只读方式加载设备;
              -w  以可读写模式加载设备,属于mount默认设置;
              -a   加载文件/etc/fstab中指定的所有设备;
              -L<标签> :标签其实就是磁盘分区标识的别名,标签可以随便起名,这样便于记忆,在linux下磁盘分区的设备名比较难记,利用标签代替设备名,简单易记。
              -o<选项>  :指定加载文件系统时的选项, ro: 以只读模式加载; rw:以可读写模式加载;
               -t  <文件系统类型>:指定设备的文件系统类型,常见文件系统类型由 xfs/ext3/ext4/vfat/nfs等;
               设备名:硬盘分区在linux上的设备标识,类似于/dev/sda1  、/dev/hda2等;
            挂载点  :Linux系统下指定的某个目录。
     例:  # mount -t ext4 /dev/sdb6  /data1  
              #mount -o remount, rw /data  (重新以可读可写模式挂载data)

Guess you like

Origin blog.51cto.com/12772149/2596129