dockur / windows

Windows inside a Docker container.
MIT License
17.4k stars 1.49k forks source link

[Question]: Mounting WinPE ISO and Working on Installed OS Drive #509

Closed WSHAPER closed 4 months ago

WSHAPER commented 4 months ago

Is your question not already answered in the FAQ?

Is this a general question and not a technical issue?

Question

TL;DR

I'm seeking guidance on whether it's possible to mount a WinPE ISO and work on a drive containing an already installed OS, specifically to create an image with prepackaged software after running sysprep on the previously installed OS contained in storage/.

Could you please advise on the following:

  1. Is it possible to mount a WinPE ISO and work on the drive containing the installed OS as described?
  2. If so, what changes or additional configurations are required to achieve this?

Thank you for your assistance in advance!

Setup

Here is my storage/ directory structure:

[4.0K]  ./
├── [4.0K]  shared/
│   └── [ 566]  readme.txt*
├── [   0]  boot.iso*
├── [ 64G]  data.img*
├── [2.9G]  HBCD_PE_x64.iso*
├── [  18]  windows.mac*
├── [   4]  windows.old
├── [3.5M]  windows.rom*
├── [528K]  windows.vars*
└── [   5]  windows.ver*

I've attempted the following compose.yml configuration, but it results in the Windows logo appearing without booting into WinPE:

services:
  windows:
    image: dockurr/windows
    container_name: windows
    environment:
      VERSION: "win10"
      BOOT_INDEX: "1"
    devices:
      - /dev/kvm
    cap_add:
      - NET_ADMIN
    ports:
      - 8006:8006
      - 3389:3389/tcp
      - 3389:3389/udp
    stop_grace_period: 2m
    restart: on-failure
    volumes:
      - ~/github/windows/storage/HBCD_PE_x64.iso:/storage/boot.iso
      - ~/github/windows/storage:/storage
kroese commented 4 months ago

I do not understand so well how you ended up with these files in/storage. To start you have a boot.iso, but this project does nothing with a boot.iso (its from another project called qemu-docker but not used here). Secondly you have a file called windows.old which is only used when legacy booting Windows XP. So you have a very strange collection of files and I dont know what you did.

Also I do not know where you got this HBCD_PE_x64.iso so there is no way for me to try it myself.

WSHAPER commented 4 months ago

First of all, thank you for the quick response for taking the time to resolve my question. I've retried the entire procedure documented below and got the bootable .iso running. However, I'm still not certain on how to properly map the installed partition, so it's visible in the bootable WinPE's diskmgmt.msc.

Clarification

Apologies for the confusion, I was indeed switching between qemu-docker and docker-windows.

Steps to Reproduce

  1. Download tiny11_2311_x64.iso manually
  2. Rename tiny11_2311_x64.iso to custom.iso and place in storage/
  3. Update compose.yml:
    • Map storage/
    • Map win11x64.xml (unattended install)
      volumes:
      - ~/github/dockur-windows/storage:/storage
      - ~/github/dockur-windows/assets/win11x64.xml:/run/assets/win11x64.xml
  4. Remove the following from compose.yml, since src/install.sh:195 seems to match custom.iso:
    environment:
          VERSION: "win11"
  5. Let installation complete after running:
    docker-compose up -d
  6. Inspect via localhost:8006 and shut down after install with:
    docker-compose down
    • After installation, your storage/ should look like this (custom.iso now missing):
      [4.0K]  ./
      ├── [4.0K]  shared/
      │   └── [ 566]  readme.txt
      ├── [ 64G]  data.img
      ├── [   0]  windows.boot
      ├── [  18]  windows.mac
      ├── [3.5M]  windows.rom
      ├── [528K]  windows.vars
      └── [   5]  windows.ver

In a comment on Issue #362 (Boot from ISO After Installation), you suggested setting BOOT_INDEX environment variable to a value lower than 3.

  1. Modify compose.yml and run docker-compose up -d:

    • Set BOOT_INDEX
    • Attempt to map HBCD_PE_x64.iso to custom.iso
      environment:
          BOOT_INDEX: "1"
      volumes:
      # Add (or place `HBCD_PE_x64.iso` as `custom.iso` in `storage/`):
      - ~/path/to/your/file/HBCD_PE_x64.iso:/storage/custom.iso
      # Keep:
      - ~/github/dockur-windows/storage:/storage
      # Remove:
      # - ~/github/dockur-windows/assets/win11x64.xml:/run/assets/win11x64.xml
  2. Open localhost:8006 and run diskmgmt.msc inside the bootable WinPE .iso, where only the virtio-win-0.1.248 shows up, not the drives created in previous installation.

kroese commented 4 months ago

I guess it is normal that the drive doesnt show up, because Windows PE do not have the drivers build-in to read/recognize the Virtio SCSI disks. Normally these drivers are installed during the automatic installation (via the unattended.xml file).

So you need a copy of the Hirens PE ISO that has VirtIO drivers, but I do not think such thing exists.

I dont understand why you need this PE ISO at all? You can just install normal Win11 via the normal way, and if you want to manipulate another disk image with it, you can just rename that disk image to data2.img and place it in /storage2 and it will be a secondary disk inside Windows.

I never used WinPE, but I cannot imagine it contains a tool that you cannot run under normal Windows. So why make everything so complicated?

WSHAPER commented 4 months ago

@kroese Thanks, you're totally right! :)

WSHAPER commented 4 months ago

Solution

Troubleshooting Offline Disk Due to Signature Collision

Summary

diskpart
list disk
select disk X
uniqueid disk
uniqueid disk id=xxxxxxxx-...
online disk
exit
  1. Elevated Command Prompt (Run as Administrator):
    1. diskpart (start the diskpart utility)
    2. list disk
    3. Identify offline disk by its number (e.g., Disk 1).
    4. select disk X (replace X with the offline disk number)
    5. uniqueid disk (display the disk's current unique identifier)
    6. Assign a new unique ID to the selected disk: uniqueid disk id=xxxxxxxx (replace xxxxxxxx with a random 8-digit hexadecimal number, e.g. uniqueid disk id=1234abcd)
    7. online disk (bring the selected disk online)
    8. exit (exit the diskpart utility)
  2. exit Command Prompt and reopen diskmgmt.msc (Disk Management)
    1. Action → Rescan Disks