Get rid of "Resource Busy" message on Mac OS X
I am trying to repair a lost HSF+
partition table an iMac by running the i
command inside of sudo pdisk /dev/rdisk1
. Once I try running the i
command, I get an error message saying that the resource is busy:
pdisk: can't open file '/dev/rdisk1' for writing (Resource busy)
I get the same result when using /dev/disk1
, /dev/rdisk2
, and /dev/disk2
.
I also tried running sudo gpt /dev/(r)disk(1-3)
. Interestingly enough, the I only get a result from /dev/rdisk3
:
So, I try to see what is using the resource by running sudo lsof /dev/rdisk1
, as well as sudo lsof /dev/disk1
. Nothing shows up:
I've also tried unmounting the device by running sudo umount /dev/disk1
as well as sudo umount /dev/rdisk1
. I get a message saying that the device is not currently mounted:
Here's a list of all of the disks connected to the computer, found by running sudo DiskUtil list
:
/dev/disk0 - The disk of the computer that the iMac is connected to.
/dev/disk1 - The HDD of the iMac.
/dev/disk2 - The SSD of the iMac.
/dev/disk3 - I don't know what this is. I would assume it is the combined HDD and SSD of the iMac.
/dev/disk4 - An external hard drive.
/dev/disk5 - I have no clue what this is either. Maybe utilities for /dev/disk4?
The iMac has a fusion drive, and /dev/disk1
is the HDD. I've tried with the SSD, /dev/disk2
, but I get the same result.
I have the iMac plugged into another computer via thunderbolt, and by holding t when the iMac started up, the Macintosh HD
showed up as an external device on the other computer.
How could I get rid of this message? I've tried restarting both the iMac and the computer that it is connected to.
Solution 1:
First off, the pdisk
command is used to modify drives that are partitioned using an Apple Partition Map. Only PowerPC-based Macs use those.
Secondly, your umount
commands above are failing because /dev/disk1 and /dev/disk2 are not mounted. Typically only partitions are mounted (e.g. /dev/disk0s3), although in your case, you have a Fusion Drive. You are absolutely correct that /dev/disk3 is not a 'real' disk. It is the combined capacity of /dev/disk1s2 and /dev/disk2s2. If you type umount /dev/disk3
, that should work. Of course, nothing is mounted on /dev/disk1 or /dev/disk2, so you will have to issue a diskutil unmountdisk /dev/diskN
for those. That should free them up so the gpt
command will stop giving you the resource busy error.
Fusion Drives use Apple CoreStorage partitions as containers, which is sort of analogous to Microsoft's Dynamic Disks. Unfortunately, they make manipulating the partitions more difficult, and take many disk/partition recovery products off the table.
However, aside from the issues above, I'm not exactly sure what the problem is. You mention that the partition table is lost, but the output from diskutil list
suggests your partition tables seem to be OK.
Can you elaborate a little more about the problem you were having?
Solution 2:
try this: diskutil unmountDisk force /dev/disk0 (or whatever your disk is)
Solution 3:
I had a similar issue to the OP so I thought I would share what I found. My scenario was different in that;
1) I had bought a brand new Sandisk 32GB
USB Stick which I needed to use on a different unix distro later. The USB came pre-formatted as they usually do, with the FAT
filesystem and some files for backup etc
2) I only have a Macbook Pro (MacOS 10.14.4)
to hand, but I needed to format the stick to ext2
which is not as straight forward as you might like.
When plugging in my new USB stick, I was indeed met with the following;
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s1 489825072 422619568 51147752 90% 2408063 9223372036852367744 0% /
devfs 673 673 0 100% 1164 0 100% /dev
/dev/disk1s4 489825072 14680896 51147752 23% 7 9223372036854775800 0% /private/var/vm
map -hosts 0 0 0 100% 0 0 100% /net
map auto_home 0 0 0 100% 0 0 100% /home
map -fstab 0 0 0 100% 0 0 100% /Network/Servers
/dev/disk1s3 489825072 1021032 51147752 2% 30 9223372036854775777 0% /Volumes/Recovery
/dev/disk2s1 60033120 26976 60006144 1% 0 0 100% /Volumes/SANDISK32GB
Running e2fsprogs to format the USB stick resulted in the following;
sudo $(brew --prefix e2fsprogs)/sbin/mkfs.ext2 /dev/disk2
mke2fs 1.44.5 (15-Dec-2018)
/dev/disk2: Resource busy while setting up superblock
What I needed to do was unmount the FAT partition from the Mac so that I could format it in ext2 as required;
diskutil unmountdisk /dev/disk2s1
Then run the original e2fsprogs command to format the USB disk.
Notice the difference between the filesystem name and the mounted filesystem name
/dev/disk2s1 mounted vs /dev/disk2 device.