Installing Windows and Linux into the same partition
gist.github.com
gist.github.com
https://en.wikipedia.org/wiki/Cooperative_Linux
>The term "cooperative" is used to describe two entities working in parallel. In effect Cooperative Linux turns the two different operating system kernels into two big coroutines. Each kernel has its own complete CPU context and address space, and each kernel decides when to give control back to its partner.
>However, while both kernels theoretically have full access to the real hardware, modern PC hardware is not designed to be controlled by two different operating systems at the same time. Therefore, the host kernel is left in control of the real hardware and the guest kernel contains special drivers that communicate with the host and provide various important devices to the guest OS. The host can be any OS kernel that exports basic primitives that allow the Cooperative Linux portable driver to run in CPL0 mode (ring 0) and allocate memory.
[0] see the dozens of official Windows GUI frameworks: https://news.ycombinator.com/item?id=16736720 (and since then, it's gotten worse: https://www.google.com/search?hl=en&q=uwp%20deprecated)
QEMU might work for your usecase though.
It's mostly used in embedded or IOT systems, or inside a single application with async/await, but it can be used for the whole OS as well.
If the system and its built-in applications are designed to take advantage of it, and any external application is run inside a VM to make sure it doesn't misbehave, cooperative multitasking works great.
VirtualBox supports fake disk images that are just pointers to a real block device, which could be an entire drive or partition.
I took advantage of that to have a dual-boot Linux & Windows 7 install (with the main bootloader still being Windows’ as I hate GRUB) and then created a VM pointing to the Linux partition.
The system was configured to be able to deal with both the real hardware and the VM emulated HW. As far as I know most stuff worked out of the box, the only change I had to make was have two network configuration entries - one for physical hardware and one for the VM.
This worked really well actually and performance was good.
As for drivers, the idea is that you're passing through as much of the devices as possible so it works on that level. For those you cannot passthrough, Windows 10 was surprisingly accomodating.
Though I don't remember how or whether it is legal.
if I recall (big "if"), all editions of Windows from Pro upwards include a license to run exactly one instance of the same edition of Windows inside a VM at a time. It does not need to be hosted by Hyper-V or be hosted on the associated licensed Windows installation.
Windows 10 Enterprise, I think, includes 10 VM licenses per purchased license, but those 10 are all meant for the same user, which is the user who is using the physically installed license and are not to be spread around and used by different users.
Windows licensing is kinda weird
Had the same experience, it worked surprisingly good and was easily good enough for daily use.
Unmounted or hidden, an additional separate specialized FAT32 boot partition has been common for Windows since long before UEFI & GPT partitioning became mainstream.
Usually the first active primary partition on a Windows 7 BIOS PC, a few hundred megabytes of FAT32 were there specifically to hold the BOOTMGR file and its associated BOOT folder, (where you could build a Windows bootmenu) which would point from there to any of your main NTFS partitions that had a version of Windows installed.
That regular Windows bootmenu (in BIOS) could also be used to point to the GRUB-based bootsector from a type 83 EXTx Linux partition on the same HDD. This would boot the Linux like normal. Even though Windows would not mount nor access the Linux partition. But Linux could mount and access the Windows partition.
Alternatively, on a fresh BIOS partitioning layout, the FAT32 Boot partition can be upsized to a few GB (instead of mere MB) and then a copy of an entire live Linux fileset from the bootable Linux DVD can be placed there right next to the Windows BOOT folder. The contained live Linux squash filesystem is then booted into memory from the FAT32 volume using the Windows bootmenu, with GRUB, or even Syslinux which can boot the Isolinux-launchable DVD fileset when the fileset is stored on a FAT32 volume.
An advantage of this arrangement is so (live) Linux is avaiable bare metal when needed on an otherwise unchanged Windows PC, without having any EXTx partitions. As more distros gained access to NTFS it became possible to place the Linux live folderset right there on the NTFS volume alongside Windows, so there was another option.
In BIOS mode Windows 10 (and even Windows 11 in BIOS for extra credit) works just like Windows 7 for this.
For UEFI a FAT32 ESP is almost always in use but Windows bootloader will not boot Linux in UEFI. But the /EFI/BOOT folder in the UEFI ESP is not dedicated to Windows like the BOOT folder was under BIOS. /EFI/BOOT contains the key BOOTX64.EFI file which is basically a renamed OS-specific bootfile placed there by the most recent OS that was installed or had its bootfiles updated in common ways.
BOOTX64.EFI then points hardcodedly to one of the associated /EFI/Microsoft or /EFI/ubuntu, etc folders there on the boot partition which will contain a Windows or Linux bootmenu accordingly.
The /EFI/Microsoft folder contains the regular Windows bootmenu which accesses any of the Windows OS's that are installed on any of the NTFS[0] partitions that are unhidden at the time.
The /EFI/ubuntu folder contains the GRUB bootmenu which accesses any of the Linux OS's that are installed on any of the EXTx[0] partitions. Additionally the GRUB bootmenu can be configured to have a Windows bootentry which then chains to the regular Windows bootmenu in /EFI/Microsoft/Boot/BCD. Also in GRUB a bootentry can be added to launch a live Linux fileset stored on a sizable enough ESP FAT32 boot volume similarly to how it's done in BIOS.
Interestingly, on a Windows XP PC to begin with you could install to a different folder than the default WINDOWS (such as WINNT or WINXP). Afterward if you protectively renamed Documents and Settings & Program Files from the command line of the NT6 install DVD, you could then install NT6 into its own default WINDOWS folder alongside XP on the same partition without conflicts. The real Documents and Settings can then be unveiled and an NTLDR entry added to the NT6 bootmenu. BOOT.INI can then handle the NT5 & DOS booting as before and NT5 when booted can share the Program Files folder with NT6 as long as you are careful, since NT5 does not need to run anything in the Program Files folder when you boot. Often you can install an NT5 program into the same Program Files folder shared with NT6 this way and there is no conflict whatsoever.
[0] a wider variety of filesystems are becoming supported as years go by.
I'm occasionally using this to install Linux on an external drive.
Moreover—the, erm, advantage of a system where you can tune the boot process in a hundred different ways is that you can do quite weird stuff. Like, have the boot ramdisk mount a network drive and then use that as the root filesystem.
you can do this, but i've always found figuring out what drive to mount to be a challenge in the grub interface. at one point in time it was the best option.
these days, it's generally easier (imho) to just boot intot he livecd/usb environment, mount the volume you want to repair, and chroot into it
The initramfs is the first root filesystem a Linux system has but it resides entirely in RAM. It's initialized using an archive stored on disk, but after that point can be modified freely without touching disk at all. Very much like /tmp in distros that store /tmp in memory.
initramfs is mostly for loading stuff required for booting the system. Usually these are storage related - maybe your root filesystem lives on a disk that's encrypted, backed by RAID, etc. and it requires a password or some modules that aren't baked into the main kernel image. If you include these modules/config/etc. in your initramfs and the initramfs's init (it has a distinct init from your main system, usually a shell script) knows about them then they can be used to bootstrap your root filesystem.
Of course, it requires that the initramfs be stored on a filesystem whose code is baked into the kernel. ex2 is/was a popular choice, as well as the UEFI system partition (basically FAT). Both simpler filesystems that don't bloat the kernel too much.
Once you've mounted a filesystem of some kind in the initramfs, you call pivot_root and the root filesystem switches from being the initramfs to being whatever filesystem the initramfs mounted. Then you can exec that filesystem's init and get the full system up.
Or you could just stop in the initramfs. Usually they just contain busybox and some other system binaries so they're not practically useful, but at one point I experimented with including a Lisp there. It never ran on real hardware but I was able to boot to an SBCL REPL via QEMU, which was pretty cool. The next step was Emacs but that didn't work out for reasons I don't remember clearly.
(Though I'm not so sure now that I remember it right, since VMs tend to use low-level approaches like kernel extensions, and Rosetta is probably not friendly toward those.)
Maybe I'll use my free time this weekend to try and compile that.
I had an old Mac that for some reason couldn’t boot the Windows DVD, but installing it onto a VM that used the real HDD worked fine.
This is the guide I used for making the SSD look like an internal hard drive https://ckirbach.wordpress.com/2017/07/25/how-to-add-a-physi...
Once the first part of the installation was completed, I turned off the VM and booted the SSD from real hardware (after disabling the internal disk in the laptop's firmware to avoid anything unfortunate happening).
Apart from being a little slower, everything works fine. I haven't yet been offered the windows 11 upgrade so I can't say if that will continue working.
Is there a way to fool Windows into thinking it's a normal SATA hard-drive attached to the motherboard and not a USB one?
After the first part of the installation is done (the copying files from the ISO image/DVD/USB stick part), Windows 10 won't run a check that prevents C:\ being a USB drive.
So I don't think there's any reason to fool it after that point.
And before that point of the installation the virtual machine is there to fool it. When the drive is attached to the VM as per the linked instructions (in my comment above) Windows will see it as an internal drive.
---
I have also tried Windows 11 using these same steps, but got a message saying that my (virtual) hardware didn't meet the requirements. I suspect it was the TPM module that was incorrect in the VM. Probably as more people try to run Windows 11, virt manager's support will improve (including the downstream distributions' copies).
I used to get random blue screens of death from this however, so stopped using it. Also: WTG is no longer supported by Microsoft, so we can't use it anymore.
I like your hack of attaching an SSD to a VM. How do you do that though? Is there some procedure for doing that? I'd love to know!
https://superuser.com/questions/495025/use-physical-harddisk...
However, making it possible to boot windows without the VM required some hacks and I neither know if they work for modern windows too nor what they were exactly.
Another interesting cross-OS trick is folks who use a shared NTFS drive to maintain a common Steam library between Windows and Linux. I did this for a while before I switched completely to Linux, but it's still fairly common.
[0]: https://askubuntu.com/a/47122/11736
[1]: https://www.sysprobs.com/access-physical-disk-virtualbox-des...
If you're sharing a library between Windows and Linux, NTFS should be your way forward, especially given the improved native R/W NTFS (NTFS3) driver that is present in newer Linux kernels (5.15+). exFAT is a marked improvement over FAT32 (no realworld filesize limit) but NTFS will probably be the least painful choice longer term (given the journaling capability).
Either way, NTFS isn’t supported by Proton and I’m still on 5.14; 5.15 was only released on Halloween 3 weeks ago and isn’t in most distributions/repositories yet or nearly as battle-tested. However I am excited to get my hands on the better NTFS support.
https://github.com/DualCoder/vgpu_unlock
Looks like it can enable a virtual GPU so you don't need to actually use 2 GPUs, but I haven't tried it, it looks pretty cool if you only want to run only 1 to switch.
Also, regarding hating GRUB: take a look at rEFInd. The themes are way better [0] and it can autodetect operating systems so not only is it harder to break your system with a bad config, it'll detect USB boot devices as well so you don't have to mash F11 or whatever if you need to boot from one. It also has mouse support and (in theory) also touchscreen.
https://wiki.ubuntu.com/WubiGuide
They've since dropped the idea but you can still cobble together something similar.
https://unix.stackexchange.com/questions/309900/deploy-linux...
That said this was back during win7, the cobbled together solution may be more stable..
The really nasty part is that even having separate drives won’t save you - I don’t know if Windows can install the bootloader to a different drive than the one holding the OS partition or if it’s some other bug but I absolutely remember a Windows install nuking the bootloader on other drives that were connected during the OS install.
It wasn’t a big deal pre-Windows 10 as you only install an OS once and disconnecting the drives is trivial, but nowadays with every update being an OS reinstall it’s a major problem if this issue still persists.
Every normal OS registers a boot option with the UEFI and puts its bootloader into a normal directory. It also pushes its own bootloader as the default in some cases, but that's just a single boot order change away after booting into the UEFI setup (or after messing with confusing and dangerous tools from inside Windows, which I wouldn't recommend).
The dual boot problem is only really insurmountable in BIOS+MBR mode (which should be considered long deprecated) and with buggy motherboards. Some people will set their system to BIOS+MBR mode for some weird reason, but with Windows 11 this mode should finally be dead already. UEFI has been an option since at least Windows 7 but it was disabled by default for a long time, so if you've upgraded to Windows 10 from a previous version, you'll most likely still be running this old and unstable config. I think this is one of the reasons new Linux users have so much trouble dual booting.
Modern motherboards detect different UEFI bootloaders installed on EFI partitions even if you swap around SSDs. Dual booting has come a very long way!
There's another problem. Motherboards with non-compliant UEFI specs. Exact details here may be flawed, but one of the most insidious dual boot issues I had, which prevented grub from loading was that it turned out, if you had a folder or file labeled windows or Microsoft in the EFI partition, it would always preferentially boot that one no matter what order you set to actually prefer. To fix it, I had to run the Linux EFI utilities for OS detection to set everything up, then go in and manually change everything with windows to some other name. This included modifying whatever the grub configuration file is that says to never modify manually. The biggest issue I had is that it took a LONG time to figure out that noncompliant UEFI specs on the motherboard was the problem. It was maddening.
https://bugs.launchpad.net/wubi/+bug/1471344
Removing wubi was a quick fix instead of patching it.
Wubi also had a dependency on grub4dos which had an idiosyncratic development and release style, to say the least. It was also the only component developed by non-English speakers, which made communication very hard. Later releases had some major regressions that were never sorted out, and I think everyone involved found it highly draining to deal with these issues without a more fundamentally correct way of tracking and preventing regressions.
Considering that Windows 95 still was a shell over DOS (until a later update?), you could conceivably just ‘quit to DOS’ and then run Linux. Alas I don't know of a reverse process.
A 486DX2-80 paired with a much newer circa-1997 3GB IDE hard disc on a VL-Bus controller should have been CPU-bound. UMSDOS made it disk-bound.
Its most solid use case was probably "mount a shared prtition and still have some Unix filename support".
Install your bootloader to the SAME partition as you installed linux in. This is not the default in either windows or linux - and it will try to scare you into not doing it. But do it!
Now, use your laptop's built in bios feature - "press f12 while rebooting" to select the disk to boot into. This will never fail. You can reinstall windows as many times as you like. You can burn your linux install and reinstall. They will never screw each other over and you will never be left unbootable.
FYI- I had a Dell XPS laptop and it would work just fine.
How does that even work? Is your motherboard able to read ext4 partitions?
[1] curl https://wiki.archlinux.org/title/Syslinux | grep partitionless
[2] https://unix.stackexchange.com/questions/103501/boot-partiot...
However, strictly speaking - modern bioses can scan bootable partitions.
You can however install GRUB to USB stick and boot the USB stick from the BIOS. This also protects your Linux install against any Windows malware that doesn't change the BIOS if you are careful to remove the stick before booting Windows, put /boot on the USB stick as well and encrypt the Linux partition.
I have generally not seen a non-UEFI bios or computer in the past 6-7 years. So you should be fine with UEFI.
Again, for some reason Linux installers scare you into using MBR mode. Its unnecessary now.
"would it be possible to hardlink C:\Users -> С:/home, for extra awesomness?"
(Yes, this is a joke)
Also, this reminds me of UMSDOS.
So that was an interesting experiment, but I'm not really sure if that's a good idea. Anyone wants to enlighten me on that?
Linux installers are usually friendly with Windows, but Windows installers are still hostile to other OSes (I think).
This only happens in two specific cases: 1. MBR + same physical disk for both OSes; 2. Bad UEFI implementation on the mobo + same physical disk for both OSes.
Otherwise it should work flawlessly because their bootloaders are independent and it's only a matter of setting the desired boot order.
The things that grow over time aren't part of the OS, they are user data, which can be shared without doing anything special -- just mount it up.
Unfortunately, that's not entirely true, at least for Windows. OS updates and other files are regularly stored in folders that aren't always trivial to put into a different partition. Not that this is enough of a reason to make this abomination your main install, but...
There's solutions to this that are not the OP and are probably easier, people just write them off because "ew CLI."
Having root filesystem on NTFS in any semi-sane way involves having kernel space NTFS FS implementation. Such a driver was introduced in 5.15 released on the 1st of this month.
you can do it with a single GPU nowadays
https://www.youtube.com/watch?v=_JTEsQufSx4
windows should be considered as a spyware, nobody should have it installed on an hardware
use VM with a good firewall behind