Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Dual Boot Cloned Drive Didn't Include Bootloaders

Need help with peripherals or devices?
Post Reply
Message
Author
jrredho
Posts: 13
Joined: 2015-03-03 18:00

[Solved] Dual Boot Cloned Drive Didn't Include Bootloaders

#1 Post by jrredho »

Hey All,

I recently bought an SSD for my lapton, an ASUS X202E, that came with Windows 8, got migrated on-line to Win 10, and that I dual boot with Debian Jessie (amd64) EFI.

I've looked around these forums, but I've got a semi-complicated story (sorry for that!) and haven't found anything that can help me sort out the mess. So on to the long story...

I tried to clone the working hard disk drive to the SSD, which is essentially the same 500GB size, using sgdisk to clone the GPT partition table on the drive and dd for the data partitions. I should say that the hard drive has several partitions, one of which is a separate, unencrypted Debian /boot partition; another of which is LUKS encrypted containing separate root, swap, and home partitions as LVM volumes. Unfortunately, when I tried to boot from this drive via a USB port before installing it, I killed the Grub bootloader info on the working drive, which was still installed in the laptop at that point. At least this is what I discovered when I physically installed the SSD into the laptop. I also discovered that I'd failed to include a clone of the MBR since it also couldn't find the Windows boot code!

So, I re-installed the original hard drive and re-installed Jessie, sort of---that's another, separate, long story---along with the GRUB2 efi bootloader info using the net installer's rescue mode, but I still want to migrate to the SSD. My question is this: I still have the cloned partitions, including the /boot and LUKS/LVM-encrypted partitions, on the SSD. And I also have the dual boot setup working fine on the old hard drive, which is currently installed in the laptop. Is there any way for me clone the dual boot-informed bootloader code, which, I guess this means the MBR-plus-pointer-to-GRUB-efi-bootloader, from the installed, working hard drive to the SSD without messing up any of the separate partitions that I think contain exactly the data I want them to already?

Any thoughts would be greatly appreciated!

thanks,
john
Last edited by jrredho on 2016-12-08 20:07, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Dual Boot Cloned Drive Didn't Include Bootloaders

#2 Post by Head_on_a_Stick »

jrredho wrote:using sgdisk to clone the GPT partition table on the drive and dd for the data partitions
That is rather confusing :?

Why not just use `dd`?

That would copy the partition table as well anyway.

What were the *exact* `dd` commands that you used?

What is the partition structure on the SSD now?

Code: Select all

# parted -l
jrredho wrote:Is there any way for me clone the dual boot-informed bootloader code, which, I guess this means the MBR-plus-pointer-to-GRUB-efi-bootloader, from the installed, working hard drive to the SSD without messing up any of the separate partitions that I think contain exactly the data I want them to already?
A UEFI system does *not* use the MBR of a disk to boot, the information required is stored on the motherboard NVRAM instead.

Read this for a full explanation:

https://www.happyassassin.net/2014/01/2 ... work-then/

tl;dr: you just need to create a new NVRAM entry for your system by following https://wiki.debian.org/GrubEFIReinstall
deadbang

jrredho
Posts: 13
Joined: 2015-03-03 18:00

Re: Dual Boot Cloned Drive Didn't Include Bootloaders

#3 Post by jrredho »

Hey Head_on_a_Stick,

Thanks so much for your quick reply!
Head_on_a_Stick wrote:
jrredho wrote:using sgdisk to clone the GPT partition table on the drive and dd for the data partitions
That is rather confusing :?

Why not just use `dd`?
Okay, good question, time for a bit of full-disclosure: the target SSD is about 20GB larger than the source hard drive. What I was going to try to do was to merge that disk space with another working partition. It was a theory that I didn't even get around to trying.
Head_on_a_Stick wrote: That would copy the partition table as well anyway.

What were the *exact* `dd` commands that you used?
What is the partition structure on the SSD now?

Code: Select all

# parted -l
The source hard drive has 9 partitions as does the target SSD. They appeared to me to be identical, but, unfortunately, I can't show the output currently, as the machine I'm booted on doesn't have enough USB ports close enough to allow me to attach the external drive enclosure. I'll post a followup shortly.
Head_on_a_Stick wrote:
jrredho wrote:Is there any way for me clone the dual boot-informed bootloader code, which, I guess this means the MBR-plus-pointer-to-GRUB-efi-bootloader, from the installed, working hard drive to the SSD without messing up any of the separate partitions that I think contain exactly the data I want them to already?
A UEFI system does *not* use the MBR of a disk to boot, the information required is stored on the motherboard NVRAM instead.

Read this for a full explanation:

https://www.happyassassin.net/2014/01/2 ... work-then/

tl;dr: you just need to create a new NVRAM entry for your system by following https://wiki.debian.org/GrubEFIReinstall
Wow, thanks so much for those links. I may have looked through the first one some time in the distant past and I've definitely looked at the second, but clearly forgot to re-visit either in my state of semi-panic. :)

However, I'm still in somewhat the same boat: I'd like to clone the native bootmanager/bootloader for windows *and* the Debian Grub EFI bootmanager/bootloader. You've shown me how to do the second, for which I'm eternally grateful, but I'm still hoping someone here may have a suggestion on the windows piece as well. I really want to return to the SSD data as I clobbered my (somewhat-developed) Debian installation while on my crazy bootloader repair path.

Also, I owe you a followup to show the partition table for the SSD. That's coming soon...

Thanks again!

john

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Dual Boot Cloned Drive Didn't Include Bootloaders

#4 Post by Head_on_a_Stick »

jrredho wrote:I'd like to clone the native bootmanager/bootloader for windows *and* the Debian Grub EFI bootmanager/bootloader. You've shown me how to do the second, for which I'm eternally grateful, but I'm still hoping someone here may have a suggestion on the windows piece as well.
The Windows bootloader is on the EFI system partiton at $ESP/EFI/Microsoft/Boot/bootmgfw.efi -- the ESP will have been mounted to /boot/efi in your Debian system and will be the only FAT-formatted partition (probably).

The good news is that UEFI firmware should automatically generate a UEFI boot entry for that file :)

The bad news is that some don't :(

If your firmware does not do this, try:

Code: Select all

# efibootmgr -c -d /dev/sdX -p Y -L "Windows" -l /EFI/Microsoft/Boot/bootmgfw.efi
https://packages.debian.org/jessie/efibootmgr

Replace X with the letter assigned to your main drive (probably a) and replace Y with the number assigned to the EFI system partition.
deadbang

jrredho
Posts: 13
Joined: 2015-03-03 18:00

Re: Dual Boot Cloned Drive Didn't Include Bootloaders

#5 Post by jrredho »

Hey Head_on_a_Stick,

You continue to put pure gold in this thread, and I thank you again for sticking with me.

First some old business, here is the result of running parted -l on the laptop whose disk I'm trying to clone with the SSD attached via usb:

Code: Select all

root@jrredho-lt2:~# parted -l /dev/sdb
Model: ATA Hitachi HTS54505 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                          Flags
 1      1049kB  316MB   315MB   fat32        EFI system partition          boot, esp
 2      316MB   945MB   629MB   ntfs         Basic data partition          hidden, diag
 3      945MB   1079MB  134MB                Microsoft reserved partition  msftres
 4      1079MB  306GB   305GB   ntfs         Basic data partition          msftdata
 7      306GB   307GB   210MB   ext2         LinuxBoot                     msftdata
 8      307GB   478GB   172GB                EncryptedDisk                 msftdata
 5      478GB   479GB   367MB   ntfs                                       hidden, diag
 6      479GB   500GB   21.5GB  ntfs         Basic data partition          hidden, diag

Model: Crucial_ CT525MX300SSD1 (scsi)
Disk /dev/sdb: 525GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                          Flags
 1      1049kB  316MB   315MB   fat32        EFI system partition          boot, esp
 2      316MB   945MB   629MB   ntfs         Basic data partition          hidden, diag
 3      945MB   1079MB  134MB                Microsoft reserved partition  msftres
 4      1079MB  306GB   305GB   ntfs         Basic data partition          msftdata
 7      306GB   307GB   210MB   ext2         LinuxBoot                     msftdata
 8      307GB   478GB   172GB                EncryptedDisk                 lvm
 5      478GB   479GB   367MB   ntfs                                       hidden, diag
 6      479GB   500GB   21.5GB  ntfs         Basic data partition          hidden, diag
 9      500GB   525GB   25.0GB  ext4

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/VG-swapvol: 7999MB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system     Flags
 1      0.00B  7999MB  7999MB  linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/VG-homevol: 144GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End    Size   File system  Flags
 1      0.00B  144GB  144GB  ext4

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/VG-rootvol: 20.0GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  20.0GB  20.0GB  ext4

Error: /dev/mapper/sda8_crypt: unrecognised disk label
Model: Linux device-mapper (crypt) (dm)                                   
Disk /dev/mapper/sda8_crypt: 172GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags: 

root@jrredho-lt2:~#
Secondly, believe it or not, I still have a question on your final point:
Head_on_a_Stick wrote:
jrredho wrote:I'd like to clone the native bootmanager/bootloader for windows *and* the Debian Grub EFI bootmanager/bootloader. You've shown me how to do the second, for which I'm eternally grateful, but I'm still hoping someone here may have a suggestion on the windows piece as well.
The Windows bootloader is on the EFI system partiton at $ESP/EFI/Microsoft/Boot/bootmgfw.efi -- the ESP will have been mounted to /boot/efi in your Debian system and will be the only FAT-formatted partition (probably).

The good news is that UEFI firmware should automatically generate a UEFI boot entry for that file :)

The bad news is that some don't :(

If your firmware does not do this, try:

Code: Select all

# efibootmgr -c -d /dev/sdX -p Y -L "Windows" -l /EFI/Microsoft/Boot/bootmgfw.efi
https://packages.debian.org/jessie/efibootmgr

Replace X with the letter assigned to your main drive (probably a) and replace Y with the number assigned to the EFI system partition.
The problem is that when I put booted the Windows recovery usb I'd made back when I first got the system, which was for Windows 8, and followed the directions I found on some Windows-related forums, Windows recovery could find no installed versions of Windows on the SSD. Is your thought that maybe efibootmgr might be an alternative that could find it?

Many thanks again,
john

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Dual Boot Cloned Drive Didn't Include Bootloaders

#6 Post by Head_on_a_Stick »

jrredho wrote:The problem is that when I put booted the Windows recovery usb I'd made back when I first got the system, which was for Windows 8, and followed the directions I found on some Windows-related forums, Windows recovery could find no installed versions of Windows on the SSD. Is your thought that maybe efibootmgr might be an alternative that could find it?
No, that command just creates & modifies NVRAM entries on your motherboard.

You can check for the bootmgfw.efi Windows bootloader on /dev/sdb1 (as listed in your output):

Code: Select all

# mount /dev/sdb1 /mnt
# find /mnt -name bootmgfw.efi
# umount -R /mnt
Otherwise, I would suggest pursuing this query on a Windows forum, I suspect there may be licensing issues here and I am fairly ignorant of Windows boot mechanics anyway.
deadbang

jrredho
Posts: 13
Joined: 2015-03-03 18:00

Re: Dual Boot Cloned Drive Didn't Include Bootloaders

#7 Post by jrredho »

Head_on_a_Stick wrote: No, that command just creates & modifies NVRAM entries on your motherboard.

You can check for the bootmgfw.efi Windows bootloader on /dev/sdb1 (as listed in your output):

Code: Select all

# mount /dev/sdb1 /mnt
# find /mnt -name bootmgfw.efi
# umount -R /mnt
Otherwise, I would suggest pursuing this query on a Windows forum, I suspect there may be licensing issues here and I am fairly ignorant of Windows boot mechanics anyway.
Okay, got it. When I followed your directions, that file was found in EFI/Microsoft/Boot.

It sounds like a lot of what I stumble/fumble did actually was successful and maybe, just maybe, the only remaining issue is with the MBR itself? I tried to copy this explicitly as well when all of this first started. The hex dumps of sector 1 looked to me to be identical. Maybe, as you suggested, this is all about the licensing issue. For that it's on to the Windows forums.

Thanks again so much for all your help on this. If I could buy you a beer, I'd do it. :)

I'll look over the material on the links you pointed me to in your first post. These issues with the bootloaders getting stepped on happen somewhat regularly since I try to do Debian installs/upgrades on the LUKS/LVM setup while keeping my /home partition.

Cheers!

john

Post Reply