umount -f

Nathan Lay nslay at comcast.net
Fri Sep 2 03:49:26 GMT 2005


Hi,
I noticed a slight problem with umount -f.  Now, as I understand it, -f 
implies forceful which should (you would think) work regardless of 
whether the associated device is connected or not.  Take for example, a 
USB storage device...its a simple work around to just remember to 
unmount the file system before unplugging it, but why should it matter 
if its unplugged or not, umount -f should at least work no?  The system 
will still appear to think the file system is mounted and on a shutdown 
try to flush the write buffers onto a device thats no longer connected 
(at least if it was read/write).  Its tempting to blame the kernel, but 
I think it is more umount's fault.  I'm pressed on time so I haven't had 
a chance to look at how umount works, but shouldn't umount -f at least 
delete those write buffers if the disk isn't connected?  That way the 
system won't fatal trap at halt... See problem recreation below.
I was also thinking about trying to write a USB storage daemon (unless 
someone else is doing it/has done it), umassd, that would monitor 
connects and record file system information and the associated nodes and 
even determine how to mount the file system (ie.  Suppose you have 
multiple USB storage devices and you want them to mount in specific 
places according to fstab, I imagine you can differentiate between them 
with their volume information) and on disconnect act on the appropriate 
nodes associated to a specific umass interface.

fstab info:
/dev/da0s1d             /backup         ufs     rw,noauto       0       0

For (not that it really matters):
reeBSD LIGHTBULB.LOCAL 5.4-RELEASE-p6 FreeBSD 5.4-RELEASE-p6 #8: Wed Aug 
31 19:39:09 EST 2005     
root at LIGHTBULB.LOCAL:/usr/src/sys/i386/compile/LIGHTBULB  i386

Observe:
LIGHTBULB# lsvfs
Filesystem                        Refs Flags
-------------------------------- ----- ---------------
msdosfs                              0
ufs                                  4
devfs                                1 synthetic
cd9660                               0 read-only
LIGHTBULB# mount /backup
LIGHTBULB# lsvfs
Filesystem                        Refs Flags
-------------------------------- ----- ---------------
msdosfs                              0
ufs                                  5
devfs                                1 synthetic
cd9660                               0 read-only
LIGHTBULB# umount -f /backup
umount: unmount of /backup failed: Input/output error
LIGHTBULB# lsvfs
Filesystem                        Refs Flags
-------------------------------- ----- ---------------
msdosfs                              0
ufs                                  5
devfs                                1 synthetic
cd9660                               0 read-only


After mounting /backup, I unplugged my device and tried to "forcefully" 
(and this should unmount it even if its disconnected you would think) 
unmount it and failed, the system still thinks its mounted. 
Now at halt, the system will try to flush the write buffer to that 
mount, which doesn't exist, it will timeout and fatal trap (without 
unmounting the other disks first?)

Best Regards,
Nathan Lay


More information about the freebsd-bugs mailing list