Linux

  1. Home
  2. Computing & Technology
  3. Linux

Linux Newbie Administrator Guide

From Authors, for About.com

5.2.12 I attached a new hard drive. What do I do to start using it?

    • Plan the layout of the filesystem with the new drive

    • Partition the new hard drive

    • Format the new partitions

    • Test the new space

    • Copy data from old to new partition (optional)

    • Edit /etc/fstab

    • Reboot

    • Remove old data (optional)

Here is a longer version for my recipe.

    • Plan the new filesystem. Where would you like to use the new space? Do

df

to print a summary of free/used space on each of the existing mounted partitions. Do

du

on selected directories to find their size.

For example, I would consider using new hard drive space in one of the following mount points:

/usr/local

/home

/home/share/downloads

/usr/local/mp3s

/usr/local/dos_data

Here is why.

  • /usr/local is supposed to survive any upgrade of Linux. It is nice to have it on a separate partition because I can even reformat other partitions without affecting my local contents stored in /usr/local. I surely want it of the type "ext2", “ext3” or perhaps "reiserfs".

  • /home contains user data. Surely, it is the data that deserves the most care. It is obviously supposed to survive any upgrade of Linux. Wow, obviously I want it on a separate partition. The type is normally "ext2", “ext3” or "raiserfs".

  • /usr/local/mp3s is a non-standard Linux directory. I may keep my MP3 (music) files there. Those tend to be large.

  • /usr/local/dos_data. Another non-standard directory. If I dual boot, I would consider making an extra partion of the type "DOS FAT32" or similar so as to share files between MS Windows and Linux transparently (both ways). I would configure all the Windows-based programs to use this "drive" as the default location for all user-generated files. I could even have "mp3s", "cds" and other such directories in this location. The serious drawback of this approach--MS Windows may insist on messing up with this partition on re-install.

    • Partition the new hard drive. For example, if my new harddrive is the slave on the second IDE interface (perhaps the "fourth" IDE drive), I could use:

cfdisk /dev/hdd

or the more old-fashioned (and standard) tool:

fdisk /dev/hdd

If your drive is not "hdd" adjust the above command as needed.

hda -- first ide master (whole disk)

hdb -- first ide slave

hdc -- second ide master

hdd -- second ide slave

sda -- first scsi (whole disk)

sdb -- second scsi (whole disk)

...

sdp -- sixteenth scsi (whole disk)

For other disks, consult /usr/src/Linux/Documentation/devices.txt.

Most of the time, I want my Linux partitions to be of the type ext3 ("Linux").

Partitioning can be tricky--if you never have done it, read man fdisk and man cfdisk. It is very easy to delete a partition with all your data. Make sure you know which disk you are working with!

fdisk or cfdisk does not make any changes to the hard drive until I write the new partition layout. So if I make a bad mistake, I can always quit without writing. I write the layout to the drive only when I am completely done.

    • Format each partition. For example, to format the first partition, while checking for bad blocks (-c), I would do:

mkfs -c -t ext2 /dev/hdd1

    • Test the new partitions around. Mount the new partitions manually (the mount directory must exist and be empty). Copy a bunch of files to each partition. View/edit a couple of random files. Delete them all.

    • Copy data. Optional--only if you would like to move data from an old partition to a new partition. Go to the single-user mode (init 1). Mount the new partition manually. Copy the data from the old partition to the new partition. Careful with the old data, you probably don't want to lose it if you made a mistake, so I wouldn't delete it yet--I rename the top level directory appropriately. E.g.,

cp -R /usr/local/

* License

* Linux Newbie Administrator Guide Index

Explore Linux

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Linux

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Newbie Administrator Guide
  6. Linux Newbie Administrator Guide - 5.2 Accessing my drives

©2009 About.com, a part of The New York Times Company.

All rights reserved.