Backup one internal drive to another internal drive

I have a Dell Inspiron 3521 that came preinstalled with Windows 8.1. I decided to dual-boot Ubuntu and Windows and till the last week it was working perfectly. But, since yesterday I am unable to use Windows as it is really slow. However, Ubuntu works fine and smooth. I ran the Dell ePSA test and got a 2000-0142 error code, which is indicative of a hard-drive failure. So, if my HDD has really failed or is about to fail, how can I backup everything onto an external drive. Note that my Ubuntu and Windows are installed on the same drive and I am unable to use Windows.

EDIT: Contacted Dell, product is in warranty and they are giving me a new internal HDD. So the question is how can I backup my current drive to the new one, i.e, data from current hard drive to the new one that I’ll get.

Answer

Given the fact that your original disk was failing I would recommend against dumping the old disk to the new one. I would just copy the files that I need from the old one and that’s that.


If you still want to copy the old drive to the new one this is what I would do:

  1. Connect both disks at the same time to the same computer
  2. Boot with an Ubunutu CD/DVD
  3. Find out which drive is the old one and which one is the new one. Probably one will be /dev/sda and the other will be /dev/sdb. YOU MUST CHECK THIS properly or you will risk erasing all your data.
  4. Open a console and type this command (change /dev/sda and /dev/sdb to where your disks are; this example assumes that sda is the old disk and sdb is the new drive):

    dd if=/dev/sda conv=sync,noerror bs=64K of=/dev/hda
    

If you cannot connect both drives at the same time, you will need an external drive (or network drive) where you will store the disk image:

  1. Boot with an Ubunutu CD/DVD
  2. Connect the external drive/network drive
  3. Find out which drive is the old one and what folder is the external drive mounted to. Probably the drive will be /dev/sda and the other will be something like /media/user/XXXXXX. YOU MUST CHECK THIS properly or you will risk erasing all your data.
  4. To make the backup open a console and type these commands (change /dev/sda and /media/user/XXXXXX to where your disks are; this example assumes that sda is the old disk and /media/user/XXXXXX is a mounted backup directory):

    dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c  > /media/user/XXXXXX/sda.img.gz
    
    fdisk -l /dev/sda > /media/user/XXXXXX/sda_fdisk.info
    
  5. Remove the old disk and plug the new one in, boot to an Ubuntu CD/DVD and enter this command:

    gunzip -c /media/user/XXXXXX/sda.img.gz | dd of=/dev/sda conv=sync,noerror bs=64K
    

File /media/user/XXXXXX/sda_fdisk.info will contain some interesting information, such as cylinder size, etc, in case you need them.

You can see more information regarding this issue here:
http://debianhelp.co.uk/ddcommand.htm

Attribution
Source : Link , Question Author : LakshyaAg , Answer Author : Calabacin

Leave a Comment