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\ro
mount -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基础笔记19】,磁盘分区
【CentOS 7基础笔记20】,磁盘格式化
【CentOS 7基础笔记21】,磁盘挂载
【CentOS 7基础笔记22】,手动增加Swap空间
【CentOS 7基础笔记23】, Logical Volume Manager逻辑卷管理
修改于 171103