Moving FreeBSD to a new hard drive.

The hard drive in my laptop was showing signs of failing, so I decided to replace it. I took the opportunity to upgrade from a 30GB/4200 rpm drive to a 60GB/5400 rpm drive. I am looking forward to seeing if there is a significant performance boost from the faster drive. There are many howtos out there that talk about transferring FreeBSD to another system, but the ones I found where all on desktop machines where they could just hook up both drives at the same time. In my case, I have a laptop. Therefore, I can only hook up one drive at a time without purchasing new equipment so this guide is for all those who are in my situation.


The basic idea is to use tar to compress the various partitions, somehow copy the archives somewhere, replace the drive, install the base system, copy the archives onto the new drive and decompress them to restore the original file system. I decided on this approach because I can change partition sizes without any problem. To transfer the archives, I used samba this time to copy them to a windows machine, but I have also done it with ftp. So let's get into it.

First thing was to burn all important data to CDs or DVDs just in case something happened while I was transferring the archives. Since I am reinstalling the base system, I decided not to archive any of that. I decided to use bzip2 compression since that generally results in the smallest files, in my experience. Here is the command I used:

tar -cjf home.tar.bz2 /usr/home

I compressed the following directories:
/usr/home
/usr/local
/usr/X11R6
/usr/compat
/usr/var
/root
/boot
/var
/tmp
/etc

After arcviving the above directories, I copied them to a Windows XP Professional box. At first, I tried to copy to a box with XP Home installed, but I could never succesfully transfer any files. Finally, I tried on the XP Pro box, and had no problems. If there had a been a *nix box available or a fat32 partition, I would have used *nix. But I was stuck with windows.

After copying all the files, I replaced the hard drive and booted into the BIOS to make sure the new drive was recognized correctly. It was, so I fired up the FreeBSD 6.1 install CD and started the standard install process.

I created two primary partitions. The first one was set as a DOS FAT partition and was big enough to be used as a hibernate partition because that is the way hibernate works on this machine. The rest of the drive went to FreeBSD. After setting up the partitions and the disk labels, I installed just the base system, the GENERIC kernel, and man pages. I also turned on inetd and enabled the ftp server with anonymous access because there was no samba on the laptop now. It took about 10 minutes to do all that. I was ready to copy the archives back on to the laptop and extract them.

I then connected to the ftp server and copied my archives back over. It is important to make sure the ftp mode is set to binary and not ascii when copying the archives over ftp.

The first file to be extracted was etc.tar.bz2 because it would set up my users and groups so that tar would then set the correct permissions on everything else. After extracting all the archives to the appropriate directories, I rebooted and my system was back to normal. The whole process took about 5 hours which consisted mostly of waiting for things to be compressed/decompressed and sent over the network.

Comments

Popular posts from this blog

Work standing up

Recording the iPhone screen and Mac screen at the same time in one video

Dual boot with Windows XP using BOOT.INI