Prev: Mapping home and end keys - ksh and Putty
Next: root can't ls(1) a directory: Permission denied
From: Francis Moreau on 11 Mar 2010 04:56 Hello I've the following (stupid) script that mount a device and umount it right after the mount was succesfull: --- 8< --- #! /bin/sh declare -i i=0 tmpdir=/tmp/foo.yYZ5szCyTv node=/dev/sdc1 while :; do mount -o ro,sync $node $tmpdir && { umount $tmpdir || break } || break i+=1 echo $i done fuser $tmpdir --- >8 --- This fails during the first iteration with the following message from umount(8): umount: /tmp/foo.yYZ5szCyTv: device is busy. but fuser(1) doesn't show anything. So it looks like mount(8) initiates some operations which are not yet finished when this process exits. Could anybody shed some light ? Are there any workarounds ? I found one which consists to add a sleep(1) of one second between mount(8) and umount(8). But this looks ugly. Thanks
From: bort on 11 Mar 2010 09:46 I guess there are still filesystem initialization tasks or sth. going on if you try to unmount so fast after mounting. Try a sync(which will sync all disc caches :( ) before and/or use the lazy unmount feature if you have it. Take a look at man mount Option -l -l Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.) HTH
From: Francis Moreau on 11 Mar 2010 12:07 On Mar 11, 3:46 pm, bort <bernd.salo...(a)gmx.de> wrote: > I guess there are still filesystem initialization tasks or sth. going > on if you try to unmount so fast after mounting. Yes, I think the same. > Try a sync(which will sync all disc caches :( ) before and/or use the > lazy unmount feature if you have it. ouch that would be overkill, perharps I can find something else like $ mount /dev/sdb1 /mnt && ls /mnt >/dev/null && umount /mnt but I don't which command would be correct to use between mount and umount > > Take a look at > man mount > Option -l > > -l > Lazy unmount. Detach the filesystem from the filesystem hierarchy > now, and cleanup all references to the filesystem as soon as it is not > busy anymore. (Requires kernel 2.4.11 or later.) Well I would prefer mount(8) to be synchronous or umount(8) wait for mount(8) to complete instead of failling.
From: mop2 on 11 Mar 2010 17:12 On Thu, 11 Mar 2010 06:56:40 -0300, Francis Moreau <francis.moro(a)gmail.com> wrote: > > umount: /tmp/foo.yYZ5szCyTv: device is busy. > > but fuser(1) doesn't show anything. > I saw this some times, but using "lsof" the file in use was always shown.
From: bort on 12 Mar 2010 08:28 How about mount -rn <stuff> to avoid writing /etc/mtab and mounting it read only? Ever tried that? Hope that helps :)
|
Next
|
Last
Pages: 1 2 Prev: Mapping home and end keys - ksh and Putty Next: root can't ls(1) a directory: Permission denied |