[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How do I install a second harddrive



On Fri, 2003-08-29 at 14:38, Wathen, Metherion wrote:
> Hi all,
> I know that sounds stoopid, but I'm having trouble finding info
> that tells me what I need to do to get a second harddrive on my system
> recognized by linux.
> When i boot the system dmesg clearly shows hdb as found.
> however I don't know what to do to see the contents (if any) of hdb in a program
> like gmc.
> So my question is 
> 1) what do I use to 'see' the 2nd harddrive
> 2) how do I format it for use w/o messing up my 1st drive
> 3) how do I make it part of my existing filesystem
> 

I'll take a stab at this, although there are, I'm sure, others who could
be of greater help.

Your system appears to already "see" the second HD since dmesg shows
that hdb is being found; I assume you already had one harddrive called
hda, and you installed the second hard drive as the slave drive on IDE
channel 0, hence it comes up as hdb. (presumably you also have a cd rom
or something on IDE channel 1, coming up as hdc).

Anyway, assuming this is a new harddrive fresh out of the box, you need
to partition it first, and then format it. DO NOT, repeat, DO NOT do
this if this is a previously used HD from which you intend to reclaim
data - partitioning and formatting will lose all existing data on the
drive.

In any case: to partition the drive, you use an fdisk tool - fdisk,
cfdisk, etc. I usually use fdisk. As root, you would do "fdisk /dev/hdb"
and then using the "m" command in fdisk to see a list of allowed
commands. Basically you will create as many partitions as you like,
either primary or logical, and of course you would (in general) set the
type of partition to linux, assuming you are going to use a standard
linux file system like ext2, ext3, or reiserfs. If you are planning any
windows type file systems like FAT, NTFS, etc, you would set the
appropriate partition types. Once you have the partitions the way you
want them, write the partition table to the disk and exit fdisk. I
usually reboot after repartitioning the HD, as the program advises,
although I'm not sure (under Linux) that this step is absoluately
necessary. You want to be really careful that you don't mistype and
fdisk /dev/hda by mistake, because then youcould wipe out the data on
your existing drive (you have to write the partition table to the drive
using the proper fdisk command; no changes are actually written to the
drive until you do this, so if you realize you mistyped the initial
command to get into fdisk, just exit before doing the write.) "man
fdisk" for more info.

Once the new HD is partitioned, you can address the individual "drives"
just created using /dev/hdbn where n is a number representing the
partition on the drive. Primary partitions are numbers 1-4; logical
partitions start at 5. Note, however, that you can have a max of 4
primary partitions, and if you want logical partitions, one of those
must be an "extended" partition which can contain other (logical
partitions). When I need a multipartition drive, I usually made three
primary partitions (here called /dev/hdb1 /dev/hdb2 and /dev/hdb3) and
one extended partition in which I place the logical partitions
(/dev/hdb5 /dev/hdb6 /dev/hdb7 and so on) so there is not /dev/hda4
because the container extended partition doesn't actually "show up" as a
usable device.

Now you need to format each partition as whatever filesystem you want to
use - ext2, ext3, reiser, etc. Use "man mkfs" to learn more.

Once the partitions are formatted, you need to mount them. Decide on
your mount points, and use the mount command (man mount); also add the
appropriate lines to /ext/fstab so the partitions are automounted at
reboot. (man fstab).

That about does it. Let's assume, for instance, you wanted to make the
new drive contain all the data in your current /home tree, and needed to
move all the current data in /home to the new partition as well. Once
you've partitioned the drive(so you have one big partition, /dev/hdb1),
format it and mount it to a temporary location:

mkfs -t ext2 /dev/hdb1		#format /dev/hdb1 as ext2 file system
mount -t ext2 /dev/hdb1 /mnt	# mount to temporary location

now, copy old data from /home to "new" location
cp -a /home /mnt
OR, tar up /home and untar into /mnt with
cd /mnt; tar -cl /home | tar -xv	#you may want to change options
					#to suit your needs

then replace old /home with new /home
umount /mnt 
mount -t ext2 /dev/hdb1 /home

(note all of the above requires that you are root.)
Once you are sure everything made it over to the new drive, you may wish
to delete the contents of the old /home tree. MAKE SURE you umount the
/dev/hdb1 partition from /home to "uncover" the old contents in /home
before you do this!!! Remember that in linux, you mount a drive
(/dev/hdb1) to a "mount point" (here, /home) and when you do that, the
newly mounted drive hides the original contents at that mount point, but
it is still there, accessible after you umount the drive from that mount
point.

Hope some of this helps. There are howtos on disk partitioning and the
linux / unix filesystem that you should probably read; see the linux
documentation project (http://tldp.org).

nl




Reply to: