How to replace your laptop’s harddisk with a SSD without having to reinstall linux

I just finished a major heart surgery on my laptop. Many thanks to the guys who made some youtube tutorials about taking that laptop apart! The Acer E5-571G is definitely NOT built to be taken (apart) lightly (Here is the german tutorial that I was following, and here is an english one).

After swapping out the 2x 4G memory modules for 2x 8G ones, and the 1TB laptop hard disk drive for a 1TB SSD disk, and putting everything back together, the real fun began:

  • install the old harddisk in an external USB3.0 harddisk enclosure (the drive was still good after all)
  • boot from a Windows 10 installer
  • partition the disk and install Windows 10 in about half of the available space
  • the usual windows installation hijinx: install a driver, reboot, repeat ad nauseam
  • when windows is about done with the initial installation stuff, plug in the old harddisk on USB3.0 and copy the data from your old user account to your new

Then the linux fun begins, but be aware that this method will only work if the existing linux installation on the old disk was based on a LVM setup!

  • boot from openSUSE 13.2 installer DVD, but boot into rescue mode!
  • partition the unused space on the new disk as follows:
    • 250MB /boot
    • one LVM physical volume from the remaining space, but do not create the actual PV yet
  • plug in the old disk again
  • mount the /boot partition from the old system somewhere
  • create ext4 filesystem on the new /boot partition, and mount it somewhere
  • rsync the content of the old /boot to the new one
  • unmount the old and new /boot partitions
  • check that you can see and access your old logical volumes via the usb3 connection to your old disk (lvs, lvdisplay, vgs, vgdisplay, pvs, pvdisplay)
  • now create a PV on the new partition that you created a few steps ago
  • add that PV to the volumegroup on your old disk
  • move all used extents away from the old disk with pvmove
  • once this is done you can remove the pv that is located on the old disk, unplug the disk and use it for something else.
  • make sure the /boot partition on the new disk is not mounted
  • mount your root volume to /mnt
  • prepare your mounted root for chroot
    mount -o bind /dev /mnt/dev
    mount -o bind /sys /mnt/sys
    mount -o bind /proc /mnt/proc
  • Change into your installed system with chroot
    chroot /mnt /bin/bash --login
  • Edit /etc/fstab, make sure all references to mounted filesystems are correct (partition label/identifer for the EFI partition, UUID for /boot, etc)
  • regenerate the initrd with mkinitrd
  • recreate the grub2 configuration with grub2-mkconfig
  • reboot, enter the BIOS setup, go to the UEFI boot settings and make sure the boot order is correct and secure boot is OFF.
  • the next reboot should get you into a working GRUB2 that lets you boot linux but not windows, so boot linux, start yast2 and reinstall the grub bootloader again from there.

That’s it folks!

Leave a Reply

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

%d bloggers like this: