Recovering a window partition sdb2 with a EFI erased partition sda1

By error I erased my /mnt/sda1 EFI partition.

On /mnt/sdb2 there is the windows file system and on /mnt/sdb3 there was my kubuntu and porteus filesystem. I would like to recover the windows 10 partitions information. All my other data is backed up on an external hdd.

I was unable to boot. The error message being:
grub rescue >

Grub rescue commands would not restore the bootloader.

Using a kubuntu 24.04.2 LTS live iso, I was able to reformat /mnt/sda1 to fat32. Within the new EFI partion, I have installed some EFI files.

EFI-content

I have tried different approaches.

The last one being restoring uefi partition, grub bootloader and windows 10 bootloder with windows 10 iso thru a linux system.
Now I am going with the windows 10 iso, for the free iso:
(https://www.microsoft.com/en-ca/software-download/windows10ISO)

The procedure under ubuntu to prepare the windows 10 iso (you cannot format to usb with dd):
https://www.linuxbabe.com/ubuntu/easily … usb-ubuntu

Once the windows boot usb key is ready, it should boot your dual boot linux box:
https://www.linuxbabe.com/ubuntu/easily … usb-ubuntu
boot it from this USB stick and install Windows 10 in UEFI mode. Keep in mind that you may need to disable compatibility support module (CSM) in the firmware in order to boot in UEFI mode. You may also need to remove USB stick from your computer and insert it back in order for the firmware to detect the boot loader on your USB stick.

Unlike the kubuntu usb live system, the Windows 10 key will not boot.

Any suggestion appreciated.

Thanks.

there is some ??? debian package for that(maybe even on LiveISO), but there are also special proprietary paid tools(google may tell) for that. Don’t know more

Welcome to Ubuntu Discourse :slight_smile:

Boot the computer with the Kubuntu live USB and choose to try not install.

Then create a summary report for the boot repair tool here:
https://help.ubuntu.com/community/Boot-Repair

Copy and post the pastebin link back here for review.

Thanks.

Boot-Repair Summary report will help us a lot. Be sure to run when in UEFI boot mode.

If you created a new ESP - efi system partition, it will have new GUID & UUID.
UEFI boot entries use GUID, in Linux as partuuid, to know where to look for boot files. In Ubuntu the fstab entry for mount of ESP uses UUID. These can be edited/updated to be correct. If you have the correct Windows folders/files in ESP, you can just add a new UEFI boot entry for Windows also, with efibootmgr in Linux.

I am in a new kubuntu installation that I made on /mnt/sdb4 after resizing /mnt/sdb3. From within I have activated boot repair. Here is the pastebin:
https://paste.ubuntu.com/p/YcDQSFVp7k/

I do not even know if the system boots thru EFI. How do I make sure this is the case?

Thanks a lot for the rapid replies.

Line 99 > The firmware is EFI-compatible, and is set in EFI-mode for this installed-session.

Your partitions look like they are the result of many installations over the years.

Do you want to end up with Windows 10 and Kubuntu 22.04 on one disk?
Do you have backups of your Windows data and Kubuntu data?

GUID & UUIDs look correct, but if not booting, run the fix to totally reinstall grub that Boot-Repair suggests. But you have a customized 40_custom. Besure to back that up as new grub install will erase that. Not sure if the backup file in that folder would be preserved or only 40_custom overwritten, I would backup 40_custom to another device.

You have two ESPs. The ESP on sda1 has Ubuntu entries to boot Ubuntu on sdb4. You also have an old Ubuntu 17.04 on sdb3 which is long obsolete.

UEFI uses gpt and Windows only boots in UEFI boot mode from gpt partitioned drives. Your external sdc 2TB drive says it is MBR partitioned, report thinks it has an old Windows, but is Linux formatted?
Windows does not boot from external drives, except for the installer or repair/recovery.

My UEFI Windows has this folder as well as my Ubuntu & Boot:

ll /boot/efi/EFI
drwxr-xr-x 4 root root 2048 Dec  8 08:14 Microsoft/

So what Windows did you have and where?

I find it better to have ESP & install on same drive. And if multiple drives oftern better to have Windows on one drive & Ubuntu on another, But if SSD then better to have systems on SSD and data on HDD.

@oldfred

The 40_custom file is not a problem for me. I have a backup, and will reinstall it later. For now being able to boot into windows 10 would be OK for me.

I will remove the external 2 TB disk drive. It is only for backup purposes.

fl@GL502VMZ:~$ cd /mnt/sda1
bash: cd: /mnt/sda1: Permission denied
fl@GL502VMZ:~$ sudo cd /mnt/sda1
[sudo] password for fl: 
sudo: cd: command not found
sudo: "cd" is a shell built-in command, it cannot be run directly.
sudo: the -s option may be used to run a privileged shell.
sudo: the -D option may be used to run a command in a specific directory.
fl@GL502VMZ:~$ 
fl@GL502VMZ:~$ cd /mnt/sda1 -s
bash: cd: too many arguments

I am unable to look at the content of sda1 thru cd /mnt/sda1
On /mnt/sdb2 there is windows 10.

fdisk -l output after removal of /mnt/scc1 the external 2 TB disk drive :

...

erc.
Disk /dev/sda: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: SanDisk SD8SNAT1
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: 71BA7CA7-F19A-4D1E-9623-461A94FFCF9F

Device     Start       End   Sectors   Size Type
/dev/sda1   2048 250068991 250066944 119.2G EFI System


Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: TOSHIBA MQ01ABD1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: B6E5572E-5DC7-4654-B768-D8441B05F958

Device          Start        End   Sectors   Size Type
/dev/sdb1        2048  976762879 976760832 465.8G Microsoft basic data
/dev/sdb2   976762880  977295359    532480   260M Microsoft basic data
/dev/sdb3   977295360 1654798335 677502976 323.1G Linux filesystem
/dev/sdb4  1654798336 1953522945 298724610 142.4G Linux filesystem


Disk /dev/sdd: 7.23 GiB, 7767851008 bytes, 15171584 sectors
Disk model:                 
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: 07AFF69F-28B3-4CDB-B450-6DC25509CAC0

Device     Start      End  Sectors  Size Type
/dev/sdd1   2048 15169535 15167488  7.2G Microsoft basic data


Disk /dev/loop8: 4 KiB, 4096 bytes, 8 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 b

Line 212 of the report shows /dev/sdb2 as empty

             Avail Use% Mounted on
/dev/sdb2   255.7M   0% /mnt/boot-sav/sdb2

Can you see any files/folders there?

Was Windows on sdb1 (20% use)?

             Avail Use% Mounted on
/dev/sda1   119.2G   0% /mnt/sda1
/dev/sdb1     372G  20% /mnt/boot-sav/sdb1

Your ESP is already mounted at /boot/efi. And it is ESP. It is probably not letting you mount it again.
See my output:

ll /boot/efi/EFI

Before Boot-Repair fstab probably mounted it with umask=0077 Which is the standard for better security. Or no permissions. Boot-Repair changes to defaults, which gives you permissions to see ESP. This may be less secure as FAT32 does not support Linux ownership & permissions, so fstab is only setting. I still change my desktop to defaults.

You might be able to jump directly into Windows by replacing the device/fallback bootloader (…EFI/Boot/rootx64.efi) with the Windows bootloader (…EFI/Microsoft/bootmgfw.efi) and select the device to boot. rootx64.efi is just a copy of some other bootloader – grub usually replaces the original (Windows version) with shimx64.efi or grubx64.efi, depending upon secure boot selection. These are just files, copy them around when the EFI is mounted when booting from a UEF install media, etc.

@tea-for-one

fl@GL502VMZ:/mnt/sdb2$ ls
'$RECYCLE.BIN'   EFI  'System Volume Information'
fl@GL502VMZ:/mnt/sdb2$

gparted-view of hdd

@oldfred

There is no /boot/efi/EFI, it seems.

fl@GL502VMZ:/mnt/sdb1$ ll /boot/efi/EFI
ls: cannot access '/boot/efi/EFI': No such file or directory
fl@GL502VMZ:/mnt/sdb1$ sudo ll /boot/efi/EFI
sudo: ll: command not found
fl@GL502VMZ:/mnt/sdb1$ sudo ll /mnt/sda1/boot/efi/EFI
sudo: ll: command not found
fl@GL502VMZ:/mnt/sdb1$ cd /mnt/sda1
bash: cd: /mnt/sda1: Permission denied
fl@GL502VMZ:/mnt/sdb1$

sda1-content
sda1-content-EFI-folder

I am trying to follow-you. I do not understant, and does the above text is still pertinent after I have provided with the new information?

The structure of the partition is:
/EFI/BOOT
not
/boot/EFI/

@ubfan1

There is no EFI/Microsoft/bootmgfw.efi but here is the content of 3/efi/microsoft/boot folder from the microsoft 10 usb key:

fl@GL502VMZ:/media/fl/7A00BFAB75240AB3/efi/microsoft$ ls
boot
fl@GL502VMZ:/media/fl/7A00BFAB75240AB3/efi/microsoft$ cd /media/fl/7A00BFAB75240AB3/efi/microsoft/boot
fl@GL502VMZ:/media/fl/7A00BFAB75240AB3/efi/microsoft/boot$ ls
bcd                  efisys.bin           memtest.efi
cdboot.efi           efisys_noprompt.bin  resources
cdboot_noprompt.efi  fonts                winsipolicy.p7b
fl@GL502VMZ:/media/fl/7A00BFAB75240AB3/efi/microsoft/boot$

sdb2 is a fat32 file system, it cannot be a Windows OS partition.
sdb1 is ntfs, labelled as DATA.

The boot-repair report only recognised two operating systems (lines 85 & 86):-

* OS#1 (linux):   The OS currently in use - Ubuntu 22.04.5 LTS on sdb4
* OS#2 (linux):   Ubuntu 17.04 on sdb3

Therefore, where do you think Windows resides?

Here’s a complete directory listing of …/EFI/Microsoft/Boot:

$ sudo ls /boot/efi/EFI/Microsoft/Boot
BCD	      cbmr_driver.efi  es-MX  ja-JP	      kd_02_19a2.dll	   lv-LV	Resources		uk-UA
BCD.LOG       CIPolicies       et-EE  kd_02_10df.dll  kd_02_1af4.dll	   memtest.efi	ro-RO			winsipolicy.p7b
BCD.LOG1      cs-CZ	       fi-FI  kd_02_10ec.dll  kd_02_8086.dll	   nb-NO	ru-RU			zh-CN
BCD.LOG2      da-DK	       Fonts  kd_02_1137.dll  kd_07_1415.dll	   nl-NL	SecureBootRecovery.efi	zh-TW
bg-BG	      de-DE	       fr-CA  kd_02_1414.dll  kd_0C_8086.dll	   pl-PL	sk-SK
bootmgfw.efi  el-GR	       fr-FR  kd_02_14e4.dll  kdnet_uart16550.dll  pt-BR	sl-SI
bootmgr.efi   en-GB	       hr-HR  kd_02_15ad.dll  kdstub.dll	   pt-PT	sr-Latn-RS
BOOTSTAT.DAT  en-US	       hu-HU  kd_02_15b3.dll  ko-KR		   qps-ploc	sv-SE
boot.stl      es-ES	       it-IT  kd_02_1969.dll  lt-LT		   qps-plocm	tr-TR

I’ve copied efI files between systems without problems. The only machine specific file I know of the the stub grub.cfg files with the UUID of the actual Ubuntu root to import the maintained /boot/grub/grub.cfg.