Linux disk Mount

Source: Internet
Author: User

The Mount command is used to load the file system to the specified mount point. The most common use of this command is to mount the CDROM so that we can access the data in the CDROM because you insert the disc into the CDROM, Linux does not mount automatically, and you must manually complete the mount using the Linux mount command. After the disk format is completed, it needs to be mounted before it can be used. Before you mount a partition, you need to set up a mount point, which appears in the form of a directory. Once a partition is attached to the mount point (directory), it will be written to this directory when it is written to it.Note: Before the disk mounts the partition, the mount point must be an empty directory, because after the disk is mounted, it will not be visible until the partition is unloaded. Note: If there are multiple disks on one server, the UUID is preferred when mounting, avoiding the change of disk partition name after hardware repair replacing the disk location and affecting system startup. Options:-V: Displays the program version;-L: Displays the list of loaded file systems;-H: Displays help information and exits;-V: Verbose mode, output instruction execution details;-N: Load file system not written to file "/etc/mtab";-r: Load file system as read-only mode ;-A: Loads all file systems described in the file "/etc/fstab". Format entire disk without partitioning [email protected] ~]# Fdisk/dev/sdb#删除所有分区Welcome to Fdisk (Util-linux 2.23.2).  changes would remain in memory only, until the decide to write them. Be careful before using the write Command. command (M for help): p     #列出分区  disk/dev/sdb:1 0.7 GB, 10737418240 bytes, 20971520 sectorsunits = sectors of 1 * = bytessector size (logical/physical): bytes /bytesi/o Size (minimum/optimal): bytes/512 bytesdisk label Type:dosdisk IDENTIFIER:0X189FC246&NBSP;&NBSP;&N Bsp; device boot      start          End      Blocks   Id  System/dev/sdb1             2048     4196351      2097152   83  linux command (M for help): d      #删除分区Selected partition 1Partition 1 is deletedcommand (M-help): w    #保存退出The partition table has been altered! calling ioctl () to re-read partition table. Syncing disks. [[email protected] ~]# fdisk-l/dev/sdb   #查看磁盘的情况, at this time found that there is no partition  disk/dev/sdb:10.7 GB, 10737418240 bytes, 20971520 sectorsunits = sectors of 1 * MB = bytessector size (logical/physical): bytes/512 b YTESI/O size (minimum/optimal): bytes/512 bytesdisk label Type:dosdisk Identifier:0x189fc246   &nbs P;device Boot      start         end       blocks   id  system [[email protected] ~ ]# mkfs.xfs-f/dev/sdb  #格式化为xfs文件系统; since it has been formatted once, formatting now requires the-F option to force the formatting of the meta-data=/dev/sdb                isize=512    agcount=4, agsize=655360 blks          =                        sectsz=512   attr=2, projid32bit=1          =                        crc=1         finobt=0, sparse=0data     =                        bsize=4096    blocks=2621440, imaxpct=25         =                        sunit=0       swidth=0 blksnaming   =version 2               bsize=4096   ascii-ci=0 ftype=1log       =internal log            bsize=4096   blocks=2560, version=2         =                         sectsz=512   sunit=0 Blks, Lazy-count=1realtime =none                    extsz=4096    blocks=0, rtextents=0[[email protected] ~]# blkid/dev/sdb#使用blkid命令查看磁盘的文件系统/dev/sdb:uuid= "2e36a530-168e-47cf-8e0d-659aaa606840" type= "XFS" [[email protected] ~]# df-h#查看分区情况filesystem      size  used Avail use% Mounted on/dev/sda2         44g  1.6g   43g   4%/DEVTMPFS         1.9G     0  1.9G    0%/devtmpfs           1.9g      0  1.9g   0%/dev/shmtmpfs            1.9g  8.5m  1.9g   1%/runtmpfs            1.9G     0  1.9G    0%/sys/fs/cgroup/dev/sda5      1014m   33m   982m   4%/home/dev/sda1      1014m  135m   880m  14%/BOOTTMPFS           378M     0   378m   0%/run/user/0[[email protected] ~]# mount/dev/sdb/mnt/   #用法mount [Options]< Drive >< mount points >[Email protected] ~]# df-h#可以看到最后一列已经成功挂载, the/mnt mount point is like a disk entry, and no mount point can write data on the disk. filesystem      size  used Avail use% Mounted on/dev/sda2         44g  1.6g   43g   4%/DEVTMPFS         1.9G     0  1.9G    0%/devtmpfs           1.9g      0  1.9g   0%/dev/shmtmpfs            1.9g  8.5m  1.9g   1%/runtmpfs            1.9G     0  1.9G    0%/sys/fs/cgroup/dev/sda5      1014m   33m   982m   4%/home/dev/sda1      1014m  135m   880m  14%/BOOTTMPFS           378M     0   378m   0%/run/user/0/dev/sdb         10g    33m   10g   1%/mnt How to uninstall it? [[email protected] mnt]# umount/dev/sdb   #它会提示卸载不了, the target is busy. The reason is that we are in it disk. Umount:/mnt:target is busy. (In some cases useful info about processes, use the device are found by lsof (8) or fuser (1)) There are two workaround 1, exit mount point [E Mail protected] ~]# umount/dev/sdb2, add a-l option [[email protected] ~]# mount/dev/sdb/mnt/[[email protected] ~]# Cd/mnt/[[em AIL protected] mnt]# umount-l/dev/sdb[[email protected] ~]# man mount#查帮助, the meaning of common options. Async/sync: Whether the disk and memory are synchronized, default async is out of sync, Auto/noauto: Auto mount/not auto mount; default: Sets the mount definition by default for most permanent file systems, including Rw,suid,dev,exec,auto    , Nouser,async ro: Mount RW by Read-only permission: Mount Exec/noexec by Read and Write permissions: Allow/disallow executable execution, never mount the root partition as noexec. User/nouser: Allow/Disallow root other users to mount the partition, for security purposes, use Nouser Suid/nosuid: Allow/Disallow partition has SUID attribute, general settings Nosuid Usrquota: Start Consumer disk quota mode, Limit their usage to users Grquota: Start the group disk quota mode to re-mount the disk [[email protected] ~]# mount-o remount,rw/dev/sdb/mnt/[[email protected] ~]# Vim/etc/fstab#如果想要开机自动挂载, you need to write on the/etc/fstab configuration file# #/etc/fstab# Created by Anaconda on Tue the 23:23:48 2018## Accessible filesystems, by reference, is maintained Unde R '/dev/disk ' # See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info#uuid=0a548611-1d43-47bd-af8b-73c6 2b4efc9b/                        xfs     defaults         0 0uuid=a20b1f54-71d4-455b-a1e3-5d5e04310479/boot                    xfs      defaults        0 0uuid=50bcd687-ca95-491c-b987-346bb77a4364/home                     xfs     defaults        0 0UUID=51EFDC5D-8C12-4299-A7E9-D963E8D5361A swap                     swap    defaults         0 0/dev/sdb        /mnt     Xfs     defaults        0 0 #dev/sdb: Table of Contents and UUID function #/mnt: Mount point #xfs: File system type #defaults: Default Options #第一个0: Whether to back up. 0 means no backup; #第二个0: Boot does not need to detect the disk is 0, need to detect the disk, the root partition is 1, the other is 2[Email protected] ~]# BlkidThe role of #/dev/sdb and UUID mounts is the same. Can be written to the first column of the/etc/fstab configuration file. /dev/sdb:uuid= "2e36a530-168e-47cf-8e0d-659aaa606840" type= "XFS"/dev/sda1:uuid= " a20b1f54-71d4-455b-a1e3-5d5e04310479 "type=" XFS "/dev/sda2:uuid=" 0a548611-1d43-47bd-af8b-73c62b4efc9b "TYPE=" XFS " /dev/sda3:uuid= "51efdc5d-8c12-4299-a7e9-d963e8d5361a" type= "swap"/dev/sda5:uuid= " 50bcd687-ca95-491c-b987-346bb77a4364 "type=" XFS "/dev/sr0:uuid=" 2017-09-06-10-51-00-00 "LABEL=" CentOS 7 x86_64 "TYPE = "iso9660" pttype= "DOS" [[email protected] ~]# mount Uuid= "2e36a530-168e-47cf-8e0d-659aaa606840"/mnt/[email protected] ~]# df-htFilesystem Type Size used Avail use% mounted on/dev/sda2 xfs 44G 1.6G 43G 4%/Devtmpfs devtmpfs 1.9G 0 1.9G 0%/devTmpfs tmpfs 1.9G 0 1.9G 0%/dev/shmtmpfs tmpfs 1.9G 8.5M 1.9G 1%/runTmpfs tmpfs 1.9G 0 1.9G 0%/sys/fs/cgroup/dev/sda5 xfs 1014M 33M 982M 4% /Home/dev/sda1 xfs 1014M 135M 880M 14%/bootTmpfs tmpfs 378M 0 378M 0%/run/user/0/dev/sdb xfs 10G 33M 10G 1%/mnt

Linux disk Mount

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.