FreeBSD check the hard drive and adjust the directory structure of the file system

Source: Internet
Author: User
Tags file system

Because the file system is a very important part of the system, the task of maintaining the file system is also very important. This task includes checking, fixing the file system, and adjusting the tree to fit the changes in the system, adding new storage devices, etc.

Check your hard drive

There is no problem with the file system when using FreeBSD under normal circumstances. However, in some cases, if the computer's power is cut off without a normal shutdown operation, a file system problem will occur. In addition, for system maintenance purposes, it is also necessary to regularly check the correctness of the disk. This requires the use of the file System Check tool fsck.

# fsck /dev/wd0s3e
** /dev/rwd0s3e
** Last Mounted on /var
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
573files,3387used,26340free(132frags,3276blocks,0.4%fragmentation)

FSCK uses raw mode to access the disk, so even if the normal block device/dev/wd0s3e is used as a parameter, fsck will use the corresponding raw method device file/dev/rwd0s3e to operate. To avoid conflicts with the current disk's access operation, the file system is required to be uninstalled before checking, otherwise the file system status is always incorrect (not properly uninstalled).

In order not to affect the process running in the system, for disk maintenance, it is best to enter the Single-user state first. In this state, all unnecessary processes are turned off, the system installs only the root file system, the other files are not installed, and even the root file system is installed as read-only, which guarantees that no access conflicts will occur, resulting in an error in the file system.

Once the disk is checked for errors, Fsck prompts the administrator to make changes and can use the "-y" parameter to enable fsck to automatically fix the work without prompting for any prompts. Every time the system starts, it uses this parameter to automatically check and repair the file system.

To adjust the directory structure of a file system

A different file system is installed on the directory tree when the system is installed. Over time, some directories use file systems that are filled with file data, while in some directories the file system is rarely used, making the file system less suitable for system requirements, or adding new hard disk devices. or adjust the file to a different file system.

For example, if the FreeBSD system is used as a news server, the reader publishes the article will be saved in the/var directory of the file system, and the default/var directory space is limited, then the directory will be filled. If you continue to install a variety of applications in your system, the file system where the/usr/loc Al directory resides will be filled, and so on. Managers need to adjust according to the actual situation, you can use the DF command to view the file system's current state information.

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.