While the Debian documentation has good information on partitioning and formatting hard drives, it had relatively little information on migrating system data from one drive to another. I found three good sites that helped me get through the process:
- Reactor Core: Migrating your system to another harddrive
- Linux Home Networking: Expanding disk capacity
- Tech Republic: Add a hard drive Q&A
I didn't find any resources online that specifically walked me through how to move /var, so I integrated the pages' advice and gave it a go. Here's what I did (as with my prior Debian posts, if you're looking for help, remember that I'm a complete novice):
- I backed up all my critical data, including the entire /var directory, and then installed the new drive into the machine.
- I determined that the new drive was /dev/hdb (done by "cat /proc/partitions").
- I used "cfdisk /dev/hdb" to partition the drive and "mkfs /dev/hdb1" to format the new partition.
- I entered single-user mode by running "init 1" from the console.
- I mounted the new partition to /mnt/hdb1 (first creating the directory /mnt/hdb1, then using "mount /dev/hdb1 /mnt/hdb1").
- I copied everything in /var to the new drive, using "cp -pr * /mnt/hdb1" from the /var directory.
- After verifying that everything seemed to be OK, I added a line to /etc/fstab so the new drive would be mounted as /var. The line was "/dev/hdb1 /var ext2 defaults 1 2"
- I renamed /var to /var-old ("mv /var /var-old"), created a new, empty, /var directory, and then ran "mount -a" to mount the new drive based on the fstab line.
- I exited single user mode ("exit"), and that was it!
I was impressed with how relatively easy the entire process was; it took less than half an hour from start to finish, not including research time. Now that I've got the drive mounted, the transition from one hard drive to the other is completely seamless; /var looks and acts like any other directory, yet it's on a completely different physical drive.
Ah, the wonders of Linux.