![]() |
Cloning Partitions To A New Disk
I ran into a little bit of a problem the other day. My root partition got full. A year ago I would have thought it would never happen, but installing mythtv and a host of other applications just filled up the 25GB partition. I blame apt-cacher-ng for most of it, but it's helped save my bandwidth. The reason I'm doing this is because mI can't resize the partitions because /home is an XFS partition (for mythtv). I wanted a bigger root partition, but can't resize the current ones. Here's what you can do.
These instructions assume you have another hard drive that you're going to be cloning to. If not you can just change the of the dd command to backup.img.
The first thing you need to do is boot up from a livecd that has dd and gparted installed. Configure the partitions on the second disk how you want them. I went with a 100GB root partition (ext4), 3GB swap and the rest for the /home directory (XFS).
DO NOT MOUNT THE DRIVES! THIS CAN INTRODUCE ERRORS TO THE COPY BECAUSE OF READ/WRITES OF THE DISK.
Here are the commands in order:
sudo -s
dd if=/dev/sda1 of=/dev/sdb1 bs=64k
dd if=/dev/sda6 of=/dev/sdb6 bs=64k
Your partitions may not match. My root partition is sda1 and than I have an extended partition which has sda5 (swap) and sda6 (/home) in it.
So, you've cloned the disk (took 3 hours because it's 1TB). The next step is to install grub.
sudo grub
root (hd1,0)
setup (hd1)
quit
That will setup grub on your second disk. Now, if you choose to boot from that disk it will boot, but the partition won't show up as having a different size. You need to run this command before you reboot:
sudo fdisk /dev/sdb
and than press W. If this command doesn't show anything than DON'T PRESS W.
You should be good to go now. Reboot and boot off the second drive. Format the original drive and use it as your secondary storage.
If you have any problems just leave a comment.
- Content:

