understanding grub2, mbr, primary/secondary drives, and dual booting
DebianThis forum is for the discussion of Debian Linux.
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.
understanding grub2, mbr, primary/secondary drives, and dual booting
I previously thought I had a good grasp of the old grub1 system, but I haven't done much sysadmin kinda stuff since the move to grub2, and grub2 perplexes me.
I have a laptop with two hard drives, I'll call them internal and external (the "external" one is in a laptop drive bay and is ejectable.) Right now both have Debian on them: internal has an older version that I've cleaned out and am ready to get rid of; and external is my primary OS, debian stable, I guess it's stretch. It has an encrypted root, which somewhat complicates things.
I'm getting ready to install Windows 10 on internal drive, which is going to put itself on the MBR and not provide a boot menu.
My question: What should I put on a USB flash drive, so that I can boot from that USB drive and access grub2 on external drive?
I'm not sure whether grub2 is installed on the MBR area of external drive or not; I could probably discover this by removing internal drive and trying to boot; but short of that is there a way to find out?
Basically I want to know, how can I set myself up for success in booting debian on external, while going through this kind of scary process of clearing the MBR that I believe I have been relying on for years, with a new grub that I don't understand?
Is your system UEFI or Legacy? If you install windows, it may try to install UEFI but you can use the Custom install option and install in Legacy mode. If your current Debian (on the External) is UEFI, then you should install windows UEFI for compatibility. You can boot into Debian and open a terminal as root user and run the command:
Quote:
parted -l
If you see a partition labellef EFI in vfat format, you have UEFI.
If you have Debian on the external and plan to keep that, you need to check the parted command to see on which drive you have Debian. With the info you have posted, you should have sda and sdb but you need to verify that. If Debian is on sdb and a Legacy install, you would simply install Grub to the MBR of that drive running this command as root:
Quote:
grub-install /dev/sdb
Verify your drive first, if you aren't sure post the output of parted here.
I've looked at parted and it does not appear to be UEFI. I don't presently have any vfat partitions, and there is nothing marked efi.
I also looked in the bios setup utility, and could not find anything there about UEFI. Perhaps that means it is not supported, and I have nothing to worry about as that goes.
Thanks for the tip about the custom install option, I would not have thought of that. I am not sure if I will get the option to do that, as I am installing a corporate image; but I will look out for it.
I performed a grub-install per your advice, and tested booting from a USB stick with SystemRescueCD which gave me a prompt to boot from my HDD2, and that worked, so it looks like I have a good fallback.
Will update after my installation!
I did not see any option for custom install; as I mentioned, it was a corporate image not a standard install.
I'm not sure whether UEFI is supported by my computer (Lenovo W500), however it does not seem to be enabled, which is fine.
Conveniently, in the BIOS I am able to select the default boot device, so I've simply set the second/external drive to be the default boot device. I can remove it and boot windows, or I can insert it and it gives me a boot menu where I can select to boot linux or windows. (I had to update grub to get the boot menu updated).
A simple run of update-grub2 found the new Windows installation and made an entry for it in the boot menu.
Before running update-grub2, I added a line to the end of /etc/grub.d/40_custom:
Code:
set timeout=-1
This ensures I will always be forced to choose which OS to boot; it won't time out and choose a default. The timeout could have been set somewhere else, however a (possibly fixed by now) bug in /etc/grub.d/30_os-prober was overwriting the timeout value, so 40_custom was the best way to go.
I had no need for the SystemRescueCD bootable USB stick, but I was glad to have it as a backup plan.
/etc/default/grub is now auto-generated and will be overwritten by certain update commands
Really? That's news to me.
As far as I know, /etc/default/grub is an input file to the config generation process, to ensure that your modifications won't get overwritten, because the config generator will pick up your selected settings from the file and modify the auto-generated config file according to what it finds there.
I certainly have never seen the file getting overwritten by any update command so far.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.