hi everybody. I have a little problem with "umount": in a piece of software i try to mount a flash device to the file system of my computer, then write/read data from/to this flash device( with fstream, each open method has its corresponding close method). The problem is that as soon as I try to umount(*char_mountpoint) I get an error 16:

EBUSY 16 /* Device or resource busy */

After cancelling the process in terminal with "Ctl+C" I can umount the device wit "umount mountpoint". Does anyone have an idea why it does not work in the c++-program?
I assumed, that the problem was in my file operations code, but after i comment the whole file operations (doing only mount and umount) the problem is still there.

I mount the flash device with the following code:

mount("/dev/mtd4", "/tmp/fls/", "vfat", MS_RDONLY);

und unmount with:

while (umount("/dev/mtd4"){
                    cout << strerror(errno) << endl;
                    errno = 0;

Device or resource is busy
Device or resource is busy
Device or resource is busy
Device or resource is busy

Last edited on
It looks like your OS isn't letting you unmount because it thinks your program is still using the device. Make sure all activity has actually stopped on the device, as it could still be reading/writing from cache (look for LED activity on the flash if it has any).

If that isn't the case you can try to force an unmount with elevated privileges or lower permissions on the device itself.


sudo umount -lf mountpoint


sudo chmod 777 /dev/devicename
umount /dev/devicename
¿shouldn't umount("/dev/mtd4") be umount("/tmp/fls/") ?
¿Which OS are you using?
man wrote:
The original umount() function was called as umount(device)
and would return ENOTBLK when called with something other than a block device.
In Linux 0.98p4 a call umount(dir) was added, in order to support anonymous devices.
In Linux 2.3.99-pre7 the call umount(device) was removed, leaving only umount(dir)

If you've got it, try umount2()
thanks for your answers!
I had a little mistake in my code posted here:
I call umount not with
but with
umount ("/tmp/fls/");
(thanks to ne555)

the problem was following:
after mounting the device I called

and stayed in this directory till end of the program. This caused the error messages. The call

before umount(dir) solved my problem (thanks to slumpers at this point).

The OS I use is a commercial Linux distribution which is not on the market yet. Kernel is 2.6.37, ARM Coretex-A8 architecture

P.S.: sorry for my inattention and thanks for your help
Last edited on
Topic archived. No new replies allowed.