博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【CentOS 7笔记21】,磁盘挂载#171103
阅读量:6601 次
发布时间:2019-06-24

本文共 5175 字,大约阅读时间需要 17 分钟。

hot3.png

hellopasswd


不进行分区直接格式化

[root@localhost ~]# fdisk -l /dev/sdb	Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors	Units = sectors of 1 * 512 = 512 bytes	Sector size (logical/physical): 512 bytes / 512 bytes	I/O size (minimum/optimal): 512 bytes / 512 bytes	Disk label type: dos	Disk identifier: 0xa8f0c23e	   Device Boot      Start         End      Blocks   Id  System[root@localhost ~]# mkfs.xfs /dev/sdb	mkfs.xfs: /dev/sdb appears to contain a partition table (dos).	mkfs.xfs: Use the -f option to force overwrite.[root@localhost ~]# mkfs.xfs -f /dev/sdb	meta-data=/dev/sdb               isize=256    agcount=4, agsize=655360 blks	         =                       sectsz=512   attr=2, projid32bit=1	         =                       crc=0	data     =                       bsize=4096   blocks=2621440, imaxpct=25	         =                       sunit=0      swidth=0 blks	naming   =version 2              bsize=4096   ascii-ci=0 ftype=0	log      =internal log           bsize=4096   blocks=2560, version=2	         =                       sectsz=512   sunit=0 blks, lazy-count=1	realtime =none                   extsz=4096   blocks=0, rtextents=0[root@localhost ~]# blkid /dev/sdb	/dev/sdb: UUID="ad9ebef7-36c8-4395-a697-ffd8ae481541" TYPE="xfs"

格式化分区的目的是为了挂载文件系统,Linux要想访问磁盘必须挂载挂载点,挂载点其实就是一个目录

mount挂载

[root@localhost ~]# mount /dev/sdb /mnt/[root@localhost ~]# df -h	Filesystem      Size  Used Avail Use% Mounted on	/dev/sda3        28G  848M   27G   3% /	devtmpfs        909M     0  909M   0% /dev	tmpfs           914M     0  914M   0% /dev/shm	tmpfs           914M  8.5M  905M   1% /run	tmpfs           914M     0  914M   0% /sys/fs/cgroup	/dev/sda1       197M   75M  123M  38% /boot	/dev/sdb         10G   33M   10G   1% /mnt[root@localhost ~]# mount | grep /dev/sd	/dev/sda3 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)	/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)	/dev/sdb on /mnt type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

umount卸载

[root@localhost ~]# cd /mnt/[root@localhost mnt]# ls[root@localhost mnt]# ls[root@localhost mnt]# touch 1.txt 2.txt[root@localhost mnt]# mkdir 111[root@localhost mnt]# ls	111  1.txt  2.txt[root@localhost mnt]# umount /dev/sdb	umount: /mnt: target is busy.	        (In some cases useful info about processes that use	         the device is found by lsof(8) or fuser(1))[root@localhost mnt]# pwd	/mnt

当前在/mnt/目录中,必须退出当前目录才可以继续umount

[root@localhost mnt]# cd[root@localhost ~]# umount /dev/sdb[root@localhost ~]# df -h	Filesystem      Size  Used Avail Use% Mounted on	/dev/sda3        28G  846M   27G   3% /	devtmpfs        909M     0  909M   0% /dev	tmpfs           914M     0  914M   0% /dev/shm	tmpfs           914M  8.5M  905M   1% /run	tmpfs           914M     0  914M   0% /sys/fs/cgroup	/dev/sda1       197M   75M  123M  38% /boot

当继续挂载目录,

[root@localhost ~]# mount /dev/sdb /mnt/[root@localhost ~]# cd /mnt[root@localhost mnt]# ls	111  1.txt  2.txt

umount -l可以不用退出当前目录,便可以直接umount

[root@localhost mnt]# umount /dev/sdb	umount: /mnt: target is busy.	        (In some cases useful info about processes that use	         the device is found by lsof(8) or fuser(1))[root@localhost mnt]# umount -l /dev/sdb[root@localhost mnt]# df -h	Filesystem      Size  Used Avail Use% Mounted on	/dev/sda3        28G  846M   27G   3% /	devtmpfs        909M     0  909M   0% /dev	tmpfs           914M     0  914M   0% /dev/shm	tmpfs           914M  8.5M  905M   1% /run	tmpfs           914M     0  914M   0% /sys/fs/cgroup	/dev/sda1       197M   75M  123M  38% /boot

常用

mount -o rw\romount -o remount	#重新挂载

系统启动默认挂载的磁盘

[root@localhost mnt]# vi /etc/fstab		#	# /etc/fstab	# Created by anaconda on Tue Oct 17 21:12:03 2017	#	# 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=915e2a85-8d48-4667-9001-eae59adccb98 /                       xfs     defaults        1 1	UUID=f50883db-5558-4813-8053-67e97169c609 /boot                   xfs     defaults        1 2	UUID=d0344494-65f1-4279-a595-76801470be33 swap                    swap    defaults        0 0

系统启动默认挂载哪个磁盘哪个分区 第一列设备的设备号,第二列为挂载点,第三列为分区格式,第四列为挂载选项,第五列为是否备份,第六列为优先级1 这里可以写分区号,也可以写UUID,而UUID可以通过blkid查看

[root@localhost mnt]# blkid	/dev/sr0: UUID="2017-10-27-14-49-48-00" LABEL="20171027_144209" TYPE="iso9660" 	/dev/sda1: UUID="f50883db-5558-4813-8053-67e97169c609" TYPE="xfs" 	/dev/sda2: UUID="d0344494-65f1-4279-a595-76801470be33" TYPE="swap" 	/dev/sda3: UUID="915e2a85-8d48-4667-9001-eae59adccb98" TYPE="xfs" 	/dev/sdb: UUID="ad9ebef7-36c8-4395-a697-ffd8ae481541" TYPE="xfs" [root@localhost mnt]# mount UUID="ad9ebef7-36c8-4395-a697-ffd8ae481541" /mnt/[root@localhost mnt]# df -h	Filesystem      Size  Used Avail Use% Mounted on	/dev/sda3        28G  846M   27G   3% /	devtmpfs        909M     0  909M   0% /dev	tmpfs           914M     0  914M   0% /dev/shm	tmpfs           914M  8.5M  905M   1% /run	tmpfs           914M     0  914M   0% /sys/fs/cgroup	/dev/sda1       197M   75M  123M  38% /boot	/dev/sdb         10G   33M   10G   1% /mnt

【CentOS 7基础笔记21】,磁盘挂载
修改于 171103

转载于:https://my.oschina.net/hellopasswd/blog/1560650

你可能感兴趣的文章
Java 反射机制
查看>>
Unity 碰撞检测中碰撞器与触发器的区别
查看>>
Elasticsearch配置文件说明
查看>>
路由表的构成
查看>>
初识java
查看>>
053(五十九)
查看>>
temporary Object and destructor
查看>>
(十)常用类库----数值类、字符串类
查看>>
node-gyp错误及解决办法
查看>>
xcode - 移动手势
查看>>
本地上jar命令
查看>>
简单写一下图片上传获取宽高的方法
查看>>
细说浏览器特性检测(1)-jQuery1.4添加部分
查看>>
打包如何打包额外文件,比如Sqlite数据库的db文件
查看>>
laravel
查看>>
古中国数学家的计算力真是惊人
查看>>
XMl各种格式转换功能代码
查看>>
Java基础-算术运算符(Arithmetic Operators)
查看>>
XML 基础
查看>>
C#编程(四十七)----------集合接口和类型
查看>>