f



Automatically mounting USB storage devices under their correct mount 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.)


0
kjennings (73)
5/2/2008 7:00:38 PM
comp.os.linux.misc 33599 articles. 1 followers. amosa69 (78) is leader. Post Follow

6 Replies
626 Views

Similar Articles

[PageSpeed] 52

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/
0
Ignoramus23760
5/2/2008 7:02:47 PM
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
0
5/2/2008 10:44:11 PM
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)

0
5/3/2008 2:36:56 PM
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.
0
news64 (1253)
5/3/2008 3:00:53 PM
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
0
5/3/2008 3:11:56 PM
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)

0
5/4/2008 1:18:42 PM
Reply: