View Full Version : Umount -f USB stick resluts in a kernel panic
Graaf_van_Vlaanderen
April 5th, 2009, 19:35
I followed the guidelines in mounting a USB drive, which are explained in the FreeBSD doc:
% 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:
# umount -f /mnt/username
which resulted in a kernel panic.
Then I retried something different:
# mount -t msdosfs /dev/da2s1 /usr/home/username/USB_drive/
# 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.)
ale
April 5th, 2009, 19:51
I tried everything to umount USB-drive normally but without success and in the end tried a forced umount:
# 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.
Graaf_van_Vlaanderen
April 5th, 2009, 20:18
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.
ale
April 5th, 2009, 20:51
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.
DutchDaemon
April 5th, 2009, 22:46
You're not trying to umount from within the mount, are you?
Graaf_van_Vlaanderen
April 5th, 2009, 23:27
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?
ale
April 5th, 2009, 23:33
By the way, are there any tools to examine this core dump generated by this kernel panic?
Sure, start from here http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug.html.
Anyway I wouldn't waste my time on that as it's a well known problem.
ale
April 5th, 2009, 23:42
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?
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,...)
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
Graaf_van_Vlaanderen
April 6th, 2009, 01:34
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 # 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.
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.
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?
lme@
April 6th, 2009, 11:37
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.
iic2
April 6th, 2009, 12:44
mount_msdosfs /dev/da0s1 /b
umount /dev/da0s1
Works everytime and with freeBSD 7.1 stable you don't even have to umount.
lme@
April 6th, 2009, 13:21
Just a note: mount_* is deprecated, please use mount -t fstype.
phoenix
April 6th, 2009, 18:44
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. :)
Graaf_van_Vlaanderen
April 6th, 2009, 22:34
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. :)
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/usb-disks.html
-> Paragraph 18.5: USB storage devices
The "final step" of paragraph 18.5.2
phoenix
April 7th, 2009, 08:17
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.
Graaf_van_Vlaanderen
April 7th, 2009, 10:57
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.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.