Automatically mounting USB storage devices under their correctmount points

This is a discussion on Automatically mounting USB storage devices under their correctmount points within the Linux General forums, part of the Linux Forums category; I have two USB sticks and two USB hard drives connected to a PC. The USB sticks have been formatted ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-02-2008
K. Jennings
 
Posts: n/a
Default Automatically mounting USB storage devices under their correctmount points

I have two USB sticks and two USB hard drives connected to a PC.
The USB sticks have been formatted as ext2, whereas the drives have been
formatted as jfs. My question is, how can things be configured so that
each of those drives gets mounted under its correct mount point at boot
time?

If I understand it correctly, the actual SCSI device associated
to each piece of hardware will be selected at boot time, but I do not
understand how that is done, or whether one has any control over it. For
example, USB stick #1 might be associated with /dev/sda in one occasion,
but with /dev/sdb on another. How can one then make sure that USB stick
#1 will always be mounted under (say) /Stick1, stick #2 under /Stick2,
etc.? (For simplicity, I am assuming a single partition in each of the
USB storage devices.)


Reply With Quote
  #2 (permalink)  
Old 05-02-2008
Ignoramus23760
 
Posts: n/a
Default Re: Automatically mounting USB storage devices under their correct mount points

On 2008-05-02, K. Jennings <kjennings@resurgence.net> wrote:
> I have two USB sticks and two USB hard drives connected to a PC.
> The USB sticks have been formatted as ext2, whereas the drives have been
> formatted as jfs. My question is, how can things be configured so that
> each of those drives gets mounted under its correct mount point at boot
> time?


Very easy.

Look under /dev/disk/by-id/

ls -l /dev/disk/by-id/

Let's say that your stick's partition shows as

/dev/disk/by-id/usb-USB_USB_2.0_Flash_13DFA16D-0:0-part1

(my actual example)

Then you can add a line to /etc/fstab like this:

/dev/disk/by-id/usb-USB_USB_2.0_Flash_13DFA16D-0:0-part1 /mnt/4gb auto noauto,user 0 0

and create directory

mkdir /mnt/4gb

and then it will be automounted the next time you insert the thumb
drive.

I do it all the time;

i

> If I understand it correctly, the actual SCSI device associated
> to each piece of hardware will be selected at boot time, but I do not
> understand how that is done, or whether one has any control over it. For
> example, USB stick #1 might be associated with /dev/sda in one occasion,
> but with /dev/sdb on another. How can one then make sure that USB stick
> #1 will always be mounted under (say) /Stick1, stick #2 under /Stick2,
> etc.? (For simplicity, I am assuming a single partition in each of the
> USB storage devices.)
>
>


--
Due to extreme spam originating from Google Groups, and their inattention
to spammers, I and many others block all articles originating
from Google Groups. If you want your postings to be seen by
more readers you will need to find a different means of
posting on Usenet.
http://improve-usenet.org/
Reply With Quote
  #3 (permalink)  
Old 05-02-2008
Dances With Crows
 
Posts: n/a
Default Re: Automatically mounting USB storage devices under their correct mount points

Ignoramus23760 staggered into the Black Sun and said:
> On 2008-05-02, K. Jennings wrote:
>> I have two USB sticks and two USB hard drives connected. How can
>> things be configured so that each of those drives gets mounted under
>> its correct mount point at boot time?


In general, if something can be unplugged easily, you shouldn't mount it
at boot time. If these things are going to stay attached to one machine
permanently, why didn't you use faster and cheaper SATA disks? Or is
this an ad hoc solution?

> Let's say that your stick's partition shows as
> /dev/disk/by-id/usb-USB_USB_2.0_Flash_13DFA16D-0:0-part1
> Then you can add a line to /etc/fstab like this:
> /dev/disk/by-id/usb-USB_USB_2.0_Flash_13DFA16D-0:0-part1 /mnt/4gb \
> auto noauto,user 0 0


This is overly verbose. Use e2label and whatever labeling conventions
that JFS uses (jfstune?) to give each filesystem a unique label. That
reduces the fstab line to:

LABEL=label1 /mnt/label1 auto noatime 0 0

....which is easier to deal with.

> and then it will be automounted the next time you insert the thumb
> drive.


No, it won't, not unless you're running an automounter. The "noauto"
option you wrote in your fourth fstab field also makes it so that device
will not be mounted automatically at boot time.

>> If I understand it correctly, the actual SCSI device associated to
>> each piece of hardware will be selected at boot time, but I do not
>> understand how that is done, or whether one has any control over it.


First SCSI disk detected = /dev/sda. Second = /dev/sdb. Detection
order is at least partially controlled by the BIOS if you have a Real
SCSI controller. USB devices usually have higher letters than SCSI or
SATA devices, unless the machine boots from a USB device. This is why
many people use labels and/or the LV names that LVM provides.

--
Really, I'm not out to destroy Microsoft. That will just be a
completely unintentional side effect. --Linus Torvalds
My blog and resume: http://crow202.dyndns.org:8080/wordpress/
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Reply With Quote
  #4 (permalink)  
Old 05-03-2008
Maurice Batey
 
Posts: n/a
Default Re: Automatically mounting USB storage devices under their correct mount points

On Fri, 02 May 2008 22:44:11 +0000, Dances With Crows wrote:

> Use e2label and whatever labeling conventions
> that JFS uses (jfstune?) to give each filesystem a unique label.


Would be interested to see an example of that, please.

(For ext3, what is used (Could not find an 'e3label')?)

--
/\/\aurice
Linux Mandriva 2.6.22.18-desktop-1mdv 2008.0 PP
KDE 3.5.7 32-bit
(Remove 'removethis.' to reply by email)

Reply With Quote
  #5 (permalink)  
Old 05-03-2008
Darren Salt
 
Posts: n/a
Default Re: Automatically mounting USB storage devices under their correct mount points

I demand that Maurice Batey may or may not have written...

> On Fri, 02 May 2008 22:44:11 +0000, Dances With Crows wrote:
>> Use e2label and whatever labeling conventions
>> that JFS uses (jfstune?) to give each filesystem a unique label.


> Would be interested to see an example of that, please.
> (For ext3, what is used (Could not find an 'e3label')?)


e2label.

--
| Darren Salt | linux or ds at | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Interception of this message for advertising purposes is not permitted.

I despise the pleasure of pleasing people whom I despise.
Reply With Quote
  #6 (permalink)  
Old 05-03-2008
Dances With Crows
 
Posts: n/a
Default Re: Automatically mounting USB storage devices under their correct mount points

Maurice Batey staggered into the Black Sun and said:
> On Fri, 02 May 2008 22:44:11 +0000, Dances With Crows wrote:
>> Use e2label and whatever labeling conventions that JFS uses
>> (jfstune?) to give each filesystem a unique label.

> Would be interested to see an example of that, please.


"e2label /dev/sda3 a_new_label". The syntax is similar for other
filesystems except FAT, where no labeling program exists and you have to
do:

echo -n "A_LABEL1234" | dd of=/dev/hda2 bs=1 count=11 seek=43

> For ext3, what is used? Could not find an 'e3label'.


ext3 is ext2 with a journal, so e2label is used.

--
The night passed like a kidney stone: painfully and with the help of
major sedatives. --T. Delgado, Lyttle Lytton winner, 2001
My blog and resume: http://crow202.dyndns.org:8080/wordpress/
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Reply With Quote
  #7 (permalink)  
Old 05-04-2008
Maurice Batey
 
Posts: n/a
Default Re: Automatically mounting USB storage devices under their correct mount points

On Sat, 03 May 2008 15:11:56 +0000, Dances With Crows wrote:

> "e2label /dev/sda3 a_new_label". The syntax is similar for other
> filesystems except FAT, where no labeling program exists.....


Many thanks, DWC (and Darren) - much appreciated...
--
/\/\aurice
Linux Mandriva 2.6.22.18-desktop-1mdv 2008.0 PP
KDE 3.5.7 32-bit
(Remove 'removethis.' to reply by email)

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:21 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0