In the Linux World -- Linux System Management 5

Source: Internet
Author: User
Article Title: galloping in the Linux World-Linux System Management 5. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   Use a File System
  
After creating a file system, run mount to install the file system to the main file system. The command mount has three main parameters:
  
(1) The type of the file system to be installed is specified using the-t fstype option, which is the same as the-t option in mkfs.
  
(2) The partition name of the file system to be accessed, usually the special device file in the/dev directory. If you need to install the Network File System, use the directory name output on the server.
  
(3) The path name for installing the new file system, that is, the Mount Point for placing the new file system ). This is usually an empty directory name and is specially prepared for installing a new file system. In Linux, directory/mnt is a commonly used file system installation directory. By default, both cd rom and floppy disk drives are installed in their subdirectories. Of course, the file system can also be installed in other empty directories. Do not install a file system in a non-empty directory. If this is done, the original content in this directory will be overwritten by the newly installed file system content.
  
For example, to install the ms dos file system partition/dev/hda1 to the system's empty directory/dos, run the following command:
  
# Mount-t msdos/dev/hda1/dos
  
After installing the required file system, you can use the mount command without parameters to view the currently installed file system. The installation status of the file system is recorded in the file/etc/mtab. The file is modified every time you run the mount or umount command to make the file content consistent with the actual installation of the file system in the system.
  
Linux uses a/etc/fstab file that lists all partitions that need to be automatically installed at the beginning of the system. In addition, the file can also pass parameters to the mount command. The Linux system will execute the script/etc/rc at the beginning. d/rs. sysinit, this script uses the fsck command to check the Linux partition to be installed. After no error is found, the content in the/etc/fstab file will be read, and according to the specified parameters in the file, automatically install the specified file system in the file.
  
Before shutting down the system, all installed file systems must be uninstalled to ensure the integrity of the file system. Generally, the file system defined in the/etc/fstab file can be automatically detached. However, for a manually mounted file system, you must manually uninstall it before shutting down the system. Sometimes you also need to manually Uninstall a file system during system operation. The umount command must be used to manually uninstall the file system. The umount command takes the partition name or partition Installation Point as a parameter in the following format:
  
Umount <分区名或分区的安装点>
  
For example, to detach a floppy disk that has been installed in the/mnt/floppy directory, run the following command:
  
# Umount/mnt/floppy
  
Note that the umount command cannot be used to uninstall a file system in use. In addition, for the sake of security, in Linux systems, only the system administrator root can complete hard disk partitioning, formatting partitioning, installing the file system, or uninstalling the file system.
  
   Maintain the File System
  
1. repair damaged file systems
  
When the Linux File System is caused by human factors or the system itself (for example, the user accidentally cold-starts the system, the disk key track error, or the machine did not have time to write the data in the cache to the disk before it is closed) when the file system is damaged, the integrity and correctness of the file system are affected. In this case, the system administrator is required to perform maintenance.
  
The fsck tool is used to check common file systems in Linux. The common format of The fsck command is as follows:
  
Fsck [options] file_system [...]
  
Generally, you do not need to specify any options for fsck. For example, to check the file system in the/dev/hda1 partition, run the following command:
  
# Fsck/dev/hda1
  
Run the fsck command to check the file system when the file system is not mounted. This ensures that no files are used in the file system during the check. If you need to check the root file system, boot the boot from a floppy disk and specify the device file name corresponding to the root file system when running fsck. For general users, do not use fsck to check file systems except ext2 for security purposes.
  
Fsck can fix the file system errors. If you need fsck to repair the file system, you must use options-A and-P in the command line. After the file system is repaired, restart the computer so that the system can read the correct file system information.
  
The fsck checks the file system in sequence starting from the super block, and then the allocated disk block, directory structure, number of links, and I nodes of idle block chain tables and files. Generally, you do not need to manually run fsck because fsck is automatically called if you find that the file system to be installed is incorrect during Linux boot.
  
2. Avoid file system errors that may cause system crashes
  
To avoid system crashes due to file system errors, consider the following measures and precautions:
  
(1) After the Linux system is correctly installed, back up the system;
  
(2) create a boot disk corresponding to the current Linux core;
  
(3) Back up important files on a floppy disk;
  
(4) It is best to use UPS for key servers to prevent sudden power loss;
  
(5) regularly use fsck or badblocks to check the disk. Once an error is found, you must back up the disk;
  
(6) Generally, do not log on to the Linux system as root;
  
(7) do not directly turn off the power switch of the system after the task is completed. It is best to use the shutdown command;
  
(8) do not fill hard disk space with useless programs or data.
  
This minimizes the loss caused by file system errors.
  
3. Other commands for File System Management
  
Du // statistics on the disk usage of subdirectories in the current directory, mainly to measure the size of the subdirectories and the files in all subdirectories
Df // count the free disk space in the file system. By default, the disk usage information of all file systems is displayed.
In // used to establish a link between directories or files
Find // used to find files or directories on Linux
Tar // is a file management tool used to archive or restore files from the archive.
Gzip // GNU File compression tool, used to compress Linux Files, usually used with tar
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.