Centos下无法格式化硬盘/dev/sd* is apparently in use by the system; will not make a filesystem here!

本文介绍了解决Linux系统中新数据磁盘因残留LVM信息而无法格式化的问题。通过删除dm信息并重新检查磁盘状态,最终成功完成磁盘的格式化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境说明

Centos 6.8

问题说明

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

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

[root@ovirt-host ~]# fdisk -l


Disk /dev/sda: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x000d16e8


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         131     1048576   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             131        4211    32768000   82  Linux swap / Solaris
/dev/sda3            4211      121535   942406656   83  Linux


Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x000a65a6


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      121534   976221823+  83  Linux


Disk /dev/mapper/3600508e00000000017cd3aa6870c460a: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x000a65a6


                                        Device Boot      Start         End      Blocks   Id  System
/dev/mapper/3600508e00000000017cd3aa6870c460ap1               1      121534   976221823+  83  Linux


对sdb1进行格式化,无法进行格式化,提示如下
[root@ovirt-host ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
/dev/sdb1 is apparently in use by the system; will not make a filesystem here!

解决方法

通过dm解决问题,查看dm状态,显示dm设备信息
[root@ovirt-host ~]# dmsetup status
3600508e00000000017cd3aa6870c460a: 0 1952448512 multipath 2 0 0 0 1 1 A 0 1 0 8:16 A 0 

删除dm信息,并再次查看dm状态信息
[root@ovirt-host ~]# dmsetup remove_all
[root@ovirt-host ~]# dmsetup status
No devices found

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

[root@ovirt-host ~]# fdisk -l;

Disk /dev/sda: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x000d16e8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         131     1048576   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             131        4211    32768000   82  Linux swap / Solaris
/dev/sda3            4211      121535   942406656   83  Linux

Disk /dev/sdb: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x000a65a6

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      121534   976221823+  83  Linux

此时在对sdb1进行格式化操作

[root@ovirt-host ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=256    agcount=4, agsize=61013864 blks
         =                       sectsz=512   attr=2, projid32bit=0
data     =                       bsize=4096   blocks=244055455, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=119167, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0




当你看到这个错误提示 "xfs_growfs: /dev/mapper/centos-home is not a mounted XFS filesystem",它意味着你尝试使用 `xfs_growfs` 工具扩展名为 `/dev/mapper/centos-home` 的文件系统,但是该文件系统并没有被挂载并且不是 XFS 格式(Xtreme File System,一种日志文件系统,常见于Linux)。XFS 文件系统通常用于Linux的根目录、/home或其他特定分区。 解决这个问题需要按照以下步骤操作: 1. 首先,确认该设备是否已经挂载到 `/home` 或者指定路径。可以运行 `mount` 命令查看当前挂载点信息。 ``` mount | grep centos-home ``` 2. 如果没找到挂载信息,则可能是文件系统的名称不对或者是已经被卸载。检查 `/etc/fstab` 中关于 `/dev/mapper/centos-home` 的配置,确认其正确的挂载路径和选项。 3. 使用 `lsblk` 查看 `/dev/mapper/centos-home` 是否存在,以及它的状态是否正常。 4. 确认该设备是否为XFS文件系统,可以使用 `file -s /dev/mapper/centos-home` 来检查。 5. 如果文件系统未挂载并且确实是XFS格式,你需要将其挂载,然后才能增长空间。例如,如果应该挂载到 `/home`: ``` mount /dev/mapper/centos-home /home ``` 6. 接着运行 `xfs_growfs /dev/mapper/centos-home` 来增加文件系统的大小。 7. 操作完毕后别忘了检查文件系统是否成功扩展。 如果你发现上述步骤有问题,建议查阅更详细的Linux系统管理文档或者寻求专业人员的帮助。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值