Mke2fs says “Device or resource busy while setting up superblock”

backup-restorationfilesystems

I'm trying to test restoring a backed up linux file system /apps (ext3 filesystem)

/dev/cciss/c0d0p7     177G  3.8G  164G   3% /apps

I ran the following command to take a dump:

/sbin/dump -0uz -f /backup_labeir1/apps.dmp /apps

Then I deleted the /apps folder:

rm -rf /apps

And unmounted it:

umount -l /apps

Next I'm trying to make the file-system

mke2fs -j -b 4096 -L data /dev/cciss/c0d0p7

after which I'm planning to do the below steps:

# mkdir /apps
# mount -t ext3 /dev/cciss/c0d0p7 /apps
# cd /apps
# restore -rf /backup_labeir1/apps.dmp .
# reboot

I've 2 questions:

  1. Are my testing steps correct
  2. When I run the below I get the error:
    [root@labeir2 backup_labeir1]# mke2fs -F -j -b 4096 -L data /dev/cciss/c0d0p7
    mke2fs 1.39 (29-May-2006)
    /dev/cciss/c0d0p7 is apparently in use by the system; mke2fs forced anyway.
    /dev/cciss/c0d0p7: Device or resource busy while setting up superblock

But neither the filesystem is mounted nor lsof shows me any output:

 lsof | grep /dev/cciss/c0d0p7
 lsof /dev/cciss/c0d0p7

Please help me resolve this.

Best Answer

I got the same error when I tried to format a USB drive on Mac OS X. In my case, unmounting the disk first with diskutil unmountDisk ... solved the problem.

Details: First, run diskutil list and check the output to figure out which disk you want to format. (Don't format your hard drive disk0!) In my case, it was /dev/disk1. When I first ran mkfs.ext3 /dev/disk1, I got the message "Resource busy while setting up superblock". But after I ran diskutil unmountDisk disk1, mkfs.ext3 worked.

Note: Initially, I tried diskutil eject disk1, but then the disk is not accessible anymore - e.g. diskutil list doesn't show it. diskutil unmountDisk disk1 makes sure that the disk is no longer in use, but mkfs.ext3 can still access it.

Related Topic