Windows image create problem

root@lxd1:/path/to/origin# ll
total 4784268
drwxr-xr-x 2 root root 4096 Apr 25 09:57 ./
drwxr-xr-x 4 root root 4096 Apr 25 09:57 …/
-rwxrwxrwx 1 root root 4899078144 Apr 19 06:40 windows.iso*
root@lxd1:/path/to/origin# sudo distrobuilder repack-windows windows.iso windows_distrobuilder.iso
Error: Failed to detect Windows version. Please provide the version using the --windows-version flag
Usage:
distrobuilder repack-windows [–drivers=DRIVERS] [flags]

Flags:
–drivers Path to drivers ISO
-h, --help help for repack-windows
–windows-version Windows version to repack

Global Flags:
–cache-dir Cache directory
–cleanup Clean up cache directory (default true)
–debug Enable debug output
-o, --options Override options (list of key=value)
-t, --timeout Timeout in seconds
–version Print version number

What is the reason?

@monstermunchkin is this something you’re able to help with? Thanks

Error: Failed to detect Windows version. Please provide the version using the --windows-version flag

Distrobuilder is unable to detect the Windows version of the ISO. You need to call distrobuilder with the --windows-version flag.

distrobuilder repack-windows --windows-version=<version> <source-iso> <target-iso> where <version> is one of w10 (Windows 10), 2k12 (Windows Server 2012), 2k16 (Windows Server 2016), or 2k19 (Windows Server 2019).

root@lxd1:/# distrobuilder repack-windows --windows-version=w10 path/to/origin/windows.iso path/to/win10.iso
INFO Mounting Windows ISO
INFO Downloading drivers ISO
INFO Mounting driver ISO
INFO Modifying WIM file {“file”: “boot.wim”, “index”: 2}
Error: Failed to retrieve wim file information: Failed to run: wimlib-imagex info /var/cache/distrobuilder.534409939/overlay/sources/install.w im: [ERROR] Can’t open “/var/cache/distrobuilder.534409939/overlay/sources/install.wim” read-only: No such file or directory
ERROR: Exiting with error code 47:
Failed to open a file

I have download this ISO from microsoft site

I cannot reproduce this. Could you please run distrobuilder with the --debug flag?

distrobuilder repack-windows --debug --windows-version=w10 path/to/origin/windows.iso path/to/win10.iso

2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:434 Injecting driver {“driver”: “vioserial”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:458 Copying file {“src”: “/var/cache/distrobuilder.972911762/drivers/vioserial/w10/amd64/vioser.cat”, “dest”: “/var/cache/distrobuilder.972911762/wim/Windows/System32/DriverStore/FileRepository/vioser.inf_amd64_6af78671192591e1/vioser.cat”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:458 Copying file {“src”: “/var/cache/distrobuilder.972911762/drivers/vioserial/w10/amd64/vioser.inf”, “dest”: “/var/cache/distrobuilder.972911762/wim/Windows/System32/DriverStore/FileRepository/vioser.inf_amd64_6af78671192591e1/vioser.inf”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:469 Copying file {“src”: “/var/cache/distrobuilder.972911762/drivers/vioserial/w10/amd64/vioser.inf”, “dest”: “/var/cache/distrobuilder.972911762/wim/Windows/INF/oem6.inf”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:458 Copying file {“src”: “/var/cache/distrobuilder.972911762/drivers/vioserial/w10/amd64/vioser.sys”, “dest”: “/var/cache/distrobuilder.972911762/wim/Windows/System32/DriverStore/FileRepository/vioser.inf_amd64_6af78671192591e1/vioser.sys”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:504 Copying file {“src”: “/var/cache/distrobuilder.972911762/drivers/vioserial/w10/amd64/vioser.sys”, “dest”: “/var/cache/distrobuilder.972911762/wim/Windows/System32/drivers/vioser.sys”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:566 Updating Windows registry {“hivefile”: “DRIVERS”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:573 Updating Windows registry {“hivefile”: “SYSTEM”}
2021-04-27T03:01:06Z DEBUG distrobuilder/main_repack-windows.go:580 Updating Windows registry {“hivefile”: “SOFTWARE”}
Error: Failed to retrieve wim file information: Failed to run: wimlib-imagex info /var/cache/distrobuilder.972911762/overlay/sources/install.wim: [ERROR] Can’t open “/var/cache/distrobuilder.972911762/overlay/sources/install.wim” read-only: No such file or directory
ERROR: Exiting with error code 47:
Failed to open a file.

Thank you. What version of wimlib-imagex are you using? You can get this information from running wimlib-imagex --version.

root@lxd1:~# wimlib-imagex --version
wimlib-imagex 1.13.1 (using wimlib 1.13.1)
Copyright (C) 2012-2018 Eric Biggers
License GPLv3+; GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Report bugs to ebiggers3@gmail.com.

I cannot confirm this issue, but there have been problems with this in the past, if I remember correctly. I’ve proposed a possible fix (see https://github.com/lxc/distrobuilder/pull/426) which might solve the problem.

I know that some folks use the Windows .exe tool to generate the ISO and those ISOs have usually not worked so well. Instead downloading the .iso directly from the website works a lot better.

Could you please try again with the latest edge snap of distrobuilder? Just run snap refresh distrobuilder --channel=latest/edge to update distrobuilder.

I found this usefull.
"
The Windows image repacker depends on: genisoimage, hivexregedit (libwin-hivex-perl), rsync and wimlib-imagex (wimtools). Missing dependencies are detected and reported by distrobuilder on startup.
"
Source: LXD Youtube Chanel.

Install:
sudo apt install libwin-hivex-perl
sudo apt install wimtools

And then:
sudo distrobuilder repack-windows --windows-version=2k19
from the download folder. cd Downloads/

It worked for me. Have repacked MS server 2019. :slight_smile: