Windows and other Microsoft technologies: Difference between revisions

From Elvanör's Technical Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 4: Line 4:


* First partition the drive using Linux (booted via an Ubuntu USB key). On recent systems you only need two partitions, the ESP (UEFI boot partition) and one main NTFS partition for Windows itself. Plan for additional Linux partitions right away.
* First partition the drive using Linux (booted via an Ubuntu USB key). On recent systems you only need two partitions, the ESP (UEFI boot partition) and one main NTFS partition for Windows itself. Plan for additional Linux partitions right away.
* Then install Windows before Gentoo Linux. Download Windows 11 on the official Microsoft site, then use woeusb on Linux or Microsoft tools on Windows to write the ISO to an USB key. See the additional section below for more information.
* Then install Windows before Gentoo Linux. Download Windows 11 (or later) on the official Microsoft site (choose United States English, as the International English contains United Kingdom English). Note that the image provided contains Windows 11 Pro. Then use Rufus on Windows to write the ISO to an USB key. See the additional section below for more information.
* The Windows installer normally does not touch non NTFS partitions. It will install boot files on any ESP system it finds. Its partitioning / formatting capabilities are extremely reduced, thus it is much better to prepare everything in Linux and just install on the single NTFS partition you created (it should pick up the ESP automatically).
* The Windows installer normally does not touch non NTFS partitions. It will install boot files on any ESP system it finds. Its partitioning / formatting capabilities are extremely reduced, thus it is much better to prepare everything in Linux and just install on the single NTFS partition you created (it should pick up the ESP automatically).
* It's still possible currently to run Windows 11 without a Microsoft online account, however you must [https://www.tomshardware.com/how-to/install-windows-11-without-microsoft-account follow the instructions there.] Basically, hit Shift + F10 and then type '''OOBE\BYPASSNRO''' command.
* It's still possible currently to run Windows 11 without a Microsoft online account, however you must [https://www.tomshardware.com/how-to/install-windows-11-without-microsoft-account follow the instructions there.] Basically, hit Shift + F10 and then type '''OOBE\BYPASSNRO''' command.
* Once Windows is installed, you can setup Gentoo Linux and install GRUB 2 on the ESP.
* Once Windows is installed, you can setup Gentoo Linux and install GRUB 2 on the ESP.


== Creating a Windows Boot USB Key on Linux ==
== Creating a Windows Boot USB Key==


* Not sure if it is possible anymore for modern UEFI systems. I tried creating an image of Windows 11 with Etcher; the USB key booted but installation failed.
* Not sure if it is possible anymore on Linux for modern UEFI systems. I tried creating an image of Windows 11 with Etcher; the USB key booted but installation failed. I also tried woeusb, which also did not work.
* If not possible on Linux, it is quite easy to create a bootable USB key on Windows (directly with Microsoft tools). Another previously used tool was Rufus (not sure if it still works but it's probably no longer needed).
* If not possible on Linux, it is quite easy to create a bootable USB key on Windows. The use of Rufus is recommended, as this tool can disable important options (TPM, requirement of a Microsoft online account, BitLocker).
* Apart from Rufus, Microsoft provides its own official bootable media creation tool. This will create a bootable media that can be used on any computer. This can be used as a failover option if Rufus does not work (but Rufus remains the best option and should work).


== Migration from previous installs ==
== Migration from previous installs ==

Revision as of 14:58, 30 May 2025

This article discusses the optimal way to install and operate Windows on a hard drive where Linux will be the main OS (of course).

Installation

  • First partition the drive using Linux (booted via an Ubuntu USB key). On recent systems you only need two partitions, the ESP (UEFI boot partition) and one main NTFS partition for Windows itself. Plan for additional Linux partitions right away.
  • Then install Windows before Gentoo Linux. Download Windows 11 (or later) on the official Microsoft site (choose United States English, as the International English contains United Kingdom English). Note that the image provided contains Windows 11 Pro. Then use Rufus on Windows to write the ISO to an USB key. See the additional section below for more information.
  • The Windows installer normally does not touch non NTFS partitions. It will install boot files on any ESP system it finds. Its partitioning / formatting capabilities are extremely reduced, thus it is much better to prepare everything in Linux and just install on the single NTFS partition you created (it should pick up the ESP automatically).
  • It's still possible currently to run Windows 11 without a Microsoft online account, however you must follow the instructions there. Basically, hit Shift + F10 and then type OOBE\BYPASSNRO command.
  • Once Windows is installed, you can setup Gentoo Linux and install GRUB 2 on the ESP.

Creating a Windows Boot USB Key

  • Not sure if it is possible anymore on Linux for modern UEFI systems. I tried creating an image of Windows 11 with Etcher; the USB key booted but installation failed. I also tried woeusb, which also did not work.
  • If not possible on Linux, it is quite easy to create a bootable USB key on Windows. The use of Rufus is recommended, as this tool can disable important options (TPM, requirement of a Microsoft online account, BitLocker).
  • Apart from Rufus, Microsoft provides its own official bootable media creation tool. This will create a bootable media that can be used on any computer. This can be used as a failover option if Rufus does not work (but Rufus remains the best option and should work).

Migration from previous installs

  • Even with recent Windows (10) versions, moving Windows from a partition to another is a pain. Boot logs are inexistent, Windows can easily become unbootable. It is thus recommended to follow these recommendations:
  • If you need to move Windows from one drive to another, use Partition Magic on Windows (best tool for partition management), cloning the whole drive. Then rearrange / fix partitions on Linux as usual.
  • In theory, bcdboot and bcdedit programs could recreate a functional ESP and bootable system after a single partition has been cloned to a new drive but in my case, it never worked out. Note that these programs should ALWAYS be started from a USB Windows installation drive, not from a running Windows system.

Important Notes

  • When you install Windows, be sure to install it on a system with a SINGLE hard drive, or at least with no other hard drives containing Windows. If you install it while another drive containing Windows is present, it won't write the bootloader into the partition of the newly installed Windows. Rather it will modify (without telling you anything) the configuration file (boot.ini) of where the previous bootloader is installed. You'll later encounter problems with GRUB's chain-loading (dual-booting) mechanism.
  • If you anyway made a mistake and installed Windows while another drive containing Windows was present, you can still fix the problem. Copy the files boot.ini, ntldr and ntdetect.com from the older Windows installation into the new one. These files are present on the root of the partition (although they are hidden, so you must edit settings to see them). Once they are copied, modify the file boot.ini on the new system so that it is correct.

Windows Boot System

  • On a system with UEFI, Windows will need three partitions: the EFI boot partition (FAT32 file system), the MSR (Microsoft Reserved Partition, it has no filesystem and under gparted has the msftr flag), and the main Windows partition (in this order).
  • Do not delete the MSR partition as the system will probably become unbootable!
  • You can create a Windows 8 Repair USB drive easily if you have access to a Windows 8 computer. This even works under VirtualBox.

Various Tips

  • If you forget your Windows 10 password, you can reset it under Linux with the chntpw tool. Do not use any Windows tool, they have lots of problems. chntpw seems to work really well, but I used it only once.
  • You can extract the file from a Windows installer by running it like that in the Windows console:
setup.exe -a -pc c:\path\to\extraction
  • To disable Windows key (very important in games), follow the instructions here. Note that this is the only correct tutorial I have found for Windows 10.
  • To disable special media keyboard keys (also essential in games) on Windows 10, you have to edit the registry. Change the "Start" key DWORD value to 4 in HKEY_LOCAL_MACHINE:\SYSTEM\CurrentControlSet\Services\hidserv.

Windows on a non-first hard drive

  • Windows does not support booting from the non first hard drive in the system. So if you install Windows on such a drive, the following manipulation will be necessary in GRUB:
title Windows XP SP2 (English)
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
makeactive
chainloader  +1

This fakes the second drive as the first one. You do not need to edit boot.ini settings after you did this.

Windows 11

Windows Vista

  • With Windows Vista, if you somehow change your hard drive partitions, Vista will generally end up being unbootable. This can be repaired with a Vista boot CD easily though. It should not even wipe out GRUB of the MBR.

Copying a Windows 7 partition under Linux

  • The procedure is explained here.
  • It is extremely important to respect the same partition offsets. In particular, recent versions of fdisk seem to start the first partition on sector 2048. To be able to start on previous sectors, use fdisk -c=nondos option. Also don't forget to copy the MBR to the new hard drive.
  • Note also that in my case, ntfsclone did not work. dd worked however.

FAT32

  • Even with FAT32, you cannot use files larger than 4GB. Thus FAT32 is not a good file system for USB keys.


Obsolete Information

  • You can go to the recovery console by booting the install CD and then typing "R".

Old information for BIOS systems

  • On any hard drive, there can be only 4 primary partitions. Primary partitions can be used for booting; an extended partition can then contain any other number of partitions (it's in fact a placeholder). In fdisk for example, if there is an extended partition fdisk will display it overlapping with the actual partitions it contains (an extended partition is not an "actual" partition). Booting from an extended partition (in fact, a partition within an extended partition may be more correct) may be possible, but I am not sure. It may not be possible to boot directly from within GRUB into such a partition.
  • Create the primary partition under Linux, choosing NTFS as the partition type, then boot the Windows install CD-ROM and install onto that partition. As always, the less Windows does for you the better, since you do not control the process (Windows can actually create an extended partition without your knowledge!).
  • Sometimes, during a Windows update, the process can create additional partitions, thus breaking the Linux boot (the previous root partition for Linux boot will have changed). Only way to repair is to boot via an USB key.
  • Rewrite the partition table as msdos and format your USB drive as NTFS using GParted (also add the boot flag).
  • In GParted, right click the USB partition and select Information. Copy the UUID somewhere as you will need it.
  • Copy all files from mounted Windows ISO or DVD to USB drive using your favorite file manager.
  • Go to USB drive and if the folder named boot has uppercase characters, make them all lowercase by renaming it.
  • Install GRUB on USB: sudo grub-install -v --target=i386-pc --boot-directory="/<USB_mount_folder>/boot" /dev/sdX (for instance /dev/sdc).
  • Create a GRUB config file in the USB drive folder boot/grub with the name grub.cfg:
echo "If you see this, you have successfully booted from USB"
insmod ntfs
insmod search_fs_uuid  
search --no-floppy --fs-uuid <UUID_from_step_2> --set root 
ntldr /bootmgr
  • Unmount the USB drive and restart your PC. Choose the USB as the first boot device in BIOS and start booting from it.