Linux Mount management and linux Mount Management

Source: Internet
Author: User

Linux Mount management and linux Mount Management

Overview

In the previous chapter, the mount command has been used to mount partitions in the linux operating system space. This chapter details the mount management, this command involves many knowledge points and is also important. It is a command to be mastered.

 

Mount a partition

Mount basic syntax

Mount [parameter]/dev/sdb1 (partition to be mounted)/sdb1 (mount directory)

The parameter is optional or does not contain any parameter. The parameter usage method (-o ro, sync, atime ).

Parameters:

-T: Specifies the file system type.

mount -t ext4 /dev/sdb1 /sdb1

-O: Specifies the mount option.

Ro, rw: Read-only or read/write mounting. The default value is rw.

Sync: cache is not applicable, and all operations are directly read and written to the disk.

Async: Applicable to cache. default mode.

Noatime: The file access time is not updated each time a file is accessed.

Atime: update the file access time each time you access a file. The default method is.

Remount: remount the file system.

 

View the Currently mounted partitions

mount

You can run the mount command without parameters to view all the mount partitions of the current system, including the mount points, partition types, and parameters of the partitions.

View the ls/sdb1 files in the Mount Partition

There will be a Lost + found folder under each Mount partition, which is used to store corrupted data of the file. For example, use fsck to check the partition command error information and write it to the folder (command: fsck/dev/sdb1 ).

Modify partition read-only

mount -o remount,ro /dev/sdb1 /sdb1

After you change sdb1 to read-only, you cannot use touch to create files.

Do not update File Access time

mount -o remount,rw,noatime /dev/sdb1 /sdb1

Especially for systems with high performance requirements, you can set the file system to not update the time when accessing files, such as the partitions that store database files, because access is very frequent, if the access time is updated for each access, the performance may be affected. In this case, we can set the access time of the partition to not update the file to improve the performance.

Stat command

You can run the stat command to view the file access time.

stat test

This is because I have made changes to the parameters later. After adding the noatime parameter, the access time will not be modified. You can try it;

No Cache

The purpose of enabling the cache is to improve the read/write performance, that is, you read and write data first, because the cache read/write speed is much higher than that of the disk, this will improve the read/write performance, however, there is also a risk of data loss and modification when the data is written to the cache and suddenly becomes unavailable, the cached data may be lost, resulting in no data written to the disk. However, now linux File System types such as ext3 and ext4 will record logs by default, that is, there will be MB of log space in the partition to record disk read/write operations, this is also a measure to ensure data loss and modification. Caching is not applicable to systems with strict data requirements, but is applicable in most cases. This is the default method in linux.

mount -o remount,rw,noatime,sync /dev/sdb1 /sdb1

Detach a partition

Umount syntax

Umount/dev/sdb1 (partition) or umount/sdb1 (mount point)

Detach an sdb1 Partition

An error occurred while uninstalling the device. The following message is displayed: the device is busy.

Fuser command

You can run the fuser command to view the processes occupied by the file system.

Fuser-m/sdb1 (mount point)
Or
Fuser-m/dev/sdb1 (partition)

 

We can see that the 2821 process is in use.

Losf command

View the files in use. The losf command is short for list open file.

Losf/sdb1 (mount point)

 

You can use the losf command to view the files in use. bash is in use, because I am in the sdb1 folder, and the current command window is in use. Switch to another directory.

After switching to another path, run the umount command to unmount the partition. Run the mount command to view the partition information. You can see that the sdb1 partition has been uninstalled.

Summary

The most important part of the mount command is the rational use of parameters, because these parameters will affect the performance of our system. I wrote two articles one day in a row. It's really tiring. It's already early in the morning.

 

 

Note:

Author: pursuer. chen

Blog: http://www.cnblogs.com/chenmh

All essays on this site are original. You are welcome to repost them. However, you must indicate the source of the article and clearly provide the link at the beginning of the article. Otherwise, you will be held accountable.

Welcome to discussion

 

 

 

--- Restore content end ---

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.