As I am running a Linux VDR installation with an old IBM Deskstar 40GB harddisk. The problem with this harddisk is that it is very small when you use VDR's autotimer functionality and it is far too loud for my living room. My new harddisk is a Samsung SP2514N with 250GB. This drive is very silent. When it is switched on you are wondering if it is really running. But how to copy the old installation to the new harddisk without a fresh and clean installation with all the hassle? Two tools made my day recently:
Warning: Backup your data before you try any of the procedures described below! You have been warned!
You must start your computer with some live CD Linux system that has this tools installed because you cannot copy a filesystem that is mounted. I have used Knoppix for that purpose.
This procedure might work with other filesystems than ext2/ext3 as well (they must be resizable though). Step 4 differs for other filesystem types.
Step 1: Install the new harddisk
You need both the old and the new harddisk in the same computer. I installed my new harddisk as secondary slave (hdd). The old harddisk is the primary master (hda). We change that after we have copied all the data to the new disk. Boot up with Knoppix
Step 2: Create the partitions on the new harddisk
Use fdisk -l /dev/hda to print out all partitions on the disk. Write everything down or print it out. Use mount to find out which partition is your root-filesystem (mounted to /). You need this info in step 6. Now create on the new disk the same partition layout as on the old disk. These partitions need to be equal the size or larger than the old partitions. Swap partitions need to be prepared with mkswap /dev/hddx.
Step 3: Copy the data to the new harddisk
For every partition (skipping swap partitions) do the following:
dd_rescue /dev/hdax /dev/hddx
fsck -f /dev/hddx
Step 4: Resize the filesystems
Now it is time to resize the filesystems to the new partition sizes. Do the following for all the partitions on the new disk (skipping swap partitions again):
resize2fs -p /dev/hddx
Step 5: Remove the old harddisk
Now it is time to say goodbye to your old harddisk. Jumper the new harddisk to the same configuration as the old one and connect it to the cable-plug of the old harddisk. Shut down your computer before you do that! After that boot up with Knoppix again.
Step 6: Install the bootloader on the new harddisk
Now mount your root filesystem partition (it was hda2 in my case): mount /dev/hda2 /mnt And chroot to that mounted directory: chroot /mnt The next step depends on which bootloader you use. There are two possible ones: lilo and GRUB. In the lilo case just execute the command lilo. You should see something like "Linux added". In the case of GRUB execute grub-install.
So that's it. You should now enter reboot and see your new harddisk booting your old installation.




Great!
Great article! Had a new harddisk running in no time. Thanks for writing!!
Post new comment