this post was submitted on 14 Jan 2025
8 points (100.0% liked)

Technology

1017 readers
66 users here now

A tech news sub for communists

founded 2 years ago
MODERATORS
 

My laptop is (maybe was) Linux and Windows 10 dual booted. I was reinstalling the Linux OS and in the process I accidentally formatted the Windows 10 boot partition. At least I think it is the boot partition because I don't really know how Windows works (or doesn't work amirite).

This is the lsblk output:

$ lsblk -f
NAME        FSTYPE     FSVER LABEL [...] MOUNTPOINTS
nvme1n1     zfs_member 5000  zroot [...]
├─nvme1n1p1 vfat       FAT32       [...] /boot/efi
├─nvme1n1p2 swap       1           [...] [SWAP]
└─nvme1n1p3 zfs_member 5000  zroot [...]
nvme0n1
├─nvme0n1p1
└─nvme0n1p2 ntfs

The nvme0n1p1 is the one related to booting. I accidentally formatted it.

I have a Windows 10 USB prepared. I tried looking online and I never found a question asking exactly for this. The ones I found that were similar enough suggested different commands.

Anyone has experience with this?

Thanks in advance.

top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

I assume that's your efi partition where grub lives. If not, you should install grub there as it's gonna be your boot menu, from where you boot any OS. If so, you can download a windows iso and extract the boot files by mounting it on a folder and looking at the boot/ folder. Then you can make a Microsoft/boot/ folder in you efi partition and place the files there. You can check that it works by trying to boot from the grub CLI. Lastly, to make a menu entry for Windows on grub you need to use the 40.custom file on the /etc/grub.d folder iirc and add a menuentry with all the commands you needed for booting Windows.

You should check that you actually replaced the entire boot partition by navigating /boot/efi and looking for extra files that are unused, if not you can skip downloading and extracting the boot files.

I know this is a bit cryptic but I don't have much time rn, I'll edit this comment later

[–] [email protected] 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

The current boot partition being used for linux is nvme1n1p1 which is the efi partition and it's using refind instead of grub. When you install windows it automatically creates a boot partition which used to be nvme0n1p1. Stuff like os-prober look for this partition when detecting windows installs.

I am not understand your comment correctly. To me it sounds like I can copy some stuff from the main windows partition and copy it into the linus boot partition and create a bootloader entry that can then boot into windows. Is this correct?

[–] [email protected] 2 points 2 weeks ago (1 children)

Yea, though not the main windows partition since it doesn't have the boot files, but a windows installer iso.

[–] [email protected] 2 points 2 weeks ago (1 children)

You are gonna have to help me out more because it seems there never was a windows boot partition and you were right. There is a windows reserved partition and the actual c:\ partition. So my guess is that the windows boot files were on the partition that also housed the linux boot stuff (refind and so on).

So I tried using the command prompt from a live Windows USB. But I could not mount the linux boot partition at all. It is a normal fat32 partition but Windows does not recognise it as such. It could be because of the way it was created: i copied some mkfs command from a guide. Because of this I could not assignletter this partition or do any of the cmd sorcery I found online.

I guess I could try recreating this partition in a way that Windows is not deeply offended by it. But apart that I am out of ideas.

[–] [email protected] 2 points 2 weeks ago (1 children)

Hmmm I don't know why that could be. Did you set it as an EFI partition? Check that, and if you currently can't do it, you could try your idea, or copy the windows boot files to some other drive and then copy those to the efi partition using Linux. You could also install windows or grab the windows files on some other unrelated computer (assuming it'd use efi).

[–] [email protected] 2 points 2 weeks ago

I looked into it today and turns out the whole disk that the partition is on was using the dos table rather than gpt. I really don't know how I did that but that is besides the point. So I ended up having to nuke the whole disk and reinstall linux. Haven't yet tried to have windows boot yet but at least found out one thing that was wrong.

[–] [email protected] 4 points 2 weeks ago (2 children)

Ok so, a while back my windows did a fucking weird thing where I cloned an OS drive and later on down the road I went to wipe the OLD OS drive after I had been using the new one for months. Well my PC randomly decided to boot from the OLD drive and fucked up the boot on the NEW one. To this day my best IT friend that has seen just about everything, has no idea what happened because wid ows is just fucking stupid sometimes.

So anyway, I got this program Macrum Reflect and went through a tutorial of making a recovery media. I did that AFTER an official windows recovery media failed.

The Macrum Reflect recovery media fixed the boot in, not shitting you, less than 5 seconds after I ran it. I'd say it took it less than 2 seconds really. I clicked run and it was done. It was so fast I initially thought it just didn't work.

My PC booted right up using the new drive and have zero problems.

So yeah, maybe try Macrum Reflect recovery media. You'll need a working PC to set it up.

[–] [email protected] 2 points 1 week ago

I've been told (but I cannot verify) that windows' default behaviour is to install an EFI partition on every internal drive, and update them all in the event of an update.

I know from experience that windows only expects to see itself installed and will happily fuck up your bootloader with whatever garbage it wants to.

I suspect that these two "characteristics" together are what is to blame here.

[–] [email protected] 1 points 2 weeks ago

To add to this, if you ever have to clone a drive, look up Veeam backup. It's the best backup and cloning software I've ever used. So Macrum and Veeam go on every PC I have now. lol

[–] [email protected] 3 points 2 weeks ago (1 children)

Try mounting nvme0n1p2 to see if your data is there.

If it is you should be able to just use the install USB to repair the boot partition or just install it on top while preserving data.

[–] [email protected] 1 points 2 weeks ago

The data is still there thankfully. Haven't solved the problem yet but I don't wanna lose the stuff on it despite most of it being junk.

[–] [email protected] 2 points 2 weeks ago (1 children)
[–] [email protected] 2 points 2 weeks ago (1 children)

A true master is an eternal rookie

[–] [email protected] 2 points 1 week ago

lol you got me there