hellopasswdnode
[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要想訪問磁盤必須掛載掛載點,掛載點其實就是一個目錄app
[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)
[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/目錄中,必須退出當前目錄才能夠繼續umountide
[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
當繼續掛載目錄,.net
[root@localhost ~]# mount /dev/sdb /mnt/ [root@localhost ~]# cd /mnt [root@localhost mnt]# ls 111 1.txt 2.txt
umount -l能夠不用退出當前目錄,即可以直接umount3d
[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查看code
[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邏輯卷管理
修改於 171103blog