LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2022, 01:31 AM   #1
fung0808
LQ Newbie
 
Registered: Dec 2022
Posts: 1

Rep: Reputation: 0
Accidentally deleted Windows after installing Linux


Hello all,

My goal was to dual-boot Windows and Linux but I realize that I might have accidentally deleted Windows after installing Linux (Lubuntu), and below is the output when I enter
Code:
sudo fdisk -l
in my terminal.

https://postimg.cc/nMJrWTck

I am thinking to delete partitions /dev/nvme0n1p2 and /dev/nvme0n1p4 and re-install Windows OS again.

Is my direction right? Please help and thank you!!
 
Old 12-19-2022, 01:54 AM   #2
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,806
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
3 would need to be shrunk to have room for two OSes. You should start from scratch, possibly keeping 1 & 4 only or 1, 2 & 4 only, and ensuring Windows does not use the whole disk or remainder, but only as much of it as you choose. You can use any live Linux disk to fdisk in advance instead of leaving it all up to the Windows installation partitioner, or use a Gparted or other bootable partitioner media. Alternatively to installing Windows first, reinstall Lubuntu to a smaller partition, leaving room for Windows to follow in remaining space. With UEFI and GPT, it's not important which to do first, but to boot from Linux after installing Windows will require a minimal amount of effort to restore Linux to boot control, as simple as a BIOS change, or learning your BBS hotkey and using it.
 
Old 12-19-2022, 02:43 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Another alternative is to try the legacy OS inside a virtual machine. Qemu and VirtualBox are available. That way once you get the legacy system installed, updated, and configured you can take a snapshot of the image and use that as your starting point each time you fire it up. That will come in handy to prevent it from going bad either from malware (which will be an issue) or through so-called bit rot. So I'd give a virtual machine a try before any major attempts at reinstallation.
 
Old 12-19-2022, 06:12 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
don't forget windows will overwrite the boot loader, so linux should be repaired afterward (I mean grub should be reinstalled again). But if it was a fresh new install then start over, delete everything, install windows, leave space for linux and install linux at the end.
 
Old 12-19-2022, 10:46 AM   #5
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,806
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by pan64 View Post
don't forget windows will overwrite the boot loader, so linux should be repaired afterward (I mean grub should be reinstalled again).
Overwrite bootloader is false, and reinstall Grub is an obsolete instruction, in UEFI environments. UEFI Windows installation changes nothing that Linux writes to any disk or filesystem. There is no code written to MBR in a UEFI system. The MBR on a UEFI system is not directly involved in booting. The only exception to the need to reinstall Grub occurs if you let Windows create a new ESP or format the existing ESP.

The boot initiator is the UEFI BIOS, by loading a boot file from a VFAT filesystem, and it is the system/BIOS NVRAM that specifies which directory on the ESP filesystem to load an EFI boot file from. It is only upon loading the appropriate boot file from a directory created by Linux, which Windows won't touch, that Grub will be loaded from a Linux filesystem that Windows can't read or write. Windows never touches Grub on a UEFI system. After Windows installation, the only "repair" required is implemented via UEFI BIOS setup by moving a Linux entry back to the top of the boot priority list. Alternatively, this so-called "repair" can also be made by running efibootmgr from any UEFI Linux boot.
 
1 members found this post helpful.
Old 12-19-2022, 11:35 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Quote:
Originally Posted by mrmazda View Post
Overwrite bootloader is false, and reinstall Grub is an obsolete instruction, in UEFI environments. UEFI Windows installation changes nothing that Linux writes to any disk or filesystem. There is no code written to MBR in a UEFI system. The MBR on a UEFI system is not directly involved in booting. The only exception to the need to reinstall Grub occurs if you let Windows create a new ESP or format the existing ESP
Yes, you are right. It is only a problem with MBR, and not an issue with UEFI. And Windows came with UEFI. Just linux can be still installed with MBR.
 
Old 12-19-2022, 11:43 AM   #7
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Had you looked at the disk partitioning before installing linux you would have seen exactly what you see now, but partition 3 would have been the windows OS partition.
In general, when dual booting with windows already installed you only need to use windows to shrink the main OS partition by the size you want for the linux install then install linux into the now unallocated space, allowing it to use the existing efi partition.

There are many many tutorials on how to install linux dual boot with windows. This is one that works with both windows 10 & 11. https://www.tomshardware.com/how-to/...and-windows-11

If you do not have install media for windows it can be easily downloaded. A quick search for 'download windows install iso' will give you a lot of links, but direct from microsoft is best.

I would first reinstall windows on that drive, then after windows is reinstalled and set up, follow the tutorials or the general instructions above to reinstall linux as dual boot.

Last edited by computersavvy; 12-19-2022 at 11:47 AM.
 
Old 12-19-2022, 02:15 PM   #8
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,622

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Quote:
Originally Posted by pan64 View Post
Yes, you are right. It is only a problem with MBR, and not an issue with UEFI. And Windows came with UEFI. Just linux can be still installed with MBR.
To be precise, both CAN be installed MBR: for Windows it takes jumping through some hoops, less so for Linux. I dislike using UEFI, but it does have some significant advantages and in particular when multi-booting EFI compliant operating systems.

If possible, download the OEM OS image form your hardware provider if you had the OEM version of Windows. It may have the OEM key already included, and if not then your old key should work assuming you retained a copy.

Last edited by wpeckham; 12-19-2022 at 02:17 PM.
 
Old 12-19-2022, 04:26 PM   #9
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,806
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by wpeckham View Post
If possible, download the OEM OS image form your hardware provider if you had the OEM version of Windows. It may have the OEM key already included, and if not then your old key should work assuming you retained a copy.
Once a PC with an OEM Windows version has had Windows validated, the PC is in Windows' database indefinitely, and the original key and active validation are not required when Windows gets reinstalled. In this situation, Windows gets activated automatically when it first contacts mommy. Unless the situation changed since I last needed to use it, a retail version of Windows may be transferred to a replacement PC, unlike OEM versions, so on installation to a replacement PC, activation is required using the original retail key.
 
Old 12-26-2022, 02:27 AM   #10
linux-man
Member
 
Registered: Nov 2016
Location: Geneva
Distribution: native install of Parrot Home Edition 5.0 Debian (no security tools) 64 bit, KDE, 5.14.0-9parrot1,
Posts: 872

Rep: Reputation: Disabled
Quote:
Originally Posted by mrmazda View Post
Once a PC with an OEM Windows version has had Windows validated, the PC is in Windows' database indefinitely,
Database in Redmond WA or on OP personal pc database?

Quote:
Originally Posted by mrmazda View Post
Windows gets activated automatically when it first contacts mommy.
Not big brother?
 
Old 12-28-2022, 01:28 PM   #11
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
I'm chiming in late so you may have already done whatever but when I was new always just started over from scratch... so many times! LL

We can install microcoughed\windows use it to shrink its own partition and then install GNU\Linux, easy peasy or the Linux installer can shrink windows for us.

Have fun!
 
Old 01-05-2023, 03:15 AM   #12
jackx2023
Member
 
Registered: Jan 2023
Posts: 32

Rep: Reputation: 12
During an installation of linux there is usually an option to install linux along side windows and the installation handles it from there.
 
Old 01-09-2023, 06:56 AM   #13
Jamesmillere
LQ Newbie
 
Registered: Jan 2023
Location: USA
Posts: 2

Rep: Reputation: 0
After deleting Windows, chances are very less to recover it, still, you may contact the MS Windows support team.




Thanks
 
Old 01-09-2023, 09:17 AM   #14
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
I realize that I am jumping in late, but the recovery from the initial error is very simple.

1. reinstall windows and tell it to use the entire disk as done previously. Install it in UEFI mode as was originally done.
2. After booting and configuring windows from within windows use the disk manager to shrink the windows file system and leave enough unallocated space to install linux.
3. install linux into the open space left with step 2 above. Use uefi mode and it will use the existing EFI partition and share it with windows.

These steps are the normal steps given in 90+% of the online tutorials for a dual boot install. Almost all linux distros will configure the boot loader for dual boot if these steps are followed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I reinstall Grub and Efi (or Uefi) on my external HDD after I accidentally deleted the partition. Choklit Linux - Software 4 12-24-2019 03:42 PM
accidentally deleted the swap : linux won't start nkd Linux - Newbie 6 11-20-2010 10:16 AM
Deleted accidentally a Linux Suse 9.3 profile sfzab Linux - Software 0 12-07-2005 04:47 PM
Accidentally Deleted my Linux Partition...Need Help ASAP robbs Linux - Newbie 3 07-10-2005 07:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration