move linux os to bigger hard drive

I have red hat 9 on my computer. I have 2 20g hard drives in the machine. The first drive has 5 partitions on it everything except /home which is on my second hard drive.
I have bought a new 120g drive and I want to move everything to it and have linux remain in tack. I don't want to re-install redhat and then copy everything back if I don't have to. I am not sure how to do this, please help...

Thanks Onestar
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi onestar,

An easy way would be just to mount it as your new /home:

1. partition and format the new drive
2. mount it as /mnt/tmphome
3. cp everything from /home to the new
4. change your ftab to use the new drive as /home (and the old /hom-drive as /mnt/oldhome for a while...)
5. that's it

Other solutions depend on whether you are having any space problems, - there's several solutions where you can move things out from e.g. /usr to somewhere else, and then insert a symlink where it's been removed.

Kind regards,
onestarAuthor Commented:
Yeah I am more worried about the first drive with the boot up information. I am not sure about the boot loader if that will get copied over properly.

Here is a df from my system.

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hde7              6972800    241692   6376900   4% /
/dev/hde1                99043     29018     64911  31% /boot
/dev/hdf1             19694836  13356388   5338004  72% /home
none                    386172         0    386172   0% /dev/shm
/dev/hde5              2519576     32956   2358632   2% /tmp
/dev/hde2              6047252   2973456   2766608  52% /usr
/dev/hde3              3023640   1499852   1370196  53% /var

I have seen some program you can download from the hard drive manufacture that says you can copy everything from one hard drive to another to upgrade the hard drive but I have never tried it and I am not sure if it would work with ext3 filesystem. It probably only ment for windows.

Thanks Onestar
Hi onestar,

I'm not sure I understand your concern, - you're looking good according to your df, so moving your home should do it for you.

What is your concern ?

IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

onestarAuthor Commented:
I want to move everything from the 2 hard drives on to 1 new big hard drive without having to re-install linux on the new drive. I am going to use the 2 20g drives in another computer.

sorry, - I may have misinterpreted you: if you want to migrate from your two disks to using only the new disk, that's a quite different story of course, - but I would stick with my hde and just move my home.

I've only ever done it in two ways:

partitions of similar sizes on two disks (from old disk to new): done with linux: 'dd'  (check man-page, - it's dangerous!)
partitions of different sizes on two disks : I used DiskImage in disk-to-disk mode

ghost should be able to do this for you... perhaps in conjunction with something like PQMagic (this is more or less an alternative to Svens second method)....

Or, better yet, the free alternatives QtParted and Partimage ( Should be able to do all you want. One nice way to do it would be to run it from knoppix (it is part of knoppix..., to avoid having the drives "live" while doing it.

The first method is a bit more messy... add in the new drive "somewhere", use fdisk (or similar tool) to create partitions with sizes as close to the old partitions as possible (or very slightly larger), dd if=<old partiton> of=<ne partition>, possibly resize2fs to fit to partition, mount up all the new partitions on /somwhere, edit /somewhere/etc/fstab and adjust it for the new drive _as it will be "placed" after removing the original drives, then run grub-install <the new drive ... whatever that might be /dev/hdg perhaps> to install grub to its "MBR"... then remove the drives, and move the new one into place.
Not that pretty, and way worse "economy" since dd will copy all blocks of the partition, not just the used ones... But doable.

I'd use partimage.

-- Glenn
If you want to transfer everyting to the 120Gb drive with native Linux methods the process isn't really all that difficult. The steps that one would use look like:

1) Connect the new disk to an IDE controller. This might mean having to discconect one of the disks or some other device. To start with all that's necessary is to have the Boot disk and the new drive in the machine as we'll be doing all of the data transfers in single user mode. If necessary you can transfer the contents of /home after making the new drive the boot drive.

2) Boot up in single user mode, which is done by pressing 'e' at the Grub screen, moving down to the "kernel" line on the next screen and adding "single" to the end of kernel line.

3) Create partitions to hold the existing file systems and swap on your boot drive with fdsik. You can adjust the sizes of the partitions if desired. Life will be a bit simpler if the partition numbers on the new disk match those on the existing boot drive.

4) Make file systems on the newly created partitions (e.g., mke2fs /dev/hdb1) and create swap (e.g., mkswap /dev/hdb5). You need to supply a label for each file system (except swap) that matches your existing disk labels. You can see what those are by examining the contents of /etc/fstab. The command that I'd use when creating file systems looks like 'mke2fs -j -L /fs-label /dev/hdb?'. See 'man mke2fs' for details.

5) Mount each of the new file systems and transfer the existing file system's contents with:

  # mount /dev/hdb1 /mnt
  # dump 0af - /dev/hda1 | (cd /mnt; restore rvf -)

    Do this for each of the file systems except swap. Not all file systems might be mounted in a single user
    boot, but 'mount -a' will take care of that.

6) Make sure that you have a working boot floppy (make one with mkbootdisk if necessary). Then shutdown and reconfigure the system so that the 120Gb drive is your boot disk (usually Primary Master).

7) Boot from your boot floppy and use the command grub-install to install a boot loader.

Enjoy the new disk...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yes... Please note that Jims use of an "instant" backup/restore cycle removes the need for matching partition sizes (or resizing filesystems... since this will already be done:-).
Jims method is the time-tested default unix method... really not a bad alternative.
Sweet, at least three methods, and a multitude of tools to accomplish each, that will all work nicely:-).

-- Glenn
Argh, I was going to make one small point... all methods are actually "pure linux", in that they can be performed with linux tools "all-through".

-- Glenn (the accidental "Submit"-er)
I believe  I had the solution.
Yeah well, at least one solution... and probably the "best" solution.... And rather useless to split 50 points:-).

-- Glenn
Karl Heinz KremerCommented:
Jim's solution works in this case because the file system used is ext3, but would fail e.g. for reiserfs.

Karl Heinz KremerCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by jlevie
Please leave any comments here within the next four days.


EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.