ubuntu18.04磁盘格式化被占用

问题说明

新装的Linux系统,两块硬盘,一块作为系统磁盘,另一块作为数据磁盘,安装完系统后,由于该数据磁盘中包含之前残余的LVM信息,无法对数据磁盘无法进行操作。

新系统启动后,通过fdisk -l查看磁盘信息如下

Disk /dev/sda: 10.7 TiB, 11756399230976 bytes, 22961717248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 05120572-BCE8-4A9B-ABB0-492A152E43F2
....
....

Disk /dev/mapper/ars--vg-root: 10.7 TiB, 11754843144192 bytes, 22958678016 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/ars--vg-swap_1: 968 MiB, 1015021568 bytes, 1982464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes



root@hos:/home/ars# ll /dev/sd*
brw-rw---- 1 root disk 8,   0 Jan  7 08:33 /dev/sda
brw-rw---- 1 root disk 8,   2 Jan  7 08:33 /dev/sda2
brw-rw---- 1 root disk 8,  16 Jan  7 08:13 /dev/sdb
brw-rw---- 1 root disk 8,  32 Jan  7 08:13 /dev/sdc
brw-rw---- 1 root disk 8,  48 Jan  7 08:13 /dev/sdd
brw-rw---- 1 root disk 8,  64 Jan  7 08:13 /dev/sde
brw-rw---- 1 root disk 8,  80 Jan  7 08:13 /dev/sdf
brw-rw---- 1 root disk 8,  96 Jan  7 08:13 /dev/sdg
brw-rw---- 1 root disk 8, 112 Jan  7 08:13 /dev/sdh
brw-rw---- 1 root disk 8, 128 Jan  7 08:13 /dev/sdi
brw-rw---- 1 root disk 8, 144 Jan  7 08:13 /dev/sdj
brw-rw---- 1 root disk 8, 160 Jan  7 08:13 /dev/sdk
brw-rw---- 1 root disk 8, 176 Jan  7 08:13 /dev/sdl
brw-rw---- 1 root disk 8, 192 Jan  7 08:13 /dev/sdm
brw-rw---- 1 root disk 8, 193 Jan  7 08:13 /dev/sdm1
brw-rw---- 1 root disk 8, 194 Jan  7 08:13 /dev/sdm2

对sdb1进行格式化,无法进行格式化,提示如下

[root@ovirt-host ~]# mkfs.ext4 /dev/sda
mke2fs 1.41.12 (17-May-2010)
/dev/sda is apparently in use by the system; will not make a filesystem here!

解决方法

通过dm解决问题,查看dm状态,显示dm设备信息

root@hos:/home/ars# dmsetup status
ars--vg-swap_1: 0 1982464 linear
ars--vg-root: 0 22958678016 linear 

删除dm信息,并再次查看dm状态信息

[root@ovirt-host ~]# dmsetup remove_all
[root@ovirt-host ~]# dmsetup status
No devices found

此次dm已经找不到设备,再次通过fdisk查看磁盘信息,已经没有dm设备信息了

Disk /dev/sda: 10.7 TiB, 11756399230976 bytes, 22961717248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 05120572-BCE8-4A9B-ABB0-492A152E43F2
....
....

然后进行格式化


   转载规则


《ubuntu18.04磁盘格式化被占用》 bill 采用 知识共享署名 4.0 国际许可协议 进行许可。
  目录