Putting a new drive in a Linux system


Subject: Putting a new drive in a Linux system
From: Mike Barsalou (mbarsalou@aidea.org)
Date: Mon Apr 01 2002 - 16:11:22 AKST


I have had the occasion to once again put a different IDE drive into a
production Linux box. I used the Hard Disk Upgrade mini-HOWTO from the LDP
but ran into some problems. I have summarized the steps from the mini-HOWTO
with my comments added. Also, I was using GRUB and the HOWTO only refers to
LILO.

After reading through the Hard Disk Upgrade mini-HOWTO one time to
familiarize myself with the process, I decided that making a boot disk was a
great idea. If you don't do this, YOU ARE TAKING YOUR LIFE INTO YOUR HANDS!

All kidding aside, make a boot disk...its worth it.

A majority of these things are RedHat centric. I do not have other types of
Linux installed here, so hopefully someone can add what to do for their
specific version of Linux.

Since I was just replacing the drive and not changing the filesystem around,
I didn't have to modify /etc/fstab or any other files for that matter.

Here are the things that I did:

Brought down the machine I am going to install the drive in and attached
thew new drive to the already working system.

Brought the machine back up and started it in single user mode.

init 1 # This puts the machine in single
user mode
mkbootdisk 2.4.7-10 # this creates a boot floppy
dd if=/dev/zero of=/dev/hdx bs=8192 # this zeros the drive, x should be
a,b,c or d depending on where
                                                # your drive is located
fdisk /dev/hdx # setup the partitions to match your
old drive. Don't forget to set
                                                # an active partition or you
won't be able to boot
mkfs.ext2 -j -c /dev/hdxn # format each partition for ext3
(ext2 if you remove the -j switch)
                                                # n is the partition number
on the specific drive
mkswap -c /dev/hdxn # create your swap partition
mkdir /mnt/newdisk # create a directory so that we can
mount the partitions
                                                # For each of your partions
do the following steps
mount /dev/hdxn /mnt/newdisk # mount a partition to copy
cp -ax / /mnt/newdisk # This will copy the entire disk to
/mnt/new-disk
                                                # Estimate about 10 minutes
per gigabyte
e2label /dev/hdxn <partition label> # replace <partition label> with the
appropriate label
umount /mnt/new-disk # Unmount the partition and do
another or finish with the rest of the
                                                # mini-HOWTO

The following section is theoretical, because I had some trouble installing
grub, but I'm going to share it anyway. To install grub on the drive:

Yank the old drive and boot with the boot floppy.
rpm -ivvh grub-0.90-11.rpm # load the grub rpm
grub-install /dev/hdxn # this is the partition where the
/boot directory is located

I hope this helps someone.

Mike



This archive was generated by hypermail 2a23 : Mon Apr 01 2002 - 16:13:25 AKST