I was running low on disk space on my Ubuntu laptop, so I purchased a 1TB Western Digital "My Book" external USB 2.0 hard drive (for the Googlers, it's part # WDH1U10000 ). It comes with a bunch of auto-run cruft for Windows and Mac, so of course, that won't do. After a couple hours, I think I've settled on an easy step-by-step procedure to a) format the drive as ext3 (like my internal drive) and auto-mount the drive with normal read/write permissions for my usual user (in my case, "todb").
It's really not all that hard; I was initially over-complicating things by trying to fine-tune mount options in /etc/fstab, editing options with gconf-editor, wondering how hal works... but it turned out, in the end, to be fantastically simple.
This is all done on Ubuntu 8.10, "Intrepid Ibex."
The Short Version
- Plug in the drive
- Unmount the drive.
- Delete the existing partition and recreate it as ext3 with gparted
- Unplug the drive.
- Replug the drive.
- chown -R user:user /media/labelname
Now for the longer-winded explanation:
Plug It In
Plug in the Western Digital Drive. You might be tempted to forgo the AC power supply, thinking that USB 2.0 will handle the power requirements. You will be wrong, and sorely disappointed when you get file system corruption.
Unmount
Once your drive is connected, the first order of business is to unmount it, since it's probably already mounted thanks to the automount USB magic. Right click on the icon on your desktop, and select "Unmount." If that doesn't work, try a command line unmount:
Code:
$ sudo umount /media/My\ Book
(or whatever it's called, it does ship with a space in the label name, which is irritating)
Repartition
Next, you'll want to nuke the factory-shipped configuration. The easiest way to do this is to get yourself GParted, if you don't have it already. From a terminal:
Code:
$ sudo apt-get install gparted
Then navigate to System > Administration > Partition Editor
If you have just the one internal drive, then your new drive will likely be recognized as the device /dev/sdb. There's a selection menu on the top right side of the screen, so select /dev/sdb.
You'll now be presented with the graphical display of the existing partition. Select it, then hit the big Delete button. Select the new unallocated gray space, and hit the New button. Choose ext3 as the new filesystem, and choose a label without a space in the name (I went with the creative "MyBook"). Finally, to make all this happen, hit Apply. (If you screwed something up, hit Undo, and start over.
The reformatting will take a few minutes. Check your twitter feeds or something.
Remount
When it's done, close Gparted, yank the USB cable, wait around a few seconds, and plug it back in. Your drive should mount itself in /media/MyBook (or /media/WhateverYouLabelledItAs). If it doesn't, yank and replug again -- I've had the initial detection fail once in while, but this seems to be no big deal.
Chown
Sadly, your new ext3 drive, by default, will mount as root-owned. You can read and execute off it, but not write. I'll be pickled if I can't find out how to change the default mount options (I suspect it has to do with the arcane art of gconf-editor), but mine mounts as:
Code:
$ cat /etc/mtab
/dev/sdb1 /media/MyBook ext3 rw,nosuid,nodev,uhelper=hal 0 0
The easiest way to ensure that you can write to it is with chown. Assuming your user name is "todb" and your ext3 label is "MyBook", the terminal command is:
Code:
$ sudo chown -R todb:todb /media/MyBook
And that's it! If you know how to get fancier with the mount options, please feel free to reply to this telling us; my gconf-editor skills seem to be for naught. I think it just involves creating a new key under /system/storage/default_options for ext3 partitions, but what do I know. At any rate, this chowning method seems to work, and is persistent across mounts and reboots, so I'm happy with it for now.
Oh, and if you do intend to unplug the drive while it's running, it's probably best to first unmount it, to avoid wanging up any disk writes you might have going on:
Code:
$ umount /media/MyBook
Note that now that you own the drive, you no longer need to sudo umount.
HTH.
Bookmarks