Score:1

How to restore grub after cloning hard disk for a dual boot laptop

jp flag

I had a dual boot (Windows/Linux) laptop with a 500GB SSD, and replaced the SSD with a 1TB SSD using the procedure described below. When I reboot, it boots directly into Windows, without grub menu. Why did this happen, and how can I restore the grub menu?

This is what I did:

  1. Boot the laptop from a live bootstick (running Linux Mint)
  2. Use dd to copy the whole 500GB SSD to a network drive
  3. Shut down the laptop and replace the SSD by a 1GB SSD.
  4. Boot again with a live bootstick and use dd to copy the file on the network drive back to the SSD.
  5. Reboot without live bootstick

I know that this leaves half of my new SSD unused; I was hoping to fix that later.

dd worked correctly, or at least I can mount all partitions including live partitions from a bootstick. This is the output of fdisk -l:

Disk /dev/loop0: 1.8 GiB, 1912557568 bytes, 3735464 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


GPT PMBR size mismatch (1000215215 != 1953525167) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/nvme0n1: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: KINGSTON SKC2500M81000G                 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 282E2059-1738-4156-802F-50E4A4E71652

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1026047   1024000   500M EFI System
/dev/nvme0n1p2   1026048    1288191    262144   128M Microsoft reserved
/dev/nvme0n1p3   1288192  205020339 203732148  97.2G Microsoft basic data
/dev/nvme0n1p4 205021184  206086143   1064960   520M Windows recovery environment
/dev/nvme0n1p5 206088192  214087679   7999488   3.8G Linux swap
/dev/nvme0n1p6 214087680  969730047 755642368 360.3G Linux filesystem
/dev/nvme0n1p7 969730048  970651647    921600   450M Microsoft basic data
/dev/nvme0n1p8 970651648  997961727  27310080    13G Windows recovery environment
/dev/nvme0n1p9 997961728 1000204287   2242560   1.1G Windows recovery environment


Disk /dev/mapper/vg-root: 60 GiB, 64424509440 bytes, 125829120 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 /dev/mapper/vg-home: 300.32 GiB, 322462285824 bytes, 629809152 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 /dev/sda: 14.93 GiB, 16008609792 bytes, 31266816 sectors
Disk model: Cruzer Blade    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5b137364

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *          0  3974271  3974272  1.9G  0 Empty
/dev/sda2           632     8567     7936  3.9M ef EFI (FAT-12/16/32)
/dev/sda3       3977216 31266815 27289600   13G 83 Linux

I have tried to reinstall grub using the following commands (from the live bootstick). These commands helped to restore grub after an earlier Windows update, and they ran without errors, but did not restore grub this time.

mount /dev/mapper/vg-root /mnt
mkdir /efi
mount /dev/nvme0n1p1 /efi
grub-install --directory=/mnt/usr/lib/grub/x86_64-efi --boot-directory=/mnt/boot --efi-directory=/efi

Could the problem be caused by a different UUID for the new disk? I may be wrong, but AFAIK, disk UUIDs are stored on the disk itself so should have been cloned together with the rest of the data. So, what could be wrong and how can I reactivate grub?

Here are some hardware details:

Laptop: Dell XPS 15 (9550)

Old SSD: PM951 NVMe SAMSUNG 512GB

New SSD: Kingston Technology KC2500 M.2 1000 GB PCI Express 3.0 3D TLC NVMe

Pastebin link: http://paste.ubuntu.com/p/DkMGvNXdYq/

oldfred avatar
cn flag
What brand/model system? Lets see details, use ppa version with your live installer (2nd option) or any working install, not Boot-Repair ISO: Please copy & paste the pastebin link to the Boot-info summary report ( do not post report), do not run the auto fix till reviewed. https://help.ubuntu.com/community/Boot-Repair
jp flag
@oldfred Sorry I am somewhat confused by your request; what is "ppa version", and should or shouldn't I download and run a boot repair ISO?
jp flag
@oldfred OK, figured it out, pastebin link added. This is the first time I used boot-repair and pastebin, sorry for my confusion
oldfred avatar
cn flag
This is an Ubuntu official flavors question & answer site. As soon as they see it is Mint which is an unofficial version of Ubuntu, they will close this question. I do not know LVM, but do not see anything major. Did you have UEFI Secure Boot on before? And you have an old BIOS boot version of grub in MBR which with new drive should not even be there, but not a problem as long as you do not try to boot with BIOS mode. See https://unix.stackexchange.com/ or https://ubuntuforums.org/forumdisplay.php?f=446
jp flag
@oldfred OK sorry I didn't know this was Ubuntu only, it was the forum where I saw most related posts. Do you suggest I re-post on one of the other two forums?
jp flag
@oldfred About your other questions: I am not sure. I have a limited understanding of the different boot options, not sure what UEFI Secure Boot or Bios boot version of grub are. I want a reliable way to boot Windows or Linux, and if I need to learn more to achieve that, I will do it; I will take any advice you have.
oldfred avatar
cn flag
Better to post else where. I do not know LVM nor Mint as I use Kubuntu with standard partitions. And do not really know Windows issues.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.