Loading... # Ubuntu中格式化磁盘提示disk is busy的一种解决思路 > 本文中提到的解决办法是有关与`mdadm`有关的。 ## 问题现象: ``` root@hulk-test:~# mkfs -t ext4 /dev/sdd1 mke2fs 1.44.1 (24-Mar-2018) /dev/sdd1 contains a linux_raid_member file system labelled 'hulk-test:0' Proceed anyway? (y,N) y /dev/sdd1 is apparently in use by the system; will not make a filesystem here! root@hulk-test:~# parted -s /dev/nvme0n1 mklabel gpt Error: Could not stat device /dev/nvme0n1 - No such file or directory. root@hulk-test:~# parted -s /dev/sdd1 mklabel gpt Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/sdd1 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. ``` 类似于这种,因为我这是在远程复现,没法完全模拟实际情况,我大致介绍一下我当时的情况,硬盘被用于ubuntu的software raid,然后其中一块或者几块被拿来使用,直接挂载在系统里面做存储,或者安装系统,在做存储时,需要格式化并挂载,就会提示disk is busy,在装系统的时候,如果它的默认排序比正常要靠前,那么系统安装器会一直报错。又不知道怎么解决。下面介绍的方法都可以解决。 ## 确认问题以及解决问题: #### 确认问题 通过查看`/proc/mdstat`文件确认software raid磁盘导致。 ``` root@hulk-test:~# cat /proc/mdstat Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md0 : active raid0 sde1[1] sdd1[0] 999948288 blocks super 1.2 512k chunks unused devices: <none> ``` #### 解决问题 ``` mdadm -S /dev/md0 mdadm --misc --zero-superblock /dev/sdd #################################################################### root@hulk-test:~# mdadm -S /dev/md0 mdadm: stopped /dev/md0 root@hulk-test:~# mdadm --misc --zero-superblock /dev/sdd mdadm: Unrecognised md component device - /dev/sdd root@hulk-test:~# fdisk /dev/sdd Welcome to fdisk (util-linux 2.31.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Selected partition 1 Partition 1 has been deleted. Command (m for help): Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. ``` 同时还要处理两个文件,删除与md相关的信息 ,分别是fstab的挂载信息和mdadm.conf的DEVICE和ARRAY行 ``` vi /etc/mdadm/mdadm.conf vi /etc/fstab ##################################################################### root@hulk-test:~# cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda2 during curtin installation /dev/disk/by-uuid/ee2c479f-173e-431a-a4f2-bbef0cf9697f / ext4 defaults 0 0 # /boot/efi was on /dev/sda1 during curtin installation /dev/disk/by-uuid/5C61-43E2 /boot/efi vfat defaults 0 0 /swap.img none swap sw 0 0 ################################################ root@hulk-test:~# cat /etc/mdadm/mdadm.conf # mdadm.conf # # !NB! Run update-initramfs -u after updating this file. # !NB! This will ensure that initramfs has an uptodate copy. # # Please refer to mdadm.conf(5) for information about this file. # # by default (built-in), scan all partitions (/proc/partitions) and all # containers for MD superblocks. alternatively, specify devices to scan, using # wildcards if desired. #DEVICE partitions containers # automatically tag new arrays as belonging to the local system HOMEHOST <system> # instruct the monitoring daemon where to send mail alerts MAILADDR root # definitions of existing MD arrays # This configuration was auto-generated on Thu, 06 Aug 2020 22:39:44 +0000 by mkconf ``` 到这一步就完成了,该对硬盘怎么操作就看实际需求了。 ## Ubuntu安装过程中遇到这个情况怎么办 再安装Ubuntu过程中其实是可以调出commad line的,直接按一下F2,然后重复上面操作就好了。 Last modification:December 27, 2020 © Allow specification reprint Like 0 If you think my article is useful to you, please feel free to appreciate