Recovering the bootloader after reinstalling Windows 7 (debian stable)
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recovering the bootloader after reinstalling Windows 7 (debian stable)
I have a dual boot machine (Windows 7 and Debian).
W7 and debian are on the same HD but on diffferent partitions.
The debian partition is an LVM encrypted one.
The W7 needs reinstalling, and as I understand the process will overwrite the debian bootloader (grub).
Question: Is there a way to save the current bootloader and recover it after I've reinstalled W7, so I wont have to reinstall debian from scratch?.
I plan to re-install W7 on the same partition it is now, without overwriting the debian partition.
I have a dual boot machine (Windows 7 and Debian).
W7 and debian are on the same HD but on diffferent partitions.
The debian partition is an LVM encrypted one.
The W7 needs reinstalling, and as I understand the process will overwrite the debian bootloader (grub).
Question: Is there a way to save the current bootloader and recover it after I've reinstalled W7, so I wont have to reinstall debian from scratch?.
yes, there is. You could just allow the Windows installer to overwrite your current bootloader, then, later, boot a Live Linux and just re-install GRUB from that live system.
If you want to do it the hard way, that's possible as well. But still, low-level work on the HDD always poses the risk of an accident, and so I strongly recommend to have a full backup before you start, just in case something happens!
USE AT YOR OWN RISK!
I assume you're using GRUB as a bootloader. GRUB is typically installed as two parts. One part occupies the MBR and a few of the following sectors before the beginning of the first partition, the other part is in /boot/grub of the Linux partition (or maybe in an extra partition that is mounted to /boot). During re-installation of Windows, the GRUB part inside the Linux partition remains unchanged, of course. So it should be sufficient to back up the sectors preceding the first partition and restore them later.
You have a Linux live system ready that you can boot off a CD or USB pen drive? Good.
Here's how I would do it.
From inside Linux (the currently installed system will be fine) issue the command
Code:
sudo fdisk -l
Note the starting sector of the first partition (/dev/sda1). On my system, it's 2048, but it may be different on yours, especially when your partitions are not aligned to 1MB-boundaries.
Run the following command, replacing <number> with the number you noted before.
That's the preliminaries. Now you can re-install Windows, which will flatten the existing GRUB and replace it with its own bootloader. Once Windows is running again, ...
Boot your Live Linux from CD or USB, and have the previously saved grub.bin file ready
Again, make sure you don't write sda1, it's just sda.
Reboot your system. It should come up with the boot configuration exactly as it was before.
Again: That's pure theory, I haven't tested the procedure. Don't try it without having a verified backup for disaster recovery, just in case.
Quote:
Originally Posted by mzzxx11
I plan to re-install W7
Why are you going to do that in the first place? Are you experiencing trouble with your Windows installation?
If I were in your shoes, I'd rather try a system restore from inside Windows, or restore Windows from a previous known-good backup.
Though these tutorials specifically refer to Ubuntu or Linux Mint here and there, the procedure is the same for their ancestor Debian. Actually, for any distro using GRUB.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.