一、磁盤查看
查看所有磁盤
ll /dev/sd*
不帶數字的為磁盤,帶數字的為磁盤的分區
查看所有磁盤的分區情況
fdisk -l
結果

WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes, 1953525168 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: gpt # Start End Size Type Name 1 2048 1953525134 931.5G unknown ceph data WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes, 1953525168 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: gpt # Start End Size Type Name 1 2048 1953525134 931.5G unknown ceph data Disk /dev/sda: 300.0 GB, 300000000000 bytes, 585937500 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: 0x000de82e Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 585936895 292455424 8e Linux LVM WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sde: 1000.2 GB, 1000204886016 bytes, 1953525168 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: gpt # Start End Size Type Name 1 2048 1953525134 931.5G unknown ceph data WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdb: 300.0 GB, 300000000000 bytes, 585937500 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: gpt # Start End Size Type Name 1 2048 62916607 30G unknown ceph journal 2 62916608 125831167 30G unknown ceph journal 3 125831168 188745727 30G unknown ceph journal Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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 /dev/mapper/centos-swap: 30.0 GB, 30001856512 bytes, 58597376 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 /dev/mapper/centos-home: 215.7 GB, 215721443328 bytes, 421330944 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
二、磁盤分區
連接磁盤硬件 -> 對磁盤分區 -> 對分區進行格式化 -> 掛載分區到目錄 -> 使用
https://blog.51cto.com/yueyue207/2072255
# 對指定磁盤操作 fdisk /dev/sdc # 顯示幫助 m # 顯示已有分區 p # 刪除分區,只有1個分區時,會自動刪除已有分區,不用選擇 d # 創建新的分區 n
# 保存分區
w
# 退出不保存
q
三、磁盤格式化
mkfs -t xfs -f /dev/sdb1
四、磁盤掛載
查看掛載情況
# 或 lsblk
lsblk -f
掛載已格式化的磁盤分區
# 創建目錄 mkdir /home/data2 # 掛載磁盤到該目錄 mount /dev/sdd1 /home/data2/ # 卸載 umount /dev/sdd1
開機自動掛載
# 最后一行為新增掛載 vim /etc/fstab # # /etc/fstab # Created by anaconda on Fri May 17 02:12:54 2019 # # 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 # /dev/mapper/centos-root / xfs defaults 0 0 UUID=80774ba5-c734-40b3-90ec-5817bd434ce8 /boot xfs defaults 0 0 /dev/mapper/centos-home /home xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 /dev/sdc1 /home/data xfs defaults 0 0
五、已掛載磁盤查看
查看已掛載磁盤使用情況
df -h
查看目錄占用容量