Linux disk and File System Management (3) _ Disk Mount Offload

Source: Internet
Author: User

Mounting and unloading of disks

Mount: Attach the system's additional file system to the root file system through the directory under the root, which will be the entry operation into the new disk partition (i.e. file system).

Uninstall: The process of releasing this association relationship.

Mount points mount point : The directory on which the device is mounted

Note : After the mount point is mounted, the original files and directories under its directory will be temporarily hidden, and when the new partition is unloaded, the original files and directories will be displayed again. Therefore, it is recommended that the mount point use an empty directory.


Mount Mount:

Mount [-l] reads the/etc/mtab file to display all devices that are already mounted on the current system

[Email protected] test]# mountproc on/proc type proc (rw,nosuid,nodev,noexec,relatime)/dev/sda3 on/type ext4 (Rw,relat ime,seclabel,data=ordered)/dev/sda2 on/usr type EXT4 (rw,relatime,seclabel,data=ordered) .... Omit ... debugfs on/sys/kernel/debug type Debugfs (rw,relatime)/dev/sda1 on/boot type EXT4 (rw,relatime,seclabel,data= Ordered)/dev/sda5 on/home type EXT4 (rw,relatime,seclabel,data=ordered)

mount-a: mount a disk that is not mounted according to the data/etc/fstab by the configuration file

Mount [-FNRSVW] [-t vfstype] [-o options] device mount_point

Device : devices to be mounted

1 Device files:/DEV/SDB5

2 Volume Label:-l ' label '

3 uuid:-u ' uuid '

4 Pseudo File system

5 file path: Bind mount

mount_point : Mount point

Recommended Empty Directory

Options:

-L: Increase the display of the label column when displaying the current Mount information

-N: Do not write to/etc/mtab, by default, actual mount conditions are written to/etc/mtab in real time

At this point, if you want to view all the file systems that are mounted: cat/proc/mounts

-T: Specifies the type of file system that will be mounted

-L: Label-mount by specifying a volume label

-R: Mount in read-only mode

-A: Mount all file systems in/etc/fstab

-F: Skip system mount, trial run

-B: Bind a directory to another directory

The-O options are primarily used to describe how devices or files are hooked up.

Parameters:

Loop: Used to attach a file as a hard disk partition on the system

RO: Hook device with read-only method

RW: Mount device with read-write mode

Iocharset: Specifies the character set used to access the file system

Async: The file system uses asynchronous writes

Sync: File system uses synchronous write

Auto,noauto: Allow partition to be used Mount-a auto mount

Dev,nodev: Whether to allow the creation of device files on this partition

Suid,nosuid: Whether to allow Suid/sgid file format on this partition

User,nouser: Whether to allow any user under this partition to perform mount

Defaults: Default value rw, suid, dev, exec, auto, Nouser, and async.

Remount: Re-mount, much in case of system error, or update parameters when using

Example

#按指定卷标挂载  -L [[email protected] ~]# mount -L  ' mytest '  /mnt/test1[[email  protected] ~]# mount | grep  '/dev/sdb. ' 30:/dev/sdb1 on /root/test_mount/test1 type ext4  (rw,relatime,seclabel,data=ordered) # Read-only mount Partition [[email protected] ~]# mount -r /dev/sdb5  /mnt/test2[[email  protected] ~]# mount | grep  '/dev/sdb. ' 30:/dev/sdb1 on /root/test_mount/test1 type ext4  (rw,relatime,seclabel,data=ordered) 31:/dev/sdb5 on /root/test_mount/test2 type ext4  (ro,relatime,seclabel,data=ordered) [ [email protected] ~]# dffilesystem     1k-blocks     used available use% mounted on .... Omit .../dev/sdb1         999320    2564     927944   1% /mnt/test1/dev/sdb5         499656      784    462176   1% /mnt/test2# to mount the/home directory under/MNT/TEST3 [[Email  protected] mnt]# mount -B /home/  /mnt/test3/[[email protected]  MNT]# LL /HOME/ /MNT/TEST3//HOME/:TOTAL 32DRWX------.  2 hadoop     HADOOP     4096 SEP  9 08:04 HADOOPDRWX------.  2  root      root      16384 aug 20  06:12 LOST+FOUNDDRWX------.  2 roger     roger       4096 AUG 20 06:34 ROGERDRWX------.  3 test1      test1      4096 Sep  7 04:28  TEST1DRWX------.  2 testuser1 testuser1  4096 sep 13 18:03 testuser1/mnt/test3/:total  32DRWX------.  2 hadoop    hadoop     4096 sep   9 08:04 HADOOPDRWX------.  2 root      root       16384 AUG 20 06:12 LOST+FOUNDDRWX------.  2 roger      roger      4096 Aug 20 06:34  ROGERDRWX------.  3 test1     test1      4096  SEP  7 04:28 TEST1DRWX------.  2 testuser1 testuser1  4096  sep 13 18:03 testuser1

umount: Uninstall Command

Umount [-FN] DEVICE

Device file name

Umount [-FN] Mount_point

Mount_point mount point

Parameters:

-F: Forced uninstallation

-N: Uninstall without updating/etc/mtab

Example:

#设备名称卸载 [[email protected] ~]# umount/dev/sdb1# because the directory is mounted, so only the same mount point uninstall [[email protected] ~]# umount/mnt/test3/


Device is occupied when uninstalling

[Email protected] ~]# Umount/dev/sdb1umount:/mnt/test3:target is busy. (In some cases useful info about processes, use the device are found by lsof (8) or fuser (1))


To view the process that is accessing the specified mount point:

# fuser-v Mount_point

[[email protected] ~]# fuser-v/mnt/test3/user PID ACCESS command/mnt/test3:root Kernel mount/mnt/test3 root 3356. C.. bash

Terminates all processes that are accessing the specified mount point:
# fuser-km Mount_point

[[email protected] ~]# fuser-km/mnt/test3//mnt/test3:3356c# successfully uninstalled [[email protected] ~]# UMOUNT/DEV/SDB1


Additional notes:

fuser Command : Displays all process information that is using the specified file, file system, or sockets

fuser [-FUV] [-a|-s] [ -4|-6] [-c|-m|-n space] [-K [-i] [-M] [-W] [-signal]] File name/file system/sockets

Parameters:

-k,--kill: Kill the process of the file being accessed

-I: Interactive mode to confirm before killing process

-M: The file name next to it will refer to the top level of the filesystem, which is very effective for umount unsuccessful.

-U: Process number is displayed in parentheses after the process owner

-V: Output Process details

By default, each process number follows a letter that indicates how the process uses the file.

C File as current directory
e file as the executable object of the program
R file as root directory
M file as mmap file or shared library

Example:

[[email protected] ~]# fuser /mnt//mnt:                  3427c[[email protected] ~]# fuser -u  /mnt//mnt:                  3427c (Root) [[email protected] ~]# fuser -v /mnt/                      user         PID ACCESS COMMAND/mnt:                 root        3427&NBSP, .... C..  bash[[email protected] ~]# fuser -ki /mnt//mnt:                  3427cKill process 3427  ?  (y/n)  n 


Mount the relevant configuration file:

/etc/fstab (File system table)

The record is the system ready to mount the file system to set the boot mount

[[email protected] ~]# cat /etc/fstab ## /etc/fstab# created by  Anaconda on thu aug 20 06:13:01 2015## accessible filesystems, by  reference, are maintained under  '/dev/disk ' # see man pages fstab (5),  findfs (8),  mount (8)  and/or blkid (8)  for more info#uuid= 8306bbdb-4c6b-4975-8596-c3721eeb6998  /            ext4    defaults        1 1uuid= 4bfd1d98-b114-4685-84a0-d44130fb3128  /boot       ext4     defaults        1 2uuid= 86be1f1b-e7b0-4d86-a743-7cc99ba332ec  /home       ext4     defaults        1 2uuid=cc4474b4-402e-4e99-9b04-f55327d94faa  /usr         ext4    defaults        1 2uuid= f885b330-d561-454f-90d2-259c4a81a5f9  swap        swap     defaults        0 0

Each row in the/etc/fstab file defines a file system

There are 6 fields per line:

Device to mount or pseudo file system mount point file System type Mount options dump frequency self-test order

The device to Mount

Device name/dev/sda5, uuid=, label=, pseudo file system name

Mount point:

Directory

File system type:

EXT2/EXT3/EXT4, XFS ...

Mount Options:

Defaults,rw/ro, Nouser,async/sync, Auto/noauto ...

Dump frequency:

0 means no backup.

1 represents a daily dump operation

2 represents a dump operation on an irregular basis

Self-Test order: fsck Inspection Sector

0 indicates no self-test

1 indicates the earliest self-test

2 lower priority than 1

Example:

#编辑  /ETC/FSTAB[[EMAIL PROTECTED] ~]# VIM /ETC/FSTAB    /DEV/SDB1      /mnt/test3         ext4     defaults        0 0#  Mount    [[email  protected] ~]# mount -a# View [[email protected] ~]# dffilesystem      1k-blocks    used available use% mounted on/dev/sda3         9947976  554736   8864856    6% /devtmpfs          493016        0    493016   0% /dev...../dev/sdb1          999320    2564     927944   1% /mnt/test3 


/etc/mtab file:

Record the file system that the current system has mounted, including the virtual files created by the operating system;

[[email protected] ~]# cat /etc/mtabrootfs /  rootfs rw 0 0proc /proc proc rw,nosuid,nodev,noexec,relatime 0  0sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0devtmpfs /dev  devtmpfs rw,seclabel,nosuid,size=493016k,nr_inodes=123254,mode=755 0 0securityfs / Sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0tmpfs /dev/shm  tmpfs rw,seclabel,nosuid,nodev 0 0devpts /dev/pts devpts rw,seclabel, Nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0tmpfs /run tmpfs rw,seclabel, Nosuid,nodev,mode=755 0 0tmpfs /sys/fs/cgroup tmpfs rw,seclabel,nosuid,nodev,noexec, Mode=755 0 0 .... 

When mount Mount partition, Umount unload partition, will be real-time update mtab,mtab always maintain the current system mounted partition information, FDISK, DF Such programs, must read the mTAB file, in order to obtain the current system in the partition mount situation. You can also get the current mount information by reading/proc/mount.


If there is any mistake, please correct me!

Thank you!

Linux disk and File System Management (3) _ Disk Mount Offload

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.