Thursday, October 8, 2015

laptop - Migrating data to hard-drive replacement (linux)


My laptop hard drive was faulty so I requested and just received a new one. Now, I need to migrate my data over. This task seems easier said than done. The two drives are the same size, so I figure dd should work but I haven't seen explicit instructions on what exactly to do, and I'm scared for my data experimenting.


My setup is that these drives are 500gb and internal so I can only have one connected at a time. About 250gb on the hard drive is used. I have two partitions on the drive: a boot partition (50 megs), and a logical partition containing root (20gb), swap (8gb), home (435 gb). and reinstalling the operating system (gentoo) is not an option due to the fact that my bandwidth is severely limited right now. The only vehicle I have is an external USB hard drive with about 400gb capacity. I'm currently booted off of an ubuntu livecd in order to do the transfer.



  • Should I use dd to just copy the input drive into a file on the external HD? Or will this also try to allocate all the free space and thus not fit?

  • Will zipping everything a la dd if=/dev/sda bs=100M | gzip -c > /media/ext/image.img fix that issue?

  • Should I use dd to copy the /boot and / partition to a file on the external HD, and just copy my /home directory as files?

  • Will either of these options leave me in trouble with booting and/or grub or something on the new drive?


Thanks!
Mala


Answer



Yeah I'd take the dd approach. Back up your data first onto that external of yours.




  • Should I use dd to just copy the input drive into a file on the
    external HD? Or will this also try to
    allocate all the free space and thus
    not fit?



No. You can backup your drive as a regular imaged file, or even pipe to dd to gzip and back it up as a regular file. This way you save space:


dd bs=1024 if=/dev/sda conv=noerror,sync | gzip -9 > /mnt/usb/backup.dmg.gz

of course, replacing the drives appropriately.




  • Should I use dd to copy the / partition to a file on the external
    HD, and just copy my /home directory
    as files?



It depends. If you have a lot of custom configurations you don't want to lose, I'd just back up the whole thing. If not then your method would suffice.




  • Will either of these options leave me in trouble with booting and/or grub
    or something on the new drive?



If the drives are identical, and you use dd correctly, and plug the new drive in just like the other, you should be golden.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...