If you don't have any USB or DVD available and want to install Windows directly onto a specific partition from Ubuntu, you can use equivalent methods to WinNTSetup. While it is a bit more complex, you can still achieve this without removable media. Below are the detailed instructions to install Windows on a target partition using wimlib and ensure that it does not overwrite existing boot settings.
Prerequisites
    1. Backup: Backup all important data before proceeding with partitioning or installation.
    2. Windows ISO: Make sure you have the Windows ISO file on your Ubuntu system.
    3. Tools: Ensure the following tools are installed on your Ubuntu system:
        ◦ wimlib: for applying the Windows image. 
        ◦ gparted: for partitioning. 
        ◦ ntfs-3g: for NTFS file system support. 
       Install them using:
    3. sudo apt update
       sudo apt install wimlib gparted ntfs-3g
Step-by-Step Installation
Step 1: Partition Your Disk
    1. Open GParted:
Open GParted and identify your disk.
    2. Create an NTFS Partition:
        ◦ If you have unallocated space, right-click it and choose New. Format it as NTFS. 
        ◦ If you need to resize an existing partition, right-click on it and select Resize/Move. Allocate enough space for Windows (at least 20-30 GB recommended). 
        ◦ Apply your changes. 
Step 2: Mount the Windows ISO and NTFS Partition
    1. Mount the Windows ISO:
Create a mount point and mount your Windows ISO:
    • mkdir ~/windows-iso
sudo mount -o loop /path/to/windows.iso ~/windows-iso
    • Mount the NTFS Partition (where you will install Windows):
Create a mount point and mount the NTFS partition:
    2. sudo mkdir /mnt/windows
       sudo mount -t ntfs /dev/sdXN /mnt/windows  # Replace sdXN with your NTFS partition
Step 3: Copy Necessary Files and Apply the WIM
    1. Copy Windows Files:
First, copy necessary files from the ISO to your mounted NTFS partition:
    • sudo cp -r ~/windows-iso/* /mnt/windows/
    • Locate the WIM File:
Check inside the mounted ISO to find the install.wim:
    • ls ~/windows-iso/sources/*.wim
    • Apply the WIM File to the NTFS Partition:
Use wimlib to apply the Windows image:
    3. sudo wimlib-imagex apply ~/windows-iso/sources/install.wim 1 /mnt/windows
       Here, 1 is typically the index of the edition you want (check available indices using wimlib-imagex info ~/windows-iso/sources/install.wim).
Step 4: Prepare Boot Files without USB/DVD
Here, you can ensure that Windows recognizes your installation and can boot properly:
    1. Set Up Boot Files:
To make the partition bootable, the easiest way if you don't have a recovery environment is to use a Windows environment. You can create a regular boot entry, but it often requires a recovery environment.
       Thus, the following step is more of a safeguard. You can skip this but if you have access to a Windows recovery mode, do the following:
        ◦ If you can temporarily boot into a Windows Recovery USB from somewhere else (borrow one, or create one on another machine), access the command prompt and run:
    • bcdboot X:\Windows /s Y: /f UEFI
Here, X: is your Windows partition where C:\Windows resides, and Y: is your EFI partition (usually FAT32).
    • If No Recovery Media Available:
You can still make it possible to load Windows:
    • Mount the existing EFI Partition:
You need to identify your EFI partition using lsblk and then mount it:
    • sudo mkdir /mnt/efi
      sudo mount /dev/sdXY /mnt/efi  # Replace sdXY with your EFI partition (often around 100-300MB FAT32)
The following might help view your partitions:
    2. lsblk
        ◦ Install GRUB to Recognize Windows: Windows writes to the EFI partition during installation. Thus, make sure not to remove or overwrite it. 
Step 5: Update GRUB to Show Windows
    1. Reboot your machine:
If your system boots into Windows, it’s fine.
    2. Boot into Ubuntu:
Once you're back to your Ubuntu instance.
    3. Update GRUB:
Open a terminal and run:
    3. sudo update-grub
       This should detect the Windows installation and add it to the GRUB menu.
    4. Check GRUB Entries:
Verify the entries in /etc/default/grub and /etc/grub.d/40_custom for custom configurations if needed.
    5. Reboot:
Restart your system, and you should see an option for both Ubuntu and Windows in the GRUB menu.
Conclusion
This installation process allows you to install Windows directly onto a partition from within Ubuntu without needing a USB or CD/DVD. It involves copying the necessary files, applying the WIM image, and ensuring the boot process is correctly configured to facilitate dual-booting via GRUB. 
Important Note: Always ensure that the installation process does not interfere with your existing EFI settings and that the boot configuration is correctly restored. If possible, have a recovery option handy for both operating systems to restore settings in case something goes awry.
2 questions:
which necessary files needs to copied before run install wim, do we really need this?
is wim install will create to existed EFI partiotion boot files?
Great questions! Let's clarify what you need for a successful installation of Windows using the install.wim file and how it interacts with the EFI partition.
Question 1: Which Necessary Files Need to be Copied Before Running install.wim?
In many cases, you do not need to manually copy files from the Windows ISO to the target partition before applying the install.wim. Instead, you can apply the WIM image directly to the designated NTFS partition.
However, copying certain files can be beneficial for ensuring that Windows installation has all the required setup files and boot configuration right after applying the WIM image. Here’s a breakdown:
    1. Boot Files: The files from the sources folder are not strictly necessary before running the install.wim, but they're typically present in a fresh Windows installation. Copying them can be seen as preparing the environment for the installation:
        ◦ bootmgr 
        ◦ BCD 
        ◦ Other potential recovery tools that may be in the ISO. 
    2. Windows Configuration: These are useful for ensuring that you can boot directly into Windows after the installation is complete, as they guide the bootloader on how to start Windows.
So, while it’s not strictly necessary to copy every file to the NTFS partition before applying the install.wim, copying files such as bootmgr and files in boot (if applicable) can facilitate a smoother installation experience.
Question 2: Will the WIM Install Create Boot Files in the Existing EFI Partition?
Yes, when you apply the install.wim using wimlib, it does not automatically create or write the necessary boot files in the EFI partition needed for Windows to boot. Here's how this works:
    1. WIM Image Application: The wimlib-imagex apply command applies the contents of the Windows image to the specified NTFS partition where Windows will be installed. It does not modify the EFI partition or install the bootloader.
    2. Bootloader Setup: After applying the WIM image, you generally need to configure the EFI partition to recognize the new Windows installation. This is typically accomplished using the bcdboot command from a Windows command line environment (using a recovery USB or during a Windows setup), which will equip the EFI partition with:
        ◦ The necessary boot files. 
        ◦ The Boot Configuration Data (BCD) that helps the system find the installed Windows. 
    3. Interaction with EFI Partition: 
        ◦ If the system has an existing EFI partition, the Windows installation process creates the necessary boot files there. This is important to facilitate the booting process of Windows during startup. 
        ◦ If you are applying the WIM image directly from Linux, be aware that while you can install Windows files, you will need to utilize a Windows environment to set up the boot loader properly on the EFI partition. 
Final Recommendations
    • Recovery and Tools: If you don’t have a Windows installation USB, you may need to borrow one to create the necessary boot files in the EFI partition. This step is essential for ensuring that Windows can boot correctly after installation.
    • Post-installation: After applying the WIM and ensuring the files are copied or have a means to run bcdboot or similar commands, you can also update GRUB in Ubuntu to show both operating systems in the boot menu.
This way, you’ll have a seamless dual-boot configuration with your newly installed Windows and existing Ubuntu systems. If you have any more questions or need further assistance, feel free to ask!
is there nothing to use instead of bcdbood?
If you want to set up a Windows installation without using bcdboot, especially if you're working in a Linux environment without access to a Windows recovery environment, there are some alternatives, though they may not be as straightforward as bcdboot.
Alternative Methods to Set Up Boot for Windows
    1. Using shim and grub Only:
If you have already applied the install.wim to your NTFS partition but don't have access to bcdboot, you can manually create an entry in GRUB that points to the Windows boot manager. This won't replace bcdboot, but it will allow you to boot into Windows from GRUB directly.
       Here’s how to manually create an entry:
        ◦ Identify the partition where Windows is installed. You can use lsblk to find this out (e.g., /dev/sda2).
        ◦ Open the GRUB configuration file:
    • sudo nano /etc/grub.d/40_custom
    • Add a custom entry for Windows:
    • menuentry "Windows 10" {
    insmod part_gpt
    insmod chain
    set root=(hd0,gptX)  # Replace X with the number corresponding to your Windows partition
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
    • After editing, save the file and exit.
    • Update GRUB:
    • sudo update-grub
At this point, if you reboot, you should see an entry for Windows in the GRUB menu.
    • Using efibootmgr:
If your system supports UEFI, you can use efibootmgr to create a boot entry for Windows directly. However, this still typically requires that the Windows bootloader has been installed in the EFI partition.
    • Ensure your Ubuntu installation has efibootmgr:
    • sudo apt install efibootmgr
    • You can check existing entries with:
    • sudo efibootmgr
    • To add a new boot entry pointing to Windows (assuming it's installed correctly at /EFI/Microsoft/Boot/bootmgfw.efi):
    • sudo efibootmgr -c -d /dev/sdX -p Y -L "Windows Boot Manager" -l '\EFI\Microsoft\Boot\bootmgfw.efi'
      Replace /dev/sdX with your disk (e.g., /dev/sda) and Y with the partition number of your EFI partition.
    • Using grub-install:
If you have the appropriate permissions or capabilities, in some installations of Linux with grub (especially if you're using it as an EFI application), you might be able to install GRUB with:
    3. sudo grub-install --target=x86_64-efi --efi-directory=/mnt/efi --bootloader-id=GRUB
Reminder:
    • Creating Windows Boot Files: If you have installed Windows without running bcdboot, the necessary files (bootmgfw.efi, etc.) may not exist in the EFI partition. They need to be created during Windows installation. 
    • Impact of Missing bcdboot: Without running bcdboot, Windows may not load even with GRUB entries. The bcdboot command is crucial for setting up the Boot Configuration Data (BCD), and thus providing the bootloader needed to start Windows.
Conclusion
While there are alternatives to bcdboot, they usually require you to have the Windows boot files properly placed in the EFI partition initially. If bcdboot is not an option, your best approach is to configure the GRUB menu to load Windows directly or use tools like efibootmgr to help manage your boot options. 
If you have any further questions or need clarifications on these methods, feel free to ask!
msr is must be in windows partition or this is optional
The Microsoft Reserved Partition (MSR) is a partition that is created on GPT (GUID Partition Table) disks when installing Windows. However, the MSR partition has specific characteristics and use cases:
What is the MSR Partition?
    • Function: The MSR partition is intended for use by Windows for various reasons, particularly for storage of certain system metadata or to manage space for dynamic disks and other features. 
    • Size: The MSR partition is typically 16 MB in size. 
Is the MSR Partition Required?
    • Only for GPT Disks: 
        ◦ If you are installing Windows on a GPT disk configuration, the MSR partition is recommended but not strictly required for the system to boot or operate. Windows will function without it, but it is recommended to allow for future flexibility (like the creation of dynamic disks). 
    • For MBR Disks: 
        ◦ If you are using a Master Boot Record (MBR) partition table instead of GPT, there is no MSR partition needed at all. 
Key Points
    1. For Windows Installation: If you’re installing Windows in a dual-boot configuration on a system that already uses GPT (like modern UEFI systems), the installation process may create an MSR partition automatically if it detects the need. 
    2. Multiple OS Configurations: If you're setting up a triple or multi-boot situation, the presence of an MSR partition can aid in Windows operating properly alongside other operating systems. 
    3. Manual Management: If you are manually managing partitions (like during a custom installation process), not creating an MSR partition will not prevent Windows from functioning; however, it might limit certain features (especially future features that rely on partition management). 
Conclusion
In summary, while the MSR partition is not strictly necessary for Windows to operate, it is advisable to create one when setting up a GPT partition scheme. For basic installations, you can successfully run Windows without it, but it is good practice to include it for optimal configuration and flexibility. If you are dual-booting, it's typically handled during installation by Windows itself.
If you have further questions or specific scenarios where you're considering partitioning, feel free to ask!


everything is ok but something was not installed. winntsetup needs 2 parts(system and windows) but efi installs after and automatically. With wim i've only installed windows, what must be in system part?