Sunday, March 25, 2007

Adding a Hard Drive

A few weeks ago, at the same time I bought that 2 GB memory key, I bought a Maxim “200 GB” drive. The 200 GB is in quotes because the drive formats out to exactly 196,907,134,976 bits, which is several bits short of a load even if you believe that 1 GB = 109 bytes. (Actually, of course, 1 GB = 230 bytes.)

So I have this big-but-not-200 GB drive that I want to a) install, b) reformat as an ext3 file system, and c) make my /home directory.

Installing the drive wasn't too much of a problem. It went into the second CD drive bay. Not where it was supposed to go, but then I didn't have a lot of choice. Ideally, the drive should go on the same cable as the original hard drive. Unfortunately, drive cables are only 18 inches, max, and the geometry of the situation is that the second drive would have to be duct-taped to the case to make that work. So instead of hooking up the second drive in series with the first drive, I'm hooking it up in series with the DVD-drive. I suspect that this could cause a performance hit when I'm writing DVDs and CDs. I also suspect that I've just voided the warranty on this Dell, but that's OK, because the machine is now almost four years old, and I think the warranty has long expired.

The other problem with doing things this way is that the drive and drive-bay screw holes are mismatched, so the drive can either be screwed in and lean at an angle, or just sit loosely on the shelf. Since this is a floor-based tower model, I just let the drive sit there. This may cause problems if we ever get an earthquake, but then there's still the duct-tape option.

Anyway, the drive is installed, however precariously. So how do I save it from its Windows formating and convert it into a real disk drive? Follow:

  • First I have to find the thing, meaning, where does the computer think it is. Boot the system, and up comes the drive. Open an xterm, or go straight to the console, and issue the extremely useful command:
    $ lshw
    This gives you a complete description of your hardware. Examining the output, I see that there is a Maxtor 186 (real) GB hard disk at /dev/hdd. (If I'd hooked up the drive correctly it would have been at /dev/hdb.)
  • I got the formating directions from Jeff Hunter. I'll just list the steps I took, and refer you to his page for more information:
    $ su (become root)
    # fdisk /dev/hdd (partition the disk. Use the defaults on Hunter's page)
    # mkfs.ext3 -b 4096 /dev/hdd1 (create an ext3 file system)
  • Now add a new line to /etc/fstab:
    /dev/hdd1  /home2  ext3 defaults   0    2
  • Create a mount point for it:
    # mkdir /home2
  • Mount it:
    # mount /home2
  • Copy the files from /home to /home2:
    # cp -r /home/mike /home2
    (do this for every user directory in /home)
  • The owner of all the files you just copied is root. Fix that:
    # chown -r mike:mike /home2/mike
    (and repeat as needed)
  • Now I want to perform a bit of magic. I want to make /home2 my /home directory. Since I'm not absolutely positively sure this will all work, I'll rename the old /home to /home2 for now. Later I'll delete those files and use that partition for scratch, or another Linux distribution (maybe a “real” one).
    Right now my /etc/fstab file has the lines:
    /dev/hda3  /home    ext3    defaults    0   2
    /dev/hdd1  /home2   ext3    defaults    0   2
    
    I'm going to edit this so it reads:
    /dev/hda3  /home2   ext3    defaults    0   2
    /dev/hdd1  /home    ext3    defaults    0   2
    
  • I suppose you could then do:
    # umount /home
    # umount /home2
    # mount /home
    # mount /home2
    but I just hit Ctrl-Alt-Delete and rebooted to get the OS to read the new mount points.

So far no stability issues, no power problems, and a nice big drive.

2 comments:

Anonymous said...

Man, you're entirely too hung up on proper hardware procedure.

I once had a second drive in a case just dangling on the floor by its ribbon cable, standing on one end. It worked fine, but it bounced around too much when we accessed it, so I wadded up some paper towels to put under it. Cool idea, I never thought of duct tape.

After I'm done slapping a box together, if it has five screws involved it's a miracle. I've learned after a few years that hardware is actually much less delicate than the static-guard wristband wearers would have us believe. I've also quit putting the cases back on.

Rest assured, the rest of the house is neat and tidy. I'm just a slob with the machines.

-PP

rcjhawk said...

Well, with me it's more or less the opposite. I moved into my office less than two years ago. I believe the desktop is faux wood — I haven't seen it in some time, as it's entirely covered with papers.

Despite my spouse's best efforts, much of the house is the same way. The other occupants (except the aforementioned wife) don't help. Last Saturday a cat fell from the sky onto my head.

Given that, it's a sure bet that any piece of computer equipment is going to get nudged occasionally, (or have a snake come live inside) so I'd really like to have everything properly battened down. Never know when something will fall on it.