I got a new HDD and want to move an existing Linux installation (more specific: OpenSUSE 11.1) from a partition on the old HDD to a partition on the new HDD.

My plan is:

  1. boot using a boot CD (let's say it's the OpenSUSE boot CD)

    EDIT As suggested by many people (thanks to all)
    1a. copy all of the files from one drive to the other

  2. modify /etc/fstab (add mount points to new partitions)
  3. modify /boot/grub/menu.conf (add boot partition)
  4. reinstall grub

Am I right? Is that's it?
Or did I mis some important step? (I'm pretty sure I did)

  • 1
    you missed the step of actually copying the files from the old partition to the new one. some might say that was fairly important :) – cas Aug 13 '09 at 0:22

I would say there is one thing you missed.

  1. boot using a boot CD (let's say it's the OpenSUSE boot CD)

    1a. copy all of the files from one drive to the other

  2. modify /etc/fstab (change mount points to new partitions)

  3. modify /boot/grub/menu.conf (change boot partition)
  4. reinstall grub

I would say if you set up the partition on the new drive to be compatible with the old setings, this should be pretty straightforward. It might be a little more complicated if you have to edit the mount point locations inside of the OS files. I would recommend keeping the partitions similar enough that all you must do is boot, mount the new drive, copy, change boot partition, re-install grub on new drive. remove old drive and you are done!

  • You have to be careful with the copying though. Use the -a option to cp. – Kim Aug 12 '09 at 23:55
  • 5
    or use rsync. it has the advantage that if anything interrupts the copy, you can just run rsync again and it will pick up from where it left off rather than starting over from the beginning. in order of preference, the right tools for this job are: rsync, tar, cp -a – cas Aug 13 '09 at 0:24
  • +1 The suggestion from Craig above is good advice indeed. – Axxmasterr Aug 13 '09 at 1:05

You need to copy files as Axxmasterr pointed out. Everything else looks right to me. Others have followed a very similar path: Moving a GNU/Linux installation to a new partition

Be careful with the cp command you use to copy files over. Use the -a option to ensure correct behaviour when you hit symlinks and preserve ownership information.

Some folks have used tar instead of cp to copy the files over to the new partition:

$ cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)

As suggested in the link at the start, you may want to leave the old entry in the grub file and just add a new one, in case you need to revert.

Good luck!

  • I recommend changing the semicolons in this command to && (conditional operators) so that the subsequent 'tar' commands won't be executed if the chdir() fails for any reason (typo, permissions, whatever). Also I recommend using the -S (--sparse) option with the 'tar' --create to enable handling of sparse files like some instances of /var/log/wtmp or /var/run/utmp, for example). – Jim Dennis Mar 15 '11 at 23:45

I think that will work.

If there's just the one partition on each hard drive, and the new disk is the same size or larger than the original disk, then a faster way is to just clone the old one (/dev/xxx, where xxx = your original disk sda, hdb, etc.) to the new one (/dev/yyy).

So the steps would be:

  1. Boot using a live cd
  2. sudo dd if=/dev/xxx of=/dev/yyy bs=32k

Make sure you get if (input file) and of correct, or you will clobber your entire old disk.

  • Doing dd will copy the file system as well, it might not be prepared for change in disk size (even if more space on new disk) – Joakim Elofsson Aug 13 '09 at 0:04
  • True, the cloned partition on the new disk will be the same size as the original partition on the old disk, so you'd need to expand it to use the full new disk (I'd use gparted). If you want to change filesystems as well then the "cp -a" approach mentioned in another answer is better. – Fred Hamilton Aug 13 '09 at 0:19
  • You can resize ext2-3-4 filesytems using resize2fs. Other file systems have similar tools. For ext it's also possible to reduce the size of the filesystem. I've always preferred this over cp/tar/dump approaches. – Kristof Provost Aug 13 '09 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.