ubuntu 9.10 and external USB drives

Where Penguins and Daemons chill together in the warmth of the Sun.

Moderators: SecretSquirrel, notfred

ubuntu 9.10 and external USB drives

Postposted on Sun Dec 27, 2009 3:29 pm

How can I make Ubuntu (32-bit desktop) automatically mount an external USB hard disk? If I login through Gnome, it auto-mounts it for me, but I won't usually be logging in to this computer -- it's really just a server, running imap/smtp/apache/samba and a few other services for my home network.

Gnome sees this disk as /dev/sdb1, and mounts it on /media/disk2. It's already formatted for ext2. But like I said, I want it to mount automatically at boot time, not just when I log into the desktop. Anyone know how?
maditude
Gerbil
 
Posts: 16
Joined: Fri Nov 13, 2009 10:55 am

Re: ubuntu 9.10 and external USB drives

Postposted on Sun Dec 27, 2009 4:15 pm

add a line in /etc/fstab

something like:
Code: Select all
/dev/sdb1           /media/disk1           ext2          defaults           0    0


also, if it's actually a hard drive rather than a flash drive you might want to use ext3 rather than 2
Fernando!
Your mother ate my dog!
cheesyking
Minister of Gerbil Affairs
 
Posts: 2254
Joined: Sun Jan 25, 2004 7:52 am
Location: That London (or so I'm told)

Re: ubuntu 9.10 and external USB drives

Postposted on Sun Dec 27, 2009 4:54 pm

Awesome, cheesyking, that works great! I examined my /etc/fstab's existing lines before posting, but saw stuff about UUID=blah in there, and figured I'd better check around before doing anything rash.

The drive is indeed a hard drive (120gb 2.5" sata laptop drive). But I figured, since the server is a laptop, and both it AND the USB drive are powered from my UPS, that journaling would be pointless. Should I reconsider?
maditude
Gerbil
 
Posts: 16
Joined: Fri Nov 13, 2009 10:55 am

Re: ubuntu 9.10 and external USB drives

Postposted on Sun Dec 27, 2009 5:33 pm

If your computer ever has a hard lockup, ext3's journaling could prevent data loss & will save you from a lengthy eff ess cee kay [1] the next time drive is mounted.


[1] stupid word filter.
Think for yourself, schmuck!
i5-2500K@4.3|Asus P8P67-LE|8GB DDR3-1600|Powercolor R7850 2G|1.5TB 7200.11|1988 Model M|Saitek X-45 & P880|Logitech MX 518|Dell 2209WA|Sennheiser PC151|Asus Xonar DX
bthylafh
Grand Gerbil Poohbah
 
Posts: 3158
Joined: Mon Dec 29, 2003 11:55 pm
Location: Southwest Missouri, USA

Re: ubuntu 9.10 and external USB drives

Postposted on Mon Dec 28, 2009 8:37 am

maditude wrote:Awesome, cheesyking, that works great! I examined my /etc/fstab's existing lines before posting, but saw stuff about UUID=blah in there, and figured I'd better check around before doing anything rash.

The drive is indeed a hard drive (120gb 2.5" sata laptop drive). But I figured, since the server is a laptop, and both it AND the USB drive are powered from my UPS, that journaling would be pointless. Should I reconsider?


the UUIDs are actually a much better way of doing this as it's possible the order of your drives might change (say if you left a usb flash disk plugged in at reboot or added another internal disk etc). Google finds lots of info doing it this way but here's a very brief intro:

use the blkid command to find the UUIDs on your system...

sudo blkid

Then just alter the line in fstab to use the UUID like the other lines that the installer created. NB blkid prints UUID="xyz" but fstab uses UUID=xyz without the "" so be careful when copy and pasting!

And yes I'd always use ext3 over ext2 UPS or not, unless there's a very good reason not to (like you're using a flash disk which the journalling will prematurely age)

NB lots of pages on the net (and even the comments in fstab on my ubuntu 9.10, which is actually an upgraded 9.04) talk about using the vol_id command. This command doesn't actually exist in 9.10 so don't be surprised if it doesn't work!
Fernando!
Your mother ate my dog!
cheesyking
Minister of Gerbil Affairs
 
Posts: 2254
Joined: Sun Jan 25, 2004 7:52 am
Location: That London (or so I'm told)

Re: ubuntu 9.10 and external USB drives

Postposted on Mon Dec 28, 2009 11:12 am

it is udev that should be mounting the drives, not the desktop. see articles like superuser.com or ubuntu forums

the idea with udev is that it keeps the mount in user space and you can better control system response to mounting multiple drives in various configurations with specific actions depending upon what it is you plug in.
Bryan
bryanl
Gerbil Team Leader
 
Posts: 251
Joined: Mon Dec 15, 2003 10:27 am
Location: Nevada


Return to Linux, Unix, and Assorted Madness

Who is online

Users browsing this forum: No registered users and 5 guests