Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

  1. #1
    Join Date
    Apr 2008
    Location
    Austin, TX
    Beans
    39
    Distro
    Ubuntu 10.04 Lucid Lynx

    Lightbulb HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    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

    1. Plug in the drive
    2. Unmount the drive.
    3. Delete the existing partition and recreate it as ext3 with gparted
    4. Unplug the drive.
    5. Replug the drive.
    6. 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.

  2. #2
    Join Date
    Mar 2008
    Location
    The Burning Earth.
    Beans
    3,660

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    Thanks for posting this. I've had a hell of a time with this issue.
    A few questions if you don't mind.

    01. Does this work the same way with ext4 in 9.04?

    02. Does it work for usb flash drives?

    03. With two computers (both 9.04) with the same username on each, will each computer consider that user to be the owner?

    Thanks much.

  3. #3
    Join Date
    Mar 2008
    Location
    The Burning Earth.
    Beans
    3,660

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    I would imagine this would be true for any brand hard drive, not only WD.
    Just a thought.

  4. #4
    Join Date
    Apr 2008
    Location
    Austin, TX
    Beans
    39
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    Quote Originally Posted by warfacegod View Post
    01. Does this work the same way with ext4 in 9.04?
    Not having tried it, I would assume so. Of course, there may be different defaults in 9.04 that obviate the need for the ownership change.

    Quote Originally Posted by warfacegod View Post
    02. Does it work for usb flash drives?
    I see no reason why not, but you are encouraged to try and report back.

    Quote Originally Posted by warfacegod View Post
    03. With two computers (both 9.04) with the same username on each, will each computer consider that user to be the owner?
    Sadly, I don't know how ext3 (or ext4) stores the user identifier, though I expect it's by UID, not username -- so if you had the same UID on both computers, it should work -- since root is always UID 0, this is why root permissions will appear to persist across machines; this is also why I'd like something like mounting with an effective group permission.

    Just to be clear: Chowning the drive, as I do, is almost certainly the Wrong Way to go about this, but I've failed to find the Right Way that's compatible with Ubuntu's (apparently magical) USB device mounting procedure. It does work for my purposes, and it's easy to implement.

  5. #5
    Join Date
    May 2005
    Beans
    42

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    I have formatted a usb-drive with ext4 with no apparent problem. It even seemed that I got faster write-speed (note seemed...).
    No failure, catastrophic or otherwise yet.

  6. #6
    Join Date
    May 2005
    Beans
    42

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    I use the chown way to get read/wrtite also on both ext3 and 4.
    I seem to remeber that it's UID# not username. So as long as u only use the drive locally or on machines where u got the same UID#, no prob.
    When I want to move stuff, it's all FAT...

  7. #7
    Join Date
    Feb 2009
    Beans
    500

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    Formatting a USB flash drive with ext3, ext4, or any other journalling FS is a bad idea. The constant writes to the journal will degrade the life of the media significantly. The only thing that would do in a USB flash drive more quickly would be to use it as RAM.

    Thanks for the tutorial! I'm will be migrating all my external drives to ext4... when I get another drive big enough to hold all the data!

  8. #8
    Join Date
    Mar 2008
    Location
    The Burning Earth.
    Beans
    3,660

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    I have no idea if the defaults from 8.10 to 9.04 are different or not but with either one, when formating to any filesystem, I lost write privileges
    on flash and hard drives.

    I don't remember how I fixed that but eventually did after much foolishness and idiocy. I seem to remember lots of long winded terminal crap. This way worked instantly for my flash drive (PNY so yeah it isn't just WD). Why not simply have ubuntu ask for authentication like it for allot of other system type GUI commands?

  9. #9
    Join Date
    Mar 2008
    Location
    The Burning Earth.
    Beans
    3,660

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    Why would ext3 or 4 need more read/write operations than say FAT32 or NTFS hence shortening the flash drives life?

    (Maybe their really out to kill my flash drive)

    By the same logic, ext3 and 4 aught to do the same thing to a hard drive.

  10. #10
    Join Date
    May 2005
    Beans
    42

    Re: HOWTO: Format a Western Digital USB hard drive as ext3, with automount

    if u use
    sudo gparted
    then it will be partitioned and formatted by root (and of course owned), that might explain ur rw probs.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •