磁盘挂载
查看已挂载磁盘数
cat /proc/scsi/scsi | grep Host
//or
ll /dev/disk/by-path | grep -v part
判断磁盘名
ll /dev/disk/by-path
删除/dev/sdb所以分区
fdisk /dev/sdb
Command (m for help): p(查看当前分区状态)
Command (m for help): d(删除分区)
Partition number (1-3): 3(选择要删除的分区)
Command (m for help): d(删除分区)
Partition number (1-2): 2(选择要删除的分区)
Command (m for help): d(因为只剩下一个分区,无需选择)
Command (m for help): p(查看当前分区状态)
Command (m for help): w(会车保存新的分区)
格式化磁盘
fdisk /dev/sdb
Command (m for help): n(会车新建分区)
p primary partition(1-4): p(会车新建分区号)
Partition number(1-4): 1(分区号1-4之间选择1)
First cylinde(2048-xxxx,default 2048)
Last cylinder(2048-xxxx,default xxxxx)
Command (m for help): p(查看当前分区状态)
Command (m for help): w(会车保存新的分区)
如果提示“Partition table entries are not in disk order”则执行
fdisk /dev/sdb
Command (m for help): x(进入专家模式)
Command (m for help): f(修复分区表)
Command (m for help): p(查看当前分区状态)
Command (m for help): w(会车保存新的分区)
创建磁盘分区
mkfs.ext4 /dev/sdb1
Writing superblocks and filesystem accounting information:(回车)
挂载分区中的磁盘到目录/file1
mkdir /file1
mount /dev/sdb1/file1
将挂载信息写入fstab,让系统自动挂载
echo "/dev/sdb1 /file1 ext4 default 0 0" >> /etc/fstab
查看挂载情况
cat /etc/fstab
取消挂载
安装psmisc
yum install psmisc -y
取消目录占用
fuser -k /file1
fuser -k /dev/sdb1
取消挂载点
umount /file1
umount /dev/sdb1
删除/dev/sdb1所以分区
fdisk /dev/sdb1
…如上