Changing disk on a laptop and copy restore partion to new disk

Tags: No Tags
Comments: No Comments
Published on: June 7, 2012

Nowadays computers doesn’t come with installation media but a restore partion on the computer disk. Here I’ll show you how to make a copy of the restore partion to the new disk and start a restor from it

The computer used in this tutorial was a Acer Aspire 7750G

There are serveral way of doing this. I have choosen to make a bootable Ubuntu USB stick to do the job.

Creating a bootable USB stick with Ubuntu

 

Booting up Ubuntu

 

Do the cloning of disk

When the bootup is finished and you have a Ubuntu desktop running on the computer press CTRL+ALT+T to open upp a terminal window.

In this tutorial the new disk is the first ( as it would be C: ) and the origial disk is the second disk ( as it would be D:). In unix they have the names /dev/sda and /dev/sdb (if you are using SATA or in old machine with IDE they would be named /dev/hda and /dev/hdb)

Impotant that you don’t mix which is the original (source) disk with the empty disk. Normaly the disk mounted inside the maskin is the first i.e /dev/sda and any external will be named /dev/sdb , /dev/sdc …

In this tutorial I have mounted the new disk inside the maskin and the original outside.

type

sudo fdisk -l /dev/sda
sudo fdisk -l /dev/sdb

If the new disk is empy the ouput should be something like

ubuntu@ubuntu:~$sudo fdisk -l /dev/sda
Disk /dev/sda: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x06558168 Device Boot Start End Blocks Id System

and the second disk

ubuntu@ubuntu:~$sudo fdisk -l /dev/sdb
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x06558168 Device Boot Start End Blocks Id System /dev/sdb1 2048 31459327 15728640 27 Hidden NTFS WinRE /dev/sdb2 * 31459328 31664127 102400 7 HPFS/NTFS/exFAT /dev/sdb3 31664128 488397167 228366520 7 HPFS/NTFS/exFAT 

 

We start by copy the MBR and partion table with the following command

ubuntu@ubuntu:~$dd if=/dev/sdb of=/dev/sda bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0,0019642 s, 261 kB/s

WARNING!! Be sure that the if (source) and of (destination) is correct, otherwise you will whipe the partiontable and MBR from the working disk

doing sudo fdisk -l /dev/sda will now show the same layout as the original

ubuntu@ubuntu:~$ sudo fdisk -l /dev/sda

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x06558168

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    31459327    15728640   27  Hidden NTFS WinRE
/dev/sda2   *    31459328    31664127      102400    7  HPFS/NTFS/exFAT
/dev/sda3        31664128   488397167   228366520    7  HPFS/NTFS/exFAT

Probably are the two disks not of the same size so the size of the last partion (the one where windows will be installed) is wrong. Using the commands i fdisk this is fixed like this

ubuntu@ubuntu:~$ sudo fdisk /dev/sda

Command (m for help): d
Partition number (1-4): 3

Command (m for help): n
Partition type:  
p primary (2 primary, 0 extended, 2 free)  
e extended Select (default p): <- press RETURN
Using default response p
Partition number (1-4, default 3): <- press RETURN
First sector (31664128-234441647, default 31664128): <- press RETURN
Last sector, +sectors or +size{K,M,G} (31664128-234441647, default 234441647): <- press RETURN 

Command (m for help): t  <- change type to NTFS
Partition number (1-4): 3
Hex code (type L to list codes): 7

Command (m for help): w <- write changes and exit
The partition table has been altered! 

Calling ioctl() to re-read partition table.
Syncing disks.

The new disk has been modified to fit the new size. Now we need to copy the hidden restore partion by issuing

ubuntu@ubuntu:~$sudo dd if=/dev/sdb1 of=/dev/sda1 bs=4096 conv=notrunc,noerror
3932160+0 records in
3932160+0 records out
16106127360 bytes (16 GB) copied, 153,062 s, 105 MB/s

Once again, be sure that you are coping in the right direction

Now we are almost there, the only thing to do now is to set hidden partion as default boot

ubuntu@ubuntu:~$ sudo fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x06558168

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    31459327    15728640   27  Hidden NTFS WinRE
/dev/sda2   *    31459328    31664127      102400    7  HPFS/NTFS/exFAT
/dev/sda3        31664128   234441647   101388760   83  Linux

The * shows which partion that’s active, remove the 2nd and put 1st as boot

Command (m for help): a
Partition number (1-4): 2   <- remove from 2nd   Command (m for help): a Partition number (1-4): 1  <-set for 2st Command (m for help): p Disk /dev/sda: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x06558168 Device Boot Start End Blocks Id System /dev/sda1 * 2048 31459327 15728640 27 Hidden NTFS WinRE /dev/sda2 31459328 31664127 102400 7 HPFS/NTFS/exFAT /dev/sda3 31664128 234441647 101388760 83 Linux 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Welcome , today is Tuesday, November 21, 2017