Skip to content

Instantly share code, notes, and snippets.

@rikka0w0
Last active June 16, 2024 13:22
Show Gist options
  • Save rikka0w0/f60cc75632e8985cb2957440a7a4d762 to your computer and use it in GitHub Desktop.
Save rikka0w0/f60cc75632e8985cb2957440a7a4d762 to your computer and use it in GitHub Desktop.
Win7 RamOS PXE

Prerequests:

  1. DHCP server serving PXE information
  2. TFTP server
  3. IPXE(undionly.kpxe and/or ipxe.efi)
  4. memdisk (From Syslinx, can be found on Ubuntu live /usr/lib/syslinux/memdisk) on TFTP root
  5. A Win7 installation ISO, I'm using 23572_ENTERPRISE-7-SP1_X64_ZH-CN_PIP.iso (Google or Baidu it!), it is a special minimal Chinese x64 version created by a Russian guy.
  6. Download this tool: VHD_W7_Compact and extract to VHD_W7C_88.

1. Install Win7 x64 on a virtual machine (vmware)

  1. Install Win7
  2. Enable Administrator and delete the user created during installation
  3. Reboot and delete the unused user folder in C:\Users
  4. Disable UAC
  5. Adjust preferences
  6. Install necessary software (As few as possible, as they also use memory for storage!)
  7. Install FiraDisk driver, goto VHD_W7C_88\makebt\firadisk-driver-0.0.1.30, right click firadisk.inf and click Install.

2. Make a mini version of Windows 7 image

  1. Reboot VM into a WinPE environment.
  2. Run VHD_W7C_x64.exe
  3. Choose User path: C:\User\Administrator. In some WinPE, the open file dialogs does not work! Switch to another WinPE if you encounter this problem!
  4. In settings, select Portable version, Defrag VHD, NTFS compression and Make boot menu.
  5. Boot device is the location of bootmgr and BCD in your VM, normally C:.
  6. System drive is the place to put the VHD that is going to be generated, in this case, C:.
  7. Set VHD size to 3.9 or 3.0. Normally the image will be much less than 3.0G, in my case, it only takes 1.5G after everything is done, however, without sufficient VHD space, image creation may fail!
  8. Hit "Go" and start Mini Win7 VHD creation.
  9. When it prompts done, for Chinese Kapanese Korean users, you have to copy your fonts from "Windows\Fonts" to the VHD, otherwise wide-char won't display.

3. Reboot and test the RamOS

Reboot and choose Grub4Dos then RAMDISK. You should be able to boot into the RamOS. Check if there is a 3.9G partition after startup.

4. Shrink the VHD

  1. In RamOS or WinPE, mount the RamOS VHD in "Disk Management", shrink the windows partition to 2000MB and detach the VHD.
  2. Use VHD Resizer to resize the VHD file to something like 2020MB (less than 2048MB).
  3. Upload the 2000MB VHD file to a http server Memdisk or IPXE seem to have an limitation on the maximum size of the image loaded into the memory, 2GB seems to be fine, but 3.9GB VHD no longer works!

5. Add IPXE entry

On the TFTP server, append the following lines to the ipxe menu file:

:windows7_ramos
kernel memdisk raw harddisk
initrd ${http-root}/W764CNP1.vhd
boot
goto start

Make sure memdisk is in the TFTP root

Add driver (offline VHD)

Run as admin:

mkdir mnt
Dism /Mount-Image /ImageFile:W764CNP1.vhd /Index:1 /MountDir:mnt
DISM /Image:mnt /Add-Driver /Driver:e1e6232e.inf /ForceUnsigned
Dism /Unmount-Image /MountDir:mnt /Commit

Make sure files in [SourceDisksFiles] are in the same folder as W764CNP1.vhd and the inf files.

WIM mode IPXE menu entry

:windows7_ramos_bios
kernel wimboot
initrd ${http-root}/win7_ramos/bootmgr
initrd ${http-root}/win7_ramos/boot/bcd
initrd ${http-root}/win7_ramos/boot/boot.sdi
initrd ${http-root}/win7_ramos/boot.wim
boot
goto start

:windows7_ramos_uefi
kernel wimboot
initrd ${http-root}/win7_ramos/bootmgr.efi
# Disable integrity check
initrd ${http-root}/win7_ramos/efi/microsoft/boot/bcd
initrd ${http-root}/win7_ramos/boot/boot.sdi
initrd ${http-root}/win7_ramos/boot.wim
boot

References:

  1. Grub2 boot VHD
  2. VHD_W7_Compact - Make Mini 7 -
  3. Grub4DOS IPXE

This seems to be a better solution, it only needs one WIM file for booting. Wim has much better compression rate than NTFS.

http://bbs.wuyou.net/forum.php?mod=viewthread&tid=408544

Can someone download the attachments in the above link and share it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment