A USB hard disk /dev/sda
was plugged into my Linux system which had a NTFS partition on /dev/sda1
. The partition was not mounted.
The command to reformat the NTFS partition to an ext4 partition failed with this error:
$ sudo mkfs -t ext4 /dev/sda1
mke2fs 1.45.5 (07-Jan-2020)
/dev/sda1 contains a ntfs file system labelled 'joe_win_hard_disk'
Proceed anyway? (y,N) y
/dev/sda1 is apparently in use by the system; will not make a filesystem here!
Most online replies to this problem say that the partition might be mounted and needs to be unmounted. In my case, the partition was already unmounted. I even verified it with a:
$ sudo umount /dev/sda1
I checked if any files were open on the partition, but they were not:
$ lsof | grep sda1
After some thought, I decided that something else might have its fingers into the drive. I did have usbmount running on this system to automount drives that are plugged in. So I uninstalled it temporarily and rebooted the system:
$ sudo apt remove usbmount
$ sudo reboot
I was able to reformat the partition on the newly rebooted system.
Tried with: Ubuntu 20.04, Raspberry Pi 3 Model B+