Find the answer to your Linux question:
Results 1 to 3 of 3
I just ordered a new (larger) HDD and was wondering if there would be any problems just basically imaging my hard drive to the new one? Would I have to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682

    Copy / to new HDD?


    I just ordered a new (larger) HDD and was wondering if there would be any problems just basically imaging my hard drive to the new one? Would I have to make all the partitions the same size, etc.?
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  2. #2
    Linux User
    Join Date
    Jun 2003
    Location
    Calgary, AB CANADA
    Posts
    496
    0. Get both drives installed on your system, making a careful note of which one is hda/sda and so forth.

    1. Partition the new drive the way you want it, being careful not to
    repartition the old drive. Then, make your filesystems & swap partitions (mke2fs, mkswap) on the new drive, being careful not to reformat your old drive of course. Don't forget to make the /boot partition "active" so the BIOS knows to boot from it later on.

    2. Mount the new drive in a temporary directory. Make subdirectories (mount points) for the other partitions that the new drive will be using, and mount them in the subdirectories.
    i.e., suppose your partition table is:
    /dev/sda1 /boot
    /dev/sda2 swap
    /dev/sda3 /usr
    /dev/sda4 /home
    /dev/sda5 /
    or whatever.
    Mount /dev/sda5 in /mnt, then make directories /mnt/home /mnt/usr
    /mnt/boot and mount the appropriate partitions under /mnt just as if it was the new system. You want all of the partitions mounted when you start to copy data to the new drive.

    3. Make subdirectories (mount points) under /mnt for the directories you are not going to copy, such as /proc , /mnt of course, and perhaps /tmp.

    4. cd to the root directory. Run the following command:

    ( cd / ; tar cf - enumerate all files and directories you want tarred being
    sure to exclude the proc and mnt directories ) | ( cd /mnt ; tar -xvlpsf - )

    This will start a tar process running in / writing the tarchive to stdout, and
    it will start a tar process running in /mnt reading the tarchive from stdin.
    The -xvlpsf options will preserve your file ownership/permissions correctly.

    On my Dell (Red Hat) server, I might type (for example):

    ( cd / ; tar cf - .automount Backup.sh bin boot dell dev etc home lib misc opt
    root sbin tftpboot tmp usr usr2 var ) | ( cd /mnt/newdrive ; tar -xvlpsf - )

    This may take a while.

    5. Edit the /mnt/etc/fstab and /mnt/etc/lilo.conf to reflect the new partition
    scheme and boot scheme of the new drive, so that the changes will take effect when you boot from the new drive.

    6. If you have changed partition layouts (i.e., the root filesystem on the old drive was /dev/hda1 and now it's /dev/hda5), make yourself a boot disk that will mount root on the new drive's root partition. Red Hat provides a mkbootdisk command but if you've changed partition layouts you will need to edit the lilo.conf on the boot disk and re-run lilo on the boot disk. Or, you can pass the root device as a kernel command-line option, i.e., linux root=/dev/hda4

    7. umount the /mnt directory tree & shut down. Remove the old drive, install the new drive in the same logical spot that the old drive was in. i.e., if the old drive was IDE primary master, the new drive should take its place as IDE primary master.

    8. Boot from your boot disk. Hopefully the kernel will mount the right device as the root filesystem & your system will start up normally.

    9. Run /sbin/lilo (since you edited the lilo.conf in step 5 above, it should be
    correct) to write the boot sector to the new drive. Reboot from the hard disk this time to make sure it starts up properly without needing the boot floppy.
    - credit to Jim @ CLUE-Tech
    \"Everything should be made as simple as possible, but not simpler.\"
    Albert Einstein

  3. #3
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    Thanks, man. I'll let ya know what happens when it gets here.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •