FreeDOS dual boot with Windows 7/8/10
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
I've got a Dell Dimension 4700. It's a 32-bit PC from the
mid-2000s, and it's just barely new enough to have a PCI Express
slot, which I used to add USB 3 ports, including a type-C, on a
front panel (mostly because I thought it was funny).
The only actual work I do on this computer is writing, and the
only way I can concentrate on writing is if my computer doesn't
let me do anything else, and doesn't show anything else on the
screen. That's why I do all my writing in Word 5.5 for DOS.
For editing, I usually like to use Word 97 (with doswrd32.cnv),
then export to HTML and copy to a thumbdrive.
I'd also like a Debian installation on there, just in case it comes in handy for some random project, but I don't want to commit to not touching it. There's a good chance I'm going to want to overwrite the installation at some point in the not-too-distant future - either by installing over it (maybe with a newer version), or removing it to make more space in my Windows partition for storing some big ol' files - and I don't want that to break my bootloader.
So I need to be able to:
- Boot into FreeDOS
- Boot into Windows (this computer's got a Windows 7 license, so
that's what I'm using)
- Boot into Debian on the rare occasion I need it
- Delete the Debian partition without breaking the ability to boot into the other environments
In a normal triple-boot, you'd probably do something like this:
- Install Windows 7
- Install FreeDOS
- Install Debian using the rest of the available space
In this situation, Debian installs GRUB 2, which allows you to
boot Windows 7 or FreeDOS instead.
But I don't want to commit to my Debian installation - I'd like
to be able to overwrite or remove it, and still boot the other two
operating systems on the drive. So what I want is a system that
asks if I want Windows 7 or FreeDOS, then gives me a sneaky way to
boot to Debian instead if I'd like. Turns out there's a setup that
works really well in this very specific situation, and doesn't
need any external boot disks. I'll walk through it below.
Installing FreeDOS
There is some manual partition setup here (since we aren't using the whole hard disk for FreeDOS), but it's nothing unusual if you're familiar with the DOS world. The FreeDOS 1.3 boot CD is nice enough to drop you at an R: prompt instead of launching you right into the setup, so you can run fdisk. All you need to do is create a single primary partition, probably one that doesn't take up a lot of space (I made mine 5 GB, but I probably could have gotten away with 1 or even less - just depends on what you think you'll need it for). Make sure to mark it active, too.
Once you've created the partition, reboot into the FreeDOS 1.3 boot media again and run the setup as normal.
You should be able to boot into FreeDOS from the hard drive
(after removing the CD). Depending on your situation, you might
want to edit FDCONFIG.SYS to load fewer drivers by default -
some drivers can interfere with loading Debian, or you might
just not need them. Otherwise, you could always just pick "load
FreeDOS without drivers" at boot time when you want to boot to
Debian instead.
Installing Windows XP
Are we going to use Windows XP? No.
But we do need its bootloader.
The idea behind a FreeDOS/Win7 dual boot is to use ntldr as a shim: essentially, you'll go from Windows 7's bootloader to Windows XP's bootloader to FreeDOS. It's a bit like connecting a smartphone to a tin can by putting a rotary phone in the middle.
The nice thing is that we don't need to activate Windows XP - we don't even need to enter a product key. Just install any old copy of XP. Use the installer to create a second primary partition - I have mine taking up most of the space on the drive, leaving about 25 GB left over for Debian.
Two things to note. First, you don't need to complete the
setup process (you could just turn off the computer when
it asks for a product key, and go right on to installing Windows
7). Second, if your computer is too new to run the Windows XP
installer properly, there is a workaround: boot up a Debian
live DVD, install qemu-system-x86 with the package
manager, and run it against a Windows XP .iso image and your actual
hard drive.
Windows XP will put its bootloader on the FreeDOS partition; this is normal (it's what XP always did when dual-booting with 98 or Me). Once everything's set up, you should see two boot options: Windows XP itself, and "unrecognized operating system on drive C:". Selecting that second option will boot into FreeDOS.
Installing Windows 7
Now it's time to install Windows 7 (with our actual product key) right on top of the XP installation. Just boot from the Windows 7 disc, and pick the XP partition as the one we want to install to.
By the way, Windows XP recognizes the FreeDOS partition as C:,
and its own as D:. My Windows 7 installation didn't keep this
intact (it names its own partition C: and the FreeDOS partition
E:), but I think it might if you launch the Windows 7
installer from within XP.
The reason I chose Windows 7 for this guide is because it has a
copule of odd things you need to do to hide unnecessary boot
menu entries. The Windows 7 boot screen shows three options:
"Earlier Version of Windows", "Windows 7", and "Unrecognized
operating system on drive C". The first option, "Earlier Version
of Windows", boots FreeDOS; the third option simply fails. (If
you're using Windows 10, you'll see that the broken third option
isn't there - this should let you skip a good chunk of the next
section.)
Time for some bcdedit magic. Open a command prompt window with administrator permission, and run bcdedit /enum. The system's boot configuration looks like this:
"Windows Boot Loader" will boot Windows 7, and "Windows Legacy
OS Loader" is the XP bootloader, ntldr - that's what
is allowing us to boot FreeDOS. Let's rename its description to
"FreeDOS 1.3":
bcdedit /set {ntldr} description "FreeDOS 1.3"
Removing the "Unrecognized operating system" entry in Windows 7 is a bit trickier, though. The Windows 7 boot manager seems to be taking this description from ntldr's configuration file, boot.ini, which you can find in the FreeDOS partition. You can edit it from DOS or from Windows, but editing it from Windows means you'll need to map the partition to a drive letter (which you can do in Disk Management - something you'll probably want to do anyway), show protected operating system files and hidden files (in Folder Options), and remove the read-only flag (in the file's Properties). Once you're in the file, just remove the "[operating systems]" section (the last two lines of the file).
This solves the problem with Windows 7's boot manager, but it causes a new one in XP's. Selecting "FreeDOS 1.3" from the boot menu now gives us a confusing prompt, asking us to choose between "Windows (default)" and "Windows (default)".
For now, I've worked around this by editing boot.ini again,
this time to give ntldr a timeout of 1 second (instead of 30)
before it automatically selects the first entry. It's short
enough that my flatscreen monitor doesn't adjust in time to
actually show the prompt.
Installing GRUB4DOS
The first thing I wanted to do with Windows 7 - whether I was
going to install Debian or not - was get a modern web browser
(i.e. not IE). You can still use IE 8 to go to Mozilla's website
and nab the Firefox installer, though. The Firefox web installer
might fail, but it'll just prompt you to download the full
installer instead, and that ought to work.
(This is another thing you can skip with Windows 10! You'll
have Edge, which will work fine.)
Once you've got a new browser, you'll want to download two more
things:
chenall's builds are mirrored on GitHub if that's easier. In either case, it's the .7z file you want, since that's what contains grub.exe - just extract this one file to the root of the DOS partition. (If you can't see the DOS partition in Windows, either map it to a drive letter in Disk Management, or just put grub.exe on a floppy if you have one - you can boot to DOS and copy it back over.) No need to configure GRUB4DOS with a menu.lst file; Debian will take care of this for us.
Installing Debian
Now that you've got grub.exe, it's time to install Debian.
(Actually, you could do this before grabbing GRUB4DOS - order
isn't important here.)
I'm using the graphical installer, just because it's the default; the options are the same. For disk partitioning, you can just let the installer use the free space.
The only time you have to interrupt the installer is when it asks if you want to install the GRUB boot loader. Strange tutorials like this are probably the reason it's asking in the first place! Just press "Go Back" and you'll see the installer menu:
Go down to "execute a shell", and - once you get a root prompt
- run the following commands:
chroot /target
apt-get install grub-legacy && update-grub
exit
exit
This installs the old version of GRUB - i.e. the one before GRUB 2, and the one that GRUB4DOS was originally based on. What we're not doing is installing GRUB to the master boot record, but we are generating its configuration file. This version of GRUB uses the same menu.lst configuration file and path that GRUB4DOS expects. It doesn't matter that the menu.lst file generated by update-grub is on the Debian partition; GRUB4DOS will find it.
Back on the installer menu, pick "continue without boot loader".
Booting Debian
This might have been an awkward setup process, but the process of booting Debian is pretty darn smooth: just boot FreeDOS (maybe in emergency mode, if you're having problems) and then run grub. GRUB4DOS will find Debian's menu.lst and show the menu - from there, everything will work as normal.
And, importantly, we've also simplified the process of removing
Debian from the computer, if we ever want to: we just need
to delete grub.exe and remove the Debian partitions
(root and swap) - both things we can do from Windows 7 and its
disk management tools. In essence, this is really just
Windows/FreeDOS dual boot that doesn't rely on Debian at all -
but if we ever need to boot to Debian, we can.
(Tip for Windows 10 users: if you're already booted into Windows, and you want to reboot into your other OS, just use that "reboot now" button and pick your other OS from there - it might save you an extra boot cycle!)