Sunday, January 29, 2017

partitioning - How to copy GNU/Linux installation from a smaller partition to a bigger partition?




I got a new hard disk for my laptop and I want to move my Gentoo installation from old HDD to new.



Most simple guides recommend use of dd to copy the whole partition byte by byte.



I'm moving to the new drive because I don't have enough space on the old drive, so I don't want to simply clone the partition. Instead I need the destination partition to be bigger. Would dd work well in that case?



Assuming that I use same partition types on the new drive, would I be able to use simple cp with appropriate settings?


Answer



DD makes an identical copy and can't do partition resizing.




You can copy whole existing partitions to new, bigger ones using cpio, but my favourite way to do this is to use Clonezilla to make backup copies of the original partition/s and then restore them to the new drive, using the option to resize the destination partitions during the process - of course you need somewhere to store the image you make, so you either need a enough space on the original disk, an external drive or a network location.



The benefits of this method are that you take a backup copy of your original disk first, there's less risk of doing something horrendous with the DD command and (subject to how you make the backup), you can process the original drive, remove it and then fit the replacement - no need to have both drives fitted simultaneously, which may not be possible in the laptop anyway.



I use a liveCD version of Parted Magic as it contains a lot of other useful tools as well as Clonezilla.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...