Migrating Lenovo X220 to larger SSD including recovery partition

Goal

Migrating the factory SSD drive of a Lenovo X220 to a new, larger SSD drive keeping all partitions intact, especially keeping the recovery partition (Lenovo_Recovery, drive letter Q:) functional so that it's possible to boot into it with F11.

Even if you are a GNU/Linux user this has the benefit that you can restore the machine to its factory default state before selling it off.

Preamble

I will describe the steps that I did, trusting the you will be able to make suitable changes to accommodate your own set-up and needs. Please understand that I won't be able to answer question because I don't really have the expertise. I did this once and hope I won't have to do this ever again...

After spending quite a bit of time looking around for information on the Internet on how to accomplish such a migration, I could not find any decent instructions. Many posts mention "free" commercial tools, but I am not particularly happy if I have to rely on software that is not open source. I tried out the Samsung Data Migration 3.0 tool (http://www.samsung.com/global/business/semiconductor/minisite/SSD/global/html/support/downloads.html) that came with the new SSD drive -- and it's definitely not up to the task! To be fair, the smallprint says cloning of recovery partitions is not supported. Because of this I prepared the new SSD disk with a proper bootable Q: partition and then told the Samsung tool to not clone Q:, but instead of leaving it along it wiped it out... So, again, don't use it.

I only found one decent post related to the topic from Brad Erickson that got me started on the right track: http://eosrei.net/articles/2011/03/copy-functional-recovery-partition-new-hard-disk. You might find it useful as well.

Set-up

  • Lenovo X220 with the old, factory-shipped SSD drive (Intel SSDSA2BW160G3L, 160GB, 2.5" x 7mm, SATA II)
  • New SSD drive: Samsung SSD 850 PRO, MZ-7KE512BW, 512GB, SATA III
    • n.b.: All X220s are supporting SATA III, I believe.
  • USB-to-SATA-cable (it has 7+15 pins for power/data-connectors)
  • Put a Debian Live Install (https://www.debian.org/CD/live/) image on a 2GB USB stick.
# lsblk
...
sdb           8:16   1   1.9G  0 disk  
├─sdb1        8:17   1   264M  0 part  
└─sdb2        8:18   1   3.1M  0 part
...
    • Put the ISO image on the USB stick:
cp <file>.iso /dev/sdb

Layout of old SSD


The SSD has 3 partitions: One for the Windows drivers, a C: partition for the Windows OS and user data, and a Q: recovery partition (labeled Lenovo_Recovery). From GNU/Linux's perspective the disk looks as follows:
Device     Boot      Start           End  Sectors    Size   Id   Type
/dev/sda1     *       2048       3074047  3072000    1.5G    7   NTFS/exFAT
/dev/sda2          3074048     288002047 28492800  135.9G    7   NTFS/exFAT
/dev/sda3        288002048     312578047  2457600   11.7G    7   NTFS/exFAT

Migration steps


  • If you (still) have Windows on the X220, make a "Recovery Media". There is a dedicated Lenovo tool called "Create Recovery Media". Search for "recovery" on the Start menu in order to find it. Instruct the tool to use use an external USB drive. You can do this only once! In the creation process the USB drive gets formatted (to NTFS). The rescue media can then be accessed by pressing F12 during boot-up and selecting the USB drive as boot medium. You can still put your own files on the USB drive alongside the recovery data.

  • Leave old SSD in machine, connect new SSD with USB-to-SATA-cable.

  • Boot (F12) into Debin Live Install image and open a terminal window

  • Confirm with "lsblk" that old SSD is /dev/sda and new SSD is /dev/sdb.

  • Make an exact copy of the MBR and partition table:
dd if=/dev/sda of=/dev/sdb bs=512 count=1

  • Re-read partition table for /dev/sdb. You can reboot into Debian Live Install, or if its available, use
partprobe
  • or otherwise the following should work as well:
partx -u /dev/sdb

  • As a sanity check make sure the partition tables of both disks look the same:
partx -s /dev/sda ; partx -s /dev/sdb

  • Copy over all partitions:
dd if=/dev/sda1 of=/dev/sdb1 bs=1M
dd if=/dev/sda2 of=/dev/sdb2 bs=1M
dd if=/dev/sda3 of=/dev/sdb3 bs=1M
  • The copying takes around 3 hours and I had transfer speeds of about 30MB/s.

  • Sanity check: Put the new SSD into the machine -- it's straightforward, but if you are unsure consult the "X220 Hardware Maintenance Manual" -- and make sure that you can boot
    • into Windows and
    • into the recovery partition (F11).

  • Boot into the Debin Live Install Image and (install first and then) run "gparted" or use Gparted live (http://gparted.org/livecd.php).
    • You see (from left to right) /dev/sda1 directly followed by /dev/sda2, then a "hole" with unallocated sectors, then /dev/sda3, and finally another "hole".
    • Right-click on /dev/sda3 and select Resize/Move. In the dialog that pops up first move the right-pointing arrow to the very right and then move the left-pointing arrow to the very right. As a result the recovery partition is now at the very right of the layout and has a mimimum size (8.85 GiB). Keep the "Align to MiB" setting. Exit the dialog and execute the new layout with Edit -> Apply All Operations.

  • Sanity check: Reboot into Windows. You may see a message along the lines of
Checking file system [...]
[...]
CHKDSK is verifying files ...
[...]
  • After this -- keep your fingers crossed -- Windows will come up.

  • Sanity check: Reboot into recovery partition (F11).

  • Boot again into the Debin Live Install Image or Gparted live.
    • Right-click on /dev/sda2 and select Resize/Move. In the dialog that pops up move the right-pointing arrow to the very right to make this partition as big as possible. Keep the "Align to MiB" setting. Exit the dialog and execute the new layout with Edit -> Apply All Operations.

  • You are done. Again boot into Windows and the recovery partition to make sure that everything is fine.