Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mounting USB-to-Flash Devices at Boot

7 views
Skip to first unread message

J.B. Wood

unread,
Jan 3, 2013, 10:03:29 AM1/3/13
to
Hello everyone. I've got a Linux (Fedora) platform that boots up in
runlevel 3 to accommodate remote SSH logins only. There is no monitor
or keyboard connected to this Fedora platform although it is physically
located near the user(s).

I want a user to have the option to plug-in either a thumb drive or a
USB-to-CompactFlash adapter prior to power-up and have the device
mounted following boot completion. The adapter isn't required all the
time and I don't want the user to have to modify /etc/fstab or manually
mount the device from the command line (remote users aren't allowed root
privilege). Now, Linux platforms will often stall during boot if a
device entry in fstab can't be located (i.e. the adapter hasn't been
plugged in to a USB port). So I tried putting this line in
/etc/rc.local instead:

mount -t vfat -o gid=501,uid=501 /dev/sdb1 /media/Flash

This mounts the previously plugged in USB device at boot time with the
desired ownership and permissions. The Linux platform also seems to
boot up OK when the sdb device is absent, which is also an objective.
Any comments or (more reliable?) alternatives would most certainly be
welcome. Thanks for your time and comment. Sincerely,

--
J. B. Wood e-mail: arl_1...@hotmail.com

J G Miller

unread,
Jan 3, 2013, 10:58:18 AM1/3/13
to
On Thursday, January 3rd, 2013, at 10:03:29h -0500, J.B. Wood explained:

> So I tried putting this line in /etc/rc.local instead:
>
> mount -t vfat -o gid=501,uid=501 /dev/sdb1 /media/Flash

If the USB device always has the same filesystem, then it will
have a UUID (or you can give it one). Then in the rc.local file
first test to see if that UUID is present in /dev/disk/by-uuid/
and only then if it is present do the mount command using
the UUID rathern than the device name.

This will prevent the automatic mounting of unauthorized USB
devices which should be an important consideration especially
if there is sensitive data on the disks of the host or on
the local network.

After all people have been known to lose USB sticks containing
military secrets.

<http://news.bbc.co.UK/2/hi/uk_news/7514281.stm>

Matthew of Boswell

unread,
Jan 3, 2013, 8:10:01 PM1/3/13
to
On Thu, 03 Jan 2013 10:03:29 -0500
"J.B. Wood" <john...@nrl.navy.mil> wrote:

> [snip] Now, Linux platforms will often stall during boot if a
> device entry in fstab can't be located (i.e. the adapter hasn't been
> plugged in to a USB port). [snip]

Ah, I had a similar problem because I wanted to mount a LUKS partition
but only after a user has manually entered the decryption password.
Then I found out about mount's "nofail" option, which you can use in
fstab. Using that, you can have the usb automatically mount, or at
least the user can mount it without root priviledges (as long as you
give it the "user" or "users" option).

However, I don't know how to deal with the issue of multiple usb
drives. I mean, what if you put one in, and have sdb1 mount, then the
second usb is sdc? fstab entry for each usb port? What if the usb has
no partition table, and is just a raw fat32 (ex: /dev/sdb with no
partition number)? But maybe those are not issues for you.

Hope that helps :)

--
Matt Boswell

() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - and proprietary attachments

J.B. Wood

unread,
Jan 4, 2013, 1:33:08 PM1/4/13
to
On 01/03/2013 08:10 PM, Matthew of Boswell wrote:
> On Thu, 03 Jan 2013 10:03:29 -0500
> "J.B. Wood" <john...@nrl.navy.mil> wrote:
>
>> [snip] Now, Linux platforms will often stall during boot if a
>> device entry in fstab can't be located (i.e. the adapter hasn't been
>> plugged in to a USB port). [snip]
>
> Ah, I had a similar problem because I wanted to mount a LUKS partition
> but only after a user has manually entered the decryption password.
> Then I found out about mount's "nofail" option, which you can use in
> fstab. Using that, you can have the usb automatically mount, or at
> least the user can mount it without root priviledges (as long as you
> give it the "user" or "users" option).
>
> However, I don't know how to deal with the issue of multiple usb
> drives. I mean, what if you put one in, and have sdb1 mount, then the
> second usb is sdc? fstab entry for each usb port? What if the usb has
> no partition table, and is just a raw fat32 (ex: /dev/sdb with no
> partition number)? But maybe those are not issues for you.
>
> Hope that helps :)
>

Thanks for the info, Matthew! And also to J.G. Miller for his reply. I
wasn't aware of that fstab option (I really need to get in the habit of
reading all of a Linux man page). The "nofail" works like a champ and
it seems more elegant than my rc.local method. Your questions are also
interesting but right now they don't apply in my case. Thanks again to
all for taking the time. Sincerely,
0 new messages