在 CentOS 6.9 底下新增一顆 SSD 進行建立簡單的 Partition, 正常只要透過 fdisk 與 mkfs 就可以輕鬆完成.. 但這次在 fdisk 之後, 執行 mkfs 卻出現 /dev/sda1 is apparently in use by the system; will not make a filesystem here!
1. 使用 fdisk -l 確認 partition 的狀態
[root@xpc-sh67-i7 ~]# fdisk -l /dev/sda
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe6d6b57b
Device Boot Start End Blocks Id System
/dev/sda1 1 30401 244196001 83 Linux
2. 看一下有哪些 dm partition
[root@xpc-sh67-i7 ~]# ls -lt /dev/dm-*
brw-rw---- 1 root disk 253, 0 2017-05-07 23:12 /dev/dm-0
brw-rw---- 1 root disk 253, 5 2017-05-07 23:01 /dev/dm-5
brw-rw---- 1 root disk 253, 6 2017-05-07 23:01 /dev/dm-6
brw-rw---- 1 root disk 253, 2 2017-05-07 23:01 /dev/dm-2
brw-rw---- 1 root disk 253, 1 2017-05-07 23:01 /dev/dm-1
3. 使用 lsblk 來確認 /dev/sda1 是否是在 dm-* 內
[root@xpc-sh67-i7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 931.5G 0 disk
├─sdb1 8:17 0 500M 0 part /boot
└─sdb2 8:18 0 931G 0 part
├─vg_xpcsh67i7-lv_root (dm-0) 253:0 0 50G 0 lvm /
├─vg_xpcsh67i7-lv_swap (dm-1) 253:1 0 7.8G 0 lvm [SWAP]
└─vg_xpcsh67i7-lv_home (dm-6) 253:6 0 873.2G 0 lvm /home
sdc 8:32 0 2.7T 0 disk
├─sdc1 8:33 0 2.7T 0 part
└─35000039ff4d50da5 (dm-2) 253:2 0 2.7T 0 mpath
└─35000039ff4d50da5p1 (dm-5) 253:5 0 2.7T 0 part /data
sda 8:0 0 232.9G 0 disk
└─sda1 8:1 0 232.9G 0 part /kvm
sdd 8:48 0 1.4T 0 disk
└─sdd1 8:49 0 1.4T 0 part
4. 再透過 dmsetup status 了解目前狀態
[root@xpc-sh67-i7 ~]# dmsetup status
vg_xpcsh67i7-lv_swap: 0 16367616 linear
vg_xpcsh67i7-lv_root: 0 104857600 linear
35000039ff4d50da5: 0 5860533168 multipath 2 0 0 0 1 1 A 0 1 0 8:32 A 0
vg_xpcsh67i7-lv_home: 0 1831264256 linear
35000039ff4d50da5p1: 0 5860530176 linear
5. 使用 dmsetup remove_all 來關閉
6. 使用 mkfs.ext4 /dev/sda1 就可以開始格式化
7. 修改 /etc/multipath.conf 避免重開機後再次被納入 multipath
vi /etc/multipath.conf
# RHEV REVISION 1.0
#defaults {
# polling_interval 5
# getuid_callout "/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/%n"
# no_path_retry fail
# user_friendly_names no
# flush_on_last_del yes
# fast_io_fail_tmo 5
# dev_loss_tmo 30
# max_fds 4096
#}
devices {
device {
vendor "HITACHI"
product "DF.*"
getuid_callout "/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/%n"
}
device {
vendor "COMPELNT"
product "Compellent Vol"
no_path_retry fail
}
}
blacklist {
devnode "*"
}