|< Day Day Up >|
Move your complete system to a new hard drive .
Not only do hard drives hold your programs and data, but they fill up and run out of free space sooner than you would like. When this happens, it's time to buy a larger hard drive and migrate the system. While there are many different ways to copy files from one hard drive to another, some work better than others when transferring the full / directory. This hack outlines a method to transfer full systems and partitions from one machine to another.
6.11.1 Why This Can Be Complicated
When you copy a full Linux system from one partition to another, there are a few issues you need to consider:
Knoppix removes some of these complications. For instance, if you are booting on top of a system, you no longer have to worry about whether the copy method spans filesystems, because each filesystem is mounted under /mnt only when you choose to mount it.
6.11.2 What to Do
The best method to copy the / filesystem combines find with cpio (both are utilities that are standard on any Linux distribution, including Knoppix). This example transfers a Linux installation from a single-root partition on /dev/hda1 to /dev/hdb1 , which is a freshly formatted partition that becomes the new root partition:
knoppix@tty0[knoppix] sudo mount /mnt/hda1 knoppix@tty0[knoppix] sudo mount -o rw /mnt/hdb1 knoppix@tty0[knoppix] cd /mnt/hda1 knoppix@tty0[hda1] sudo sh -c "find ./ -xdev -print0 cpio -pa0V /mnt/hdb1 "
This example uses /mnt/hda1 and /mnt/hdb1 , but you should change those values to the two partitions you are using. When you run this command, it recursively copies everything on the /mnt/hda1 filesystem, without crossing over into other mounted partitions. It properly handles any special files, and it completely preserves permissions. For each file that is copied, this command prints out a single dot to the screen, so you get a sense of the progress. If you want more specific information on the progress, use the watch command in a different terminal:
knoppix@tty0[knoppix] watch df
The watch command runs df every two seconds and allows you to compare the used and available space on both the old and new partitions.
If you have other filesystems mounted on other partitions, you simply repeat the command and replace hda1 and hdb1 with the new partitions you want to copy from and migrate to, respectively.
After the partitions have been migrated , edit the /etc/fstab file on the new partition if any partition numbers have changed. Remember to change /etc/fstab entries to reflect the partition letters the new drive has once it is moved to its final bus location, not the partition letter it is currently assigned.
You must also restore the boot loader to the new partition. Follow the steps in [Hack #2] or [Hack #53] , depending on your boot loader. Once the boot loader is restored, halt the machine, swap the old drive with the new drive, and boot the machine from the new partition and make sure everything has copied over correctly before wiping the old drive and using it for something else.
I have used this method to copy numerous systems from one drive to another, to transfer to a larger partition or a new filesystem, and even to move to software RAID5 (and back). While the options passed to find and cpio seem daunting at first, I have found this command so useful that it has become engrained in my memory. I usually run this command directly from the system being copied in single- user mode, but it's not necessary. When you use Knoppix, you also don't have to worry about whether files have changed since you started copying them. In addition, while the files are copying, you can browse the Web or play games if watching df output bores you.
|< Day Day Up >|