磁盘挂载

查看已挂载磁盘数

  1. cat /proc/scsi/scsi | grep Host
  2. //or
  3. ll /dev/disk/by-path | grep -v part

判断磁盘名

  1. ll /dev/disk/by-path

删除/dev/sdb所以分区

  1. fdisk /dev/sdb
  2. Command (m for help): p(查看当前分区状态)
  3. Command (m for help): d(删除分区)
  4. Partition number (1-3): 3(选择要删除的分区)
  5. Command (m for help): d(删除分区)
  6. Partition number (1-2): 2(选择要删除的分区)
  7. Command (m for help): d(因为只剩下一个分区,无需选择)
  8. Command (m for help): p(查看当前分区状态)
  9. Command (m for help): w(会车保存新的分区)

格式化磁盘

  1. fdisk /dev/sdb
  2. Command (m for help): n(会车新建分区)
  3. p primary partition(1-4): p(会车新建分区号)
  4. Partition number(1-4): 1(分区号1-4之间选择1)
  5. First cylinde(2048-xxxx,default 2048)
  6. Last cylinder(2048-xxxx,default xxxxx)
  7. Command (m for help): p(查看当前分区状态)
  8. Command (m for help): w(会车保存新的分区)

如果提示“Partition table entries are not in disk order”则执行

  1. fdisk /dev/sdb
  2. Command (m for help): x(进入专家模式)
  3. Command (m for help): f(修复分区表)
  4. Command (m for help): p(查看当前分区状态)
  5. Command (m for help): w(会车保存新的分区)

创建磁盘分区

  1. mkfs.ext4 /dev/sdb1
  2. Writing superblocks and filesystem accounting information:(回车)

挂载分区中的磁盘到目录/file1

  1. mkdir /file1
  2. mount /dev/sdb1/file1

将挂载信息写入fstab,让系统自动挂载

  1. echo "/dev/sdb1 /file1 ext4 default 0 0" >> /etc/fstab

查看挂载情况

  1. cat /etc/fstab

取消挂载

安装psmisc

  1. yum install psmisc -y

取消目录占用

  1. fuser -k /file1
  2. fuser -k /dev/sdb1

取消挂载点

  1. umount /file1
  2. umount /dev/sdb1

删除/dev/sdb1所以分区
fdisk /dev/sdb1
…如上