Do Linux swap partitions need to be cloned?

1

I'm in the process of cloning my hard disk in order to test some unstable software.

One of the partitions is Linux-swap. From my understanding, it can be used by the os as additional ram. So this does not need to be cloned right?

Additionally: The disk I have has a capacity ~120 GB, while my original drive is ~250GB (though only about 70 GB are used). Since I can not dd, I created the partitions manually and I'm currently using rsync to "clone" the partitions. Is this the best way to do it? How do I make it bootable?

Nate

Posted 2012-01-30T05:39:56.453

Reputation: 21

Answers

1

It doesn't need to be cloned. It simply contains whatever was at certain memory locations when you unmounted that swap partition (or it may have been wiped for security). It doesn't contain any sensitive information.

As for the migration question, you can resize the partitions on the original disk first (you can do that with gparted) so that it fits in the new disk, making sure it still works (boot the system), and then dd'ing that to the new disk. (I highly recommend you make a per-bit backup of the 250 GB disk before you resize the partitions on it.. Better yet, resize the partition on the backup.)

Otherwise, rsync may work (and be a little safer in that it doesn't require you to fiddle with the existing system) but indeed your new drive won't be bootable. You'll then need to reinstall the bootloader (I'm assuming grub); this can simply be done by booting on your favorite LiveCD and running grub-install on the correct device (grub-install /dev/sdX)

Etienne Perot

Posted 2012-01-30T05:39:56.453

Reputation: 272

That's what I thought; also because I never see swap partitions mounted anywhere. But won't copying /boot to the first partition and making that partition bootable work? – Nate – 2012-01-30T13:51:42.630

That won't copy the MBR, so when it starts it won't know where to look for the boot information. – Rob – 2012-01-30T15:26:31.483