How to mount USB key
Roland Smith
rsmith at xs4all.nl
Wed Jun 6 17:32:24 UTC 2007
On Wed, Jun 06, 2007 at 10:57:57AM -0600, Oscar Chavarria wrote:
> I want to copy files to it. I introduced the key and was recognized as da0.
>
> I did ls dev/da0 ==> dev/da0
>
> Then
>
> mount /dev/da0 /home ==> incorrect super block.
You're trying to mount the drive as a UFS filesystem; this is the
default for mount.
Are there no other devices starting with da0? Because usually USB
keydrives are partitioned and then the first partition is formatted as
FAT32. So you probably want /dev/da0s1, or sometimes /dev/da0s4 if it exists.
It is also not a good idea to mount on /home, because it will mask your
home directory.
If you want to mount a disk as a normal user instead of root, there are
some things that need to be set up correctly, see below.
It's better to use something like:
mount_msdosfs -m 644 -M 755 -o noatime,noexec,nosuid,sync /dev/da0s1 /mnt/mydir
I've written a small shell script to do this for me;
----------------
#!/bin/sh
# Mount a thumbdrive with a MSDOS filesystem
DIR=/mnt/$USER
DEV=/dev/da0s1
# It is assumed that $DIR exists, and is owned by $USER.
# Check if $DIR is already used.
if mount|grep $DIR >/dev/null; then
echo "$DIR is already mounted!"
exit 1;
fi
# Check if $DEV is available.
if ! ls $DEV >/dev/null 2>&1; then
echo "$DEV does not exist!"
exit 1;
fi
# Everything OK, try to mount.
mount_msdosfs -m 644 -M 755 -o noatime,noexec,nosuid,sync $DEV $DIR
----------------
N.B.:
- /mnt/$USER should be an existing directory, and that you should be
it's owner.
- the script will fail if there is already an USB disk attached.
(it should use da1s1 in that case)
- the sysctl vfs.usermount should be set to 1 to allow normal users to
mount filesystems
- the permissions on the /dev/da0 device whould be set such as to allow
you access. See http://www.xs4all.nl/~rsmith/freebsd/index.html#devfs
Roland
--
R.F.Smith http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20070606/e756984b/attachment.pgp
More information about the freebsd-questions
mailing list