Solved

move linux os to bigger hard drive

Posted on 2003-11-09
14
1,173 Views
Last Modified: 2013-12-06
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
0
Comment
Question by:onestar
  • 4
  • 3
  • 2
  • +2
14 Comments
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9711903
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,
Sven
0
 
LVL 1

Author Comment

by:onestar
ID: 9711924
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
0
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9711943
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 ?

Regards,
Sven
0
 
LVL 1

Author Comment

by:onestar
ID: 9711968
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.

onestar
0
 
LVL 9

Expert Comment

by:svenkarlsen
ID: 9711976
Onestar,
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



Regards,
Sven
0
 
LVL 20

Expert Comment

by:Gns
ID: 9716081
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 (http://www.partimage.org/). 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... http://www.knoppix.net), 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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 40

Accepted Solution

by:
jlevie earned 50 total points
ID: 9719606
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...
0
 
LVL 20

Expert Comment

by:Gns
ID: 9720789
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
0
 
LVL 20

Expert Comment

by:Gns
ID: 9720804
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)
0
 
LVL 40

Expert Comment

by:jlevie
ID: 10179900
I believe  I had the solution.
0
 
LVL 20

Expert Comment

by:Gns
ID: 10182641
Yeah well, at least one solution... and probably the "best" solution.... And rather useless to split 50 points:-).

-- Glenn
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10303246
Jim's solution works in this case because the file system used is ext3, but would fail e.g. for reiserfs.

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10303249
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

khkremer
EE Cleanup Volunteer
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now