News for hackers. Stuff that matters.
Re:Installing Windows and Linux into the same partition by Nextgrid on Saturday November 20, 2021 @11:56AM (#29289718)
In terms of similar “interesting” things one I successfully did in the past that I wanted to share was to have a single Linux environment that you could either boot into or run in a VM.

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.

Re:Installing Windows and Linux into the same partition by franga2000 on Sunday November 21, 2021 @06:05AM (#29295445)
I actually managed to get it to work both ways: I can boot each OS in a VM from the other. A handful of scripts inside each detect the VM and make some changes appropriately (like disabling certain startup apps and services that I already have in the host OS, disabling some fancy graphics that like to glitch out in VMs, etc.). And because I like to over-complicate things, I set up static IPv4s, so I can for example connect to Linux with the same IP, not matter if it's in a VM or running on bare metal.

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.

[0] https://github.com/bobafetthotmail/refind-theme-regular

Re:Installing Windows and Linux into the same partition by deft on Saturday November 20, 2021 @12:23PM (#29289957)
Using VFIO passthrough and qemu I have the opposite of this which is really convenient, a windows disk that can boot as a vm or normally.
Re:Installing Windows and Linux into the same partition by pitaj on Saturday November 20, 2021 @01:15PM (#29290434)
What resources did you use to set this up? This is my dream setup.
Re:Installing Windows and Linux into the same partition by rzzzt on Saturday November 20, 2021 @01:29PM (#29290572)
Mine would be booting into a minimal Linux installation/hypervisor that fires up a Linux and a Windows VM, both full-screen, between which you could swap with a pair of keyboard shortcuts.
Re:Installing Windows and Linux into the same partition by vadfa on Saturday November 20, 2021 @04:10PM (#29291873)
I've done that. But it gets annoying too.
Re:Installing Windows and Linux into the same partition by deft on Saturday November 20, 2021 @01:27PM (#29290543)
reddit r/vfio and the arch wiki page here https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF there's also the level1tech forums which have a ton of information on it. The gist of it is this: Qemu with uefi boot, configured through virt-manager, passing in both the gpu and windows boot disk (nvme) as raw devices to the vm.
Re:Installing Windows and Linux into the same partition by tatref on Saturday November 20, 2021 @03:14PM (#29291473)
Do you have any issue with drivers or license when switching between the VM and normal?
Re:Installing Windows and Linux into the same partition by sudosysgen on Saturday November 20, 2021 @05:10PM (#29292317)
I did the same and fixed the license issues by pirating windows.

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.

Re:Installing Windows and Linux into the same partition by marcan_42 on Sunday November 21, 2021 @12:24AM (#29294383)
You can keep the licensing stuff happy by cloning the firmware GUID, MAC addresses, and disk serial numbers into the VM, in my experience.
Re:Installing Windows and Linux into the same partition by larusso on Saturday November 20, 2021 @01:38PM (#29290648)
I did this on a Mac with my bootcamp partition with parallels desktop. I only booted into windows when I wanted to play a game. The rest was mainly done as a VM. I had some shenanigans with windows licenses and other software that insisted that these systems are two different computers ;)
Re:Installing Windows and Linux into the same partition by arendtio on Saturday November 20, 2021 @01:33PM (#29290615)
10 years ago or so, I wanted to have a windows on a portable USB HDD. Windows 7 didn't want to be installed on USB-drives, but once it was installed you could modify it (edit a text file or so), to make it work. So I used a VM with the usb-drive as the HDD. That way Windows didn't knew it was being installed onto a usb-drive and everything worked fine.
Re:Installing Windows and Linux into the same partition by ccouzens on Saturday November 20, 2021 @04:06PM (#29291846)
I've done the same to install Windows 10 to an external SSD (I don't want to divide my laptop's internal drive up between two different operating systems).

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.

Re:Installing Windows and Linux into the same partition by sysadm1n on Sunday November 21, 2021 @06:49AM (#29295686)
Might try this. It would be great to have Windows To Go back.

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?

Re:Installing Windows and Linux into the same partition by ccouzens on Monday November 22, 2021 @02:25AM (#29303770)
> 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).

Re:Installing Windows and Linux into the same partition by sysadm1n on Sunday November 21, 2021 @06:45AM (#29295667)
I used Windows To Go[0] and you could put Windows 8 on an SSD or even a USB flash drive.

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!

[0] https://en.wikipedia.org/wiki/Windows_To_Go

Re:Installing Windows and Linux into the same partition by arendtio on Sunday November 21, 2021 @03:17PM (#29299322)
Attaching a physical hard drive to a VirtualBox VM was straight forward back in the day. First guide I found is this:

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.

Re:Installing Windows and Linux into the same partition by GhettoComputers on Saturday November 20, 2021 @04:31PM (#29292033)
Anyone interested in this setup try this if you have NVIDIA?

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.

Re:Installing Windows and Linux into the same partition by captn3m0 on Saturday November 20, 2021 @01:34PM (#29290619)
I did this as well, and consider it to be my "weirdest" linux install as well. I documented it on AskUbuntu[0] and followed these instructions[1] - they involve creating a fake disk image using the VBoxManage cli. The reason I had to do this was also because of the "no-external-media-to-install-Linux" challenge. WUBI[2] used to be a solution for this, but it had it's own challenges (and was only Ubuntu iirc) and was discontinued (much after I used this trick)

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...

[2]: https://help.ubuntu.com/community/Wubi

Re:Installing Windows and Linux into the same partition by samtheprogram on Saturday November 20, 2021 @02:28PM (#29291073)
Recently I tried sharing a Steam library between Windows and Linux. Sadly, Proton does not support FAT32 so if your goal is to run those games under Proton you will be disappointed.
Re:Installing Windows and Linux into the same partition by Tsiklon on Saturday November 20, 2021 @03:41PM (#29291655)
Honestly, given it's limitations (4GB Max Filesize & no journaling) FAT32 should not be used for anything aside from low capacity removable storage (or a purpose which is not frequently read from/written to).

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).

Re:Installing Windows and Linux into the same partition by samtheprogram on Saturday November 20, 2021 @03:53PM (#29291744)
FWIW I technically use exFat, my mistake.

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.

Re:Installing Windows and Linux into the same partition by Tsiklon on Saturday November 20, 2021 @04:28PM (#29292007)
You're completely correct - my apologies for that, Things certainly are looking up though.
Re:Installing Windows and Linux into the same partition by aasasd on Saturday November 20, 2021 @12:44PM (#29290166)
IIRC Linux has a capability to specify the root partition at some time during loading. (Probably via the bootloader params—this is where Grub comes in use.) This is helpful for booting from a ‘recovery’ floppy/cd/usb drive and into the system on the HD. But can also be used with VMs.

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.

Re:Installing Windows and Linux into the same partition by checkyoursudo on Saturday November 20, 2021 @05:14PM (#29292337)
In my system (Gentoo Linux), I boot via efistub and a built-in kernel command line that points to my root partition, so you don't even need Grub technically though I think it works basically the same way. Literally just 'root=PARTUUID=$whatever' compiled into the kernel, and you can set it as any valid rootfs target as far as I know. I don't even use an initramfs or initrd. I just boot right into my root partition in a couple of seconds.
Re:Installing Windows and Linux into the same partition by adamnew123456 on Saturday November 20, 2021 @03:54PM (#29291751)
In case anyone wants more detail on the internals:

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.

[1] https://wiki.debian.org/InitramfsDebug

Re:Installing Windows and Linux into the same partition by chrsig on Saturday November 20, 2021 @02:27PM (#29291065)
> IIRC Linux has a capability to specify the root partition at some time during loading. (Probably via the bootloader params—this is where Grub comes in use.) This is helpful for booting from a ‘recovery’ floppy/cd/usb drive and into the system on the HD. But can also be used with VMs.

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

Re:Installing Windows and Linux into the same partition by wildbook on Saturday November 20, 2021 @12:43PM (#29290157)
I used to have a setup similar to this, where I had a Windows 10 install and a Linux install on different partitions, both being able to boot into the other through I think VMWare?

Had the same experience, it worked surprisingly good and was easily good enough for daily use.

Re:Installing Windows and Linux into the same partition by fuzzfactor on Saturday November 20, 2021 @10:51PM (#29294060)
Naturally that's also the regular way you can also boot into either partition bare metal when you want.

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.

Re:Installing Windows and Linux into the same partition by selectodude on Saturday November 20, 2021 @12:53PM (#29290240)
Wrong OS, but VMware Fusion could do that with a boot camp volume. Worked magnificently. One of the few things I'm disappointed about losing with the transition to arm64.
Re:Installing Windows and Linux into the same partition by aasasd on Saturday November 20, 2021 @02:39PM (#29291178)
Rumor is, VMs work in Rosetta. Apparently people run Windows games that way—and are saying that performance is at least not worse than in plain Windows on x64.

(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.)

Re:Installing Windows and Linux into the same partition by selectodude on Saturday November 20, 2021 @03:03PM (#29291395)
I know that WoA works in Parallels Desktop, though I haven't tried it. That would at least give you access to x86-64 emulation in Windows. I am curious about playing around with Crossover which apparently implements WINE using Rosetta.

Maybe I'll use my free time this weekend to try and compile that.

Re:Installing Windows and Linux into the same partition by 58028641 on Sunday November 21, 2021 @03:05PM (#29299233)
VMs do not work in Rosetta. But you can run ARM64 Windows in a VM and use Windows' x64 emulation. Rosetta does work with Wine.
Re:Installing Windows and Linux into the same partition by GauntletWizard on Sunday November 21, 2021 @04:17AM (#29295102)
I was recently doing archaeology of my ZFS disk, and it reminded me of how I started using ZFS - With three disks in a Raid, running under FreeBSD. That FreeBSD System was running as a guest via VirtualBox, with the windows machine host having it's own disk. I then mounted that via Samba/CIFS... Good times, terrible hacks.
Re:Installing Windows and Linux into the same partition by moondev on Saturday November 20, 2021 @08:55PM (#29293503)
You can also install VMware esxi on a thumb drive and just boot from that. esxi has excellent support for them booting physical or virtual disks including USB and GPU passthrough from there. If you want to boot your VM on bare metal then just remove the thumb drive on next boot.
Re:Installing Windows and Linux into the same partition by yesbabyyes on Saturday November 20, 2021 @02:28PM (#29291071)
I did this with VMware Workstation back in 2000-01, only the other way around if I remember it right (Linux host, dual booting / shared with a virtual Windows 2000 partition). I was honestly surprised it worked so well.
Re:Installing Windows and Linux into the same partition by dmead on Saturday November 20, 2021 @12:43PM (#29290162)
I used to do this, but afaik virtual box explicitly disabled this because you risk some problem with data corruption on the partition running on the vm.
Re:Installing Windows and Linux into the same partition by aasasd on Saturday November 20, 2021 @12:49PM (#29290209)
Perhaps disabled in the GUI, but you can still create a VMDK ‘disk’ file that is just a text file specifying the partition to use.

I'm occasionally using this to install Linux on an external drive.

Re:Installing Windows and Linux into the same partition by Nextgrid on Saturday November 20, 2021 @01:08PM (#29290356)
Yes that's exactly how I did it back then.
Re:Installing Windows and Linux into the same partition by yjftsjthsd-h on Saturday November 20, 2021 @12:55PM (#29290250)
If you have the ability to mount the filesystem from the VM and the host, then you would almost certainly break the filesystem, although I can't immediately think how to do that with NT host and a Linux VM unless you added a third-party driver for the Linux filesystem.
Re:Installing Windows and Linux into the same partition by dmead on Saturday November 20, 2021 @08:34PM (#29293413)
There used to be decent ext drivers for windows 7/vista/xp64
Re:Installing Windows and Linux into the same partition by ineedasername on Saturday November 20, 2021 @12:53PM (#29290242)
I recently did this with the free VMware Player, and it worked alright. Mostly just for "can I do this?", so I don't know how viable or stable it would be for actual use.
Re:Installing Windows and Linux into the same partition by Tenoke on Saturday November 20, 2021 @12:06PM (#29289817)
I wish I can easily make this work with WSL. It seems the new features in Windows 11 might make it possible but it's unclear how well it will work.
Re:Installing Windows and Linux into the same partition by niklasbuschmann on Saturday November 20, 2021 @01:22PM (#29290490)
This works with Windows too.

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.

Re:Installing Windows and Linux into the same partition by jdsully on Saturday November 20, 2021 @12:42PM (#29290155)
I did this with windows but it kept needing to be reactivated so I eventually just gave up.
Re:Installing Windows and Linux into the same partition by tjoff on Saturday November 20, 2021 @01:33PM (#29290616)
You can clone the hardware id (or whatever it is called) so that the VM matches the physical hardware. Which satisfies windows.

Though I don't remember how or whether it is legal.

Re:Installing Windows and Linux into the same partition by naikrovek on Saturday November 20, 2021 @05:42PM (#29292480)
it's legal, but whether or not it violates the license agreement is what you mean, I think.

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

Re:Installing Windows and Linux into the same partition by dixie_land on Saturday November 20, 2021 @12:24PM (#29289974)
Parallel Desktop does something similar (and very seamlessly) on macOS and boot camp.