Umount -f USB stick resluts in a kernel panic

I followed the guidelines in mounting a USB drive, which are explained in the FreeBSD doc:

Code:
% mount -t msdosfs -o -m=644,-M=755 /dev/da2s1 /mnt/username

I tried everything to umount USB-drive normally but without success and in the end tried a forced umount:
Code:
# umount -f /mnt/username
which resulted in a kernel panic.

Then I retried something different:

Code:
# mount -t msdosfs /dev/da2s1 /usr/home/username/USB_drive/

Code:
# umount /usr/home/username/USB_drive/

This worked fine for at least two machines.
What am I missing that I received a kernel panic?

PS: The kernel panic resulted on a machine on which the kernel had been recompiled for dtrace. In this case the probes were not loaded. (An experiment with dtrace already resulted in a kernel panic.)
 
Graaf_van_Vlaanderen said:
I tried everything to umount USB-drive normally but without success and in the end tried a forced umount:
Code:
# umount -f /mnt/username
which resulted in a kernel panic.
This is "normal". :)
I mean it's a well known behaviour.

Instead of forcing the umount, try to understand which process is blocking it.
Use for example fstat (from the base system) or lsof (from ports).

Let's hope that with all the work about USB that are doing in CURRENT thing will get better.
 
Thanks for the feedback. I often use the 'umount -f' in Solaris.
But indeed it's better to take a little bit more time to investigate what is blocking from doing a proper umount.

I suspect that mounting something on /mnt or the overwhelmingly options in FreeBSD doc might block a proper umount.
 
Graaf_van_Vlaanderen said:
I suspect that mounting something on /mnt or the overwhelmingly options in FreeBSD doc might block a proper umount.
No, it's not about the mount point or the options, it's a process holding opened files.
 
You're not trying to umount from within the mount, are you?
 
DutchDaemon said:
You're not trying to umount from within the mount, are you?

No certainly not.
I knew from before that 'umount -f' involves a certain amount of risk, however I was completely surprised that it generated a kernel panic.

I'm also a little bit disappointed with the FreeBSD documentation on this topic,
since every step I followed (including the creation of the directory under /mnt) resulted in an unmountable situation.

The documentation is somewhat contradictory:

As an example it mounts a USB device under /mnt, while according to the FreeBSD hier it should be mounted under /media.
The example in the FreeBSD doc shows how to mount the stick, but doesn't mention how to umount this same stick.

By the way, are there any tools to examine this core dump generated by this kernel panic?
 
Graaf_van_Vlaanderen said:
I'm also a little bit disappointed with the FreeBSD documentation on this topic,
since every step I followed (including the creation of the directory under /mnt) resulted in an unmountable situation.
Can you exemplify that?

Graaf_van_Vlaanderen said:
The documentation is somewhat contradictory:

As an example it mounts a USB device under /mnt, while according to the FreeBSD hier it should be mounted under /media.
You can mount devices wherever you want with some limitations (own the mount point,...)

Graaf_van_Vlaanderen said:
The example in the FreeBSD doc shows how to mount the stick, but doesn't mention how to umount this same stick.
The chapter about usb devices tells that "the disk must be unmounted before" unplugging the device, and it should be done like with every other device, like described here http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html#DISKS-UMOUNT
 
ale said:
Can you exemplify that?

Well, I just followed the guidelines described in the doc.
At a certain moment I thought the USB-stick was properly umounted
after
Code:
# umount -a -t msdosfs
since the terminal did not return anything anymore. However I still could access the USB-stick. That's why I ended up using a forced umount.

ale said:
You can mount devices wherever you want with some limitations (own the mount point,...)
Sure, that's in the end what I also did when mounting under my user account, like described in my first post. It would just look nicer for the doc if it would use /media instead of /mnt.

ale said:
The chapter about usb devices tells that "the disk must be unmounted before" unplugging the device, and it should be done like with every other device, like described here http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/book.html#DISKS-UMOUNT

Of course, what is otherwise the point of the umount command?
 
Which Version of FreeBSD are you running?
trasz@ MFCed some patches that should prevent panics on unmounting.
You need 7-STABLE or better (for removing umass devices) CURRENT.
 
mount_msdosfs /dev/da0s1 /b

umount /dev/da0s1

Works everytime and with freeBSD 7.1 stable you don't even have to umount.
 
Just a note: mount_* is deprecated, please use mount -t fstype.
 
Graaf_van_Vlaanderen said:
The documentation is somewhat contradictory:

Including a link to which document(s) you are talking about would be very useful. It's hard to check the docs, and possibly submit PRs to improve them, if we don't know which doc(s) you are talking about. :)
 
There's nothing in there that contradicts hier(7). hier(7) mentions that /media can be used to create sub-directories for removable media, but that /mnt can also be used for temporary mount points (like would be used for removable media).

All of my FreeBSD systems (4.4 through 7.1) have empty /mnt and /media directories, and most don't even have a /media directory.

Note also the use of "[o]ne way to do that is for root to create a subdirectory owned by that user as /mnt/username". It's not saying that's the only way, that it's carved in stone, and that your house will burn down if you decide to use /media instead. :)

Personally, I prefer to use mount points within the user's directory for temporary mount points. Keeps the permissions simpler, especially on multi-user setups.
 
phoenix_rizzen said:
Personally, I prefer to use mount points within the user's directory for temporary mount points. Keeps the permissions simpler, especially on multi-user setups.

Which is what I additionally posted in my first post and indeed works fine.
 
Back
Top