云服务器系统运行Windows Server 2008 R2,有100M的隐藏启动分区。

为了对服务器的重装系统等日常维护工作,需要运行一个PE系统,最好能装进这个100M的启动分区。

要求体积要小巧,首先想到的就是WXPE了,WXPE虽然古老,但体积非常小巧,核心文件压缩后只有20M左右。

于是在硬盘里找出我珍藏多年的WXPE.ISO。

上传到服务器,将100M隐藏分区分配到A盘,并上传GRLDR,用GRLDR来引导WXPE。

重启系统后,成功看到WXPE的界面,但是不能识别云硬盘,而且鼠标会失去反应,只能纯键盘操作。

KVM虚拟机,需要安装virtio驱动,才能识别硬盘。

所以到官网下载virtio-win驱动:https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/

需要将viostor.sys驱动集成到WXPE中。

 

下面就要简单分析一下WXPE.ISO的文件结构:

├── WINNT.XPE
├── WXPE
│   ├── NTDETECT.COM
│   └── SETUPLDR.BIN
└── WXPE.IS_

引导扇区会加载SETUPLDR.BIN,然后读取WINNT.XPE中的引导参数

WINNT.XPE指定了要加载到内存的镜像文件,文件内容如下 

[SetupData]
BootDevice="ramdisk(0)"
BootPath="\WXPE\SYSTEM32\"
OsLoadOptions="/minint /fastdetect /rdexportascd /rdpath=WXPE.IS_"

其中/rdpath参数指定了内存镜像的文件路径,就是根目录下的WXPE.IS_

在WXPE中会经常看到*.IS_,*.DL_,*.SY_,*.EX_这样的后缀名,其实是一个压缩文件.

解压后会把后缀名还原为*.ISO,*.DLL,*.SYS,*.EXE

我们把WXPE.IS_解压得到WXPE.ISO,再把它解压得到WXPE的系统目录。

在\WXPE目录下有一个TXTSETUP.SIF,这个文件是WXPE启动后非常重要的文件 。

[SourceDisksFiles] 这个章节是可以删除的。

[HardwareIdsDatabase] 这个章节描述了系统启动中要检测和安装的设备列表。

比如GenDisk="Disk",{4D36E967-E325-11CE-BFC1-08002BE10318}

表示设备ID为GenDisk的设备,驱动程序为"Disk",设备类型为{4D36E967-E325-11CE-BFC1-08002BE10318}

再往下能找到disk=disk.sys,表示Disk驱动对应的文件是disk.sys。

这个设备列表很长,其中有80%的内容都是可以删除的,减少这些内容,可以明显加快系统启动速度。

在设备列表里删除一些内容,就可以安全地删除对应的\WXPE\system32\drivers下面的sys文件。

比如下面的这些设备,我用了10多年的电脑也从来没见过。

si3132r5="Silicon Image 3132 SoftRaid 5 Controller"
si3132="Silicon Image 3132 SATALink Controller"
si3124r5="Silicon Image 3124 SoftRaid 5 Controller"
si3124r="Silicon Image 3124 SATARaid Controller"
si3124="Silicon Image 3124 SATALink Controller"
si3114r5="Silicon Image 3114 SoftRaid 5 Controller"
si3114r="Silicon Image 3114 SATARaid Controller"
si3114="Silicon Image 3114 SATALink Controller"
si3112r="Silicon Image 3112 SATARaid Controller"
si3112="Silicon Image 3112 SATALink Controller"

 

于是我决定干掉这些内容,可以加快系统启动速度,何乐不为?

但是要保留最基本的设备,如鼠标,键盘,USB,IDE控制器,AHCI控制器。

我把精简过后的TXTSETUP.SIF内容贴一份在这里,以便以后查阅:

[Version]
signature="$Windows NT$"
ClassGUID={00000000-0000-0000-0000-000000000000}
[WinntDirectories]
1="\"
2=system32
3=system32\config
4=system32\drivers
22=Fonts
124=WinSxS
125=WinSxS\Manifests
[SetupData]
OsLoadOptions="/fastdetect /minint"
ForceScsi=1
ForceDiskClass=1
ForceCDRom=1
loaderprompt="Starting Windows PE ..."
[HardwareIdsDatabase]
GenDisk="Disk",{4D36E967-E325-11CE-BFC1-08002BE10318}
GenOptical="Disk",{4D36E967-E325-11CE-BFC1-08002BE10318}
GenCdRom="CdRom",{4D36E965-E325-11CE-BFC1-08002BE10318}
GenFloppyDisk="flpydisk"
GenSFloppy="sfloppy"
STORAGE\Volume="Volume",{71A27CDD-812A-11D0-BEC7-08002BE2092F}
*PNP0C08="acpi",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0C09="acpiec",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0600="atapi",{4d36e96a-e325-11ce-bfc1-08002be10318}
*PNP0700=fdc
*PNP0A00="isapnp",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0A01="isapnp",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0A04="isapnp",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0F02="inport",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*PNP0F0D="inport",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*CPQA0D7="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0300="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0301="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0302="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0303="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0304="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0305="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0306="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0309="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP030a="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP030b="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0320="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
*PNP0F03="i8042prt",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*PNP0F0B="i8042prt",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*PNP0F0E="i8042prt",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*PNP0F12="i8042prt",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*PNP0F13="i8042prt",{4D36E96F-E325-11CE-BFC1-08002BE10318}
*PNP0A03="pci",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0E00="pcmcia",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0E01="pcmcia",{4D36E97D-E325-11CE-BFC1-08002BE10318}
*PNP0E02="pcmcia",{4D36E97D-E325-11CE-BFC1-08002BE10318}
PS2_KEYBOARD="i8042prt",{4D36E96B-E325-11CE-BFC1-08002BE10318}
PS2_MOUSE="i8042prt",{4D36E96F-E325-11CE-BFC1-08002BE10318}
HID_DEVICE_SYSTEM_KEYBOARD="kbdhid",{4D36E96B-E325-11CE-BFC1-08002BE10318}
HID_DEVICE_SYSTEM_MOUSE="mouhid",{4D36E96F-E325-11CE-BFC1-08002BE10318}
SERIAL_MOUSE="sermouse",{4D36E96F-E325-11CE-BFC1-08002BE10318}
USB\Class_03&SubClass_01&Prot_02="hidusb",{36fc9e60-c465-11cf-8056-444553540000}
USB\Class_03&SubClass_01="hidusb",{36fc9e60-c465-11cf-8056-444553540000}
USB\Class_03="hidusb",{36fc9e60-c465-11cf-8056-444553540000}
USB\COMPOSITE="usbccgp",{36fc9e60-c465-11cf-8056-444553540000}
USB\CLASS_09&SUBCLASS_01="usbhub",{36fc9e60-c465-11cf-8056-444553540000}
USB\CLASS_09="usbhub",{36fc9e60-c465-11cf-8056-444553540000}
USB\ROOT_HUB20="usbhub",{36fc9e60-c465-11cf-8056-444553540000}
USB\ROOT_HUB="usbhub",{36fc9e60-c465-11cf-8056-444553540000}
USB\Class_08&SubClass_02&Prot_50="usbstor"
USB\Class_08&SubClass_05&Prot_50="usbstor"
USB\Class_08&SubClass_06&Prot_50="usbstor"
PCI\VEN_8086&CC_0106="iastor",{4d36e96a-e325-11ce-bfc1-08002be10318}
PCI\CC_0601="isapnp",{4D36E97D-E325-11CE-BFC1-08002BE10318}
PCI\CC_0602="isapnp",{4D36E97D-E325-11CE-BFC1-08002BE10318}
PCI\CC_0605="pcmcia"
PCI\CC_0607="pcmcia"
PCI\CC_0604="pci",{4D36E97D-E325-11CE-BFC1-08002BE10318}
PCI\CC_0101="pciide",{4d36e96a-e325-11ce-bfc1-08002be10318}
PCI\CC_0C0320="usbehci",{36fc9e60-c465-11cf-8056-444553540000}
PCI\CC_0C0310="usbohci",{36fc9e60-c465-11cf-8056-444553540000}
PCI\CC_0C0300="usbuhci",{36fc9e60-c465-11cf-8056-444553540000}
[ntdetect]
486c_up=NTDETECT.COM,"\"
acpipic_up=NTDETECT.COM,"\"
e_isa_up=NTDETECT.COM,"\"
mps_up=NTDETECT.COM,"\"
mps_mp=NTDETECT.COM,"\"
standard=NTDETECT.COM,"\"
syspro_mp=NTDETECT.COM,"\"
acpiapic_mp=NTDETECT.COM,"\"
acpiapic_up=NTDETECT.COM,"\"
[hal]
486c_up=hal.dll,2,hal.dll
acpiapic_up=halaacpi.dll,2,hal.dll
acpiapic_mp=halaacpi.dll,2,hal.dll
acpipic_up=halacpi.dll,2,hal.dll
e_isa_up=hal.dll,2,hal.dll
mps_up=hal.dll,2,hal.dll
mps_mp=hal.dll,2,hal.dll
syspro_mp=hal.dll,2,hal.dll
[Hal.Load]
486c_up=hal.dll
acpiapic_up=halaacpi.dll
acpiapic_mp=halaacpi.dll
acpipic_up=halacpi.dll
e_isa_up=hal.dll
mps_up=hal.dll
mps_mp=hal.dll
syspro_mp=hal.dll
[Computer]
486c_up="Standard PC with C-Step i486",files.none
acpiapic_up="ACPI Uniprocessor PC",files.none
acpiapic_mp="ACPI Multiprocessor PC",files.none
acpipic_up="Advanced Configuration and Power Interface (ACPI) PC",files.none
e_isa_up="Standard PC",files.none
mps_mp="MPS Multiprocessor PC",files.none
mps_up="MPS Uniprocessor PC",files.none
syspro_mp="Compaq SystemPro Multiprocessor or 100% Compatible",files.none
[Map.Computer]
sgiborg_mp="*SGI-3"
sgiborg_mp="*SGI-4"
sgiborg_mp="*SGI-5"
sgiborg_mp="*SGI-6"
[BootBusExtenders.Load]
pci=pci.sys
acpi=acpi.sys
isapnp=isapnp.sys
acpiec=acpiec.sys
[BootBusExtenders]
pci="PCI Bus Driver",files.pci,pci
acpi="ACPI Plug & Play Bus Driver",files.acpi,acpi
isapnp="ISA Plug & Play Bus Driver",files.isapnp,isapnp
acpiec="ACPI Embedded Controller Driver",files.none,acpiec
[files.pci]
pci.sys,4
[files.acpi]
acpi.sys,4
acpiec.sys,4
oprghdlr.sys,4
[files.isapnp]
isapnp.sys,4
[files.none]
[BusExtenders.Load]
pcmcia=pcmcia.sys
pciide=pciide.sys
mountmgr=mountmgr.sys
ftdisk=ftdisk.sys
partmgr=partmgr.sys
fdc=fdc.sys
dmload=dmload.sys
dmio=dmio.sys
fltmgr=fltmgr.sys
[BusExtenders]
pcmcia="PCMCIA Support",files.pcmcia,pcmcia
pciide="PCI IDE Bus Driver",files.pciide,pciide
mountmgr="Mount Point Manager",files.none,mountmgr
ftdisk="Volume Manager",files.none,ftdisk
partmgr="Partition Manager",files.none,partmgr
fdc="Floppy Drive Support",files.none,fdc
dmload="Dynamic Volume Support (dmload)",files.none,dmload
dmio="Dynamic Volume Support (dmio)",files.none,dmio
fltmgr="Microsoft Filesystem Filter Manager",files.fltmgr,fltmgr
[files.pcmcia]
pcmcia.sys,4
[files.pciide]
pciide.sys,4
pciidex.sys,4
[files.fltmgr]
fltmgr.sys,4
[InputDevicesSupport.Load]
usbehci=usbehci.sys
usbohci=usbohci.sys
usbuhci=usbuhci.sys
usbhub=usbhub.sys
usbccgp=usbccgp.sys
hidusb=hidusb.sys
usbstor=usbstor.sys
[InputDevicesSupport]
usbehci="Enhanced Host Controller",files.usbehci,usbehci
usbohci="Open Host Controller",files.usbohci,usbohci
usbuhci="Universal Host Controller",files.usbuhci,usbuhci
usbhub="Generic USB Hub Driver",files.usbhub,usbhub
hidusb="Human Interface Parser",files.hidusb,hidusb
usbstor="USB Storage Class Driver",files.usbstor,usbstor
usbccgp="USB Generic Parent Driver",files.usbccgp,usbccgp
[files.usbehci]
hid.dll,2
hccoin.dll,2
hidclass.sys,4
hidparse.sys,4
usbd.sys,4
usbport.sys,4
usbehci.sys,4
[files.usbohci]
hid.dll,2
hidclass.sys,4
hidparse.sys,4
usbd.sys,4
usbport.sys,4
usbohci.sys,4
[files.usbuhci]
hid.dll,2
hidclass.sys,4
hidparse.sys,4
usbd.sys,4
usbport.sys,4
usbuhci.sys,4
[files.usbhub]
usbhub.sys,4
[files.hidusb]
hidusb.sys,4
[files.usbstor]
usbstor.sys,4
[files.usbccgp]
usbccgp.sys,4
[Display.Load]
vga=vga.sys
[Display]
forcevga="标准 VGA (640x480,16 颜色)",files.none
vga="自动检测",files.none
sglfb="Cobalt",files.sglfb
[Map.Display]
vga=VGA
vga="VGA"
[Keyboard.Load]
STANDARD=i8042prt.sys
kbdhid=kbdhid.sys
[Keyboard]
STANDARD="XT,AT或增强型键盘 (83-104 键)",files.i8042,i8042prt
kbdhid="USB Keyboard",files.kbdhid,kbdhid
USB="USB Keyboard",files.kbdhid,kbdhid
[files.i8042]
i8042prt.sys,4
[files.kbdhid]
kbdhid.sys,4
[Files.KeyboardLayout]
00000409=KBDUS.DLL,2
00000804=KBDUS.DLL,2
[KeyboardLayoutId]
00010C0C=0085
[Map.Keyboard]
STANDARD=OLI_83KEY
STANDARD=OLI_102KEY
STANDARD=OLI_86KEY
STANDARD=OLI_A101_102KEY
STANDARD=XT_83KEY
STANDARD=XT_84KEY
STANDARD=ATT_301
STANDARD=ATT_302
STANDARD=PCAT_ENHANCED
STANDARD=PCAT_86KEY
STANDARD=PCXT_84KEY
STANDARD=VECTRA_DIN
USB="USB KEYBOARD"
STANDARD="101-KEY"
["Keyboard Layout"]
00000804="美式键盘(中文)"
[SCSI.Load]
atapi=atapi.sys,4
iastor=iastor.sys,4
[SCSI]
atapi="IDE CD-ROM (ATAPI 1.2)/PCI IDE Controller"
iastor="Intel SATA AHCI/RAID Controller"
[Map.SCSI]
atapi=ATAPI
atapi="ISA"
atapi="IDE"
[DiskDrivers.Load]
dmboot=dmboot.sys
[DiskDrivers]
dmboot="Dynamic Volume Support (dmboot)"
[FloppyDrivers.Load]
flpydisk=flpydisk.sys
fat=fastfat.sys
[FloppyDrivers]
floppy="Standard Floppy Disk"
fat="FAT File System"
[ScsiClass.Load]
cdrom=cdrom.sys
disk=disk.sys
floppy=sfloppy.sys
ramdisk=ramdisk.sys
[ScsiClass]
cdrom="SCSI CD-ROM"
floppy="SCSI Floppy Disk"
disk="SCSI Disk"
ramdisk="RAM Disk Driver"
[FileSystems.Load]
ksecdd=ksecdd.sys
fat=fastfat.sys
ntfs=ntfs.sys
udf=udfs.sys
ext2=ext2.sys
[FileSystems]
fat="FAT File System"
ntfs="Windows NT File System (NTFS)"
ksecdd="Kernel Security Provider"
udf="Universal Disk Format (ISO/DVD)"
ext2="Ext2 File System Driver (read-write)"
[CdRomDrivers.Load]
cdfs=cdfs.sys
[CdRomDrivers]
cdfs="CD-ROM File System"
[MouseDrivers.Load]
mouclass=mouclass.sys
mouhid=mouhid.sys
[MouseDrivers]
mouclass="Mouse Class Driver"
mouhid="HID Mouse Filter Driver"
[Mouse]
msps2="Microsoft 鼠标端口鼠标 (包括 BallPoint)",files.i8042,i8042prt
lgps2="Logitech 鼠标端口鼠标",files.i8042,i8042prt
msinp="Microsoft 输入总线鼠标",files.inport,inport
msbpser="Microsoft BallPoint Serial Mouse",files.none,sermouse
lgser="Logitech 串行鼠标",files.none,sermouse
none="No Mouse or Other Pointing Device",files.none,""
mouhid="USB 鼠标",files.mouhid,mouhid
msser="Microsoft Serial Mouse",files.none,sermouse
ps2="Mouse Port Mouse",files.i8042,i8042prt
sermouse="Serial Mouse",files.none,sermouse
USB="USB Mouse",files.mouhid,mouhid
[files.inport]
inport.sys,4
[files.mouhid]
mouhid.sys,4
[Map.Mouse]
msps2="*MICROSOFT PS2 MOUSE"
lgps2="LOGITECH PS2 MOUSE"
msinp="MICROSOFT INPORT MOUSE"
msbpser="MICROSOFT BALLPOINT SERIAL MOUSE"
lgser="LOGITECH SERIAL MOUSE"
USB="USB PS2 MOUSE"
none="NO MOUSE"
msser="*MICROSOFT SERIAL MOUSE"
[files.vga]
vga.sys,4
framebuf.dll,2
vga.dll,2
vga256.dll,2
vga64k.dll,2
[files.fbwf]
fbwf.sys,4
[Map.PROM]
sgiborg_mp="ARC PROM"
[PROM.Version]
sgiborg_mp="1000"
[FileFlags]
kernel32.dll=1
ntdll.dll=1
win32k.sys=1
cfgmgr32.dll=8
setupapi.dll=8
umpnpmgr.dll=8
vga936.fon=16
hal.dll=12
kbdclass.sys=16
mouclass.sys=16
NOTEPAD.EXE=16
WINSPOOL.DRV=16
prcp.nls=16
[SpecialFiles]
Multiprocessor=ntoskrnl.exe,2
Uniprocessor=ntoskrnl.exe,2
MPKrnlPa=ntoskrnl.exe,2
UPKrnlPa=ntoskrnl.exe,2
mouseclass=mouclass.sys,4
keyboardclass=kbdclass.sys,4
[NetServicesToDisable]
Messenger
Netlogon
Alerter
Afd
Telnet
DHCP
NetDDE
NetDDEdsdm
ntcx
ntxem
ntxall
ntepc
DigiFEP5
Pcimac
CiFilter
LicenseService
RasAcd
RasArp
NdisTapi
w3svc
ftpsvc
msftpsvc
gophersvc
raspptpf
wuser32
[SetupKeysToMigrate]
"Enum"=0,2,1,1
"Services\ACPI\Parameters"=1,2,1,0
"Services\atapi\Parameters"=1,2,1,0
"Services\P3\Parameters"=1,2,1,0
"Services\Pci\Parameters"=1,2,1,0
"Services\isapnp\Parameters"=1,2,1,0
"Control\Arbiters"=0,2,1,0
"Control\Class"=0,2,0,0
"Control\COM Name Arbiter"=0,2,1,1
"Control\HAL"=1,2,1,0
"Control\IDConfigDB"=0,2,0,1
"Control\PnP\Pci"=0,2,1,0
"Control\PnP\PciIrqRouting"=0,2,0,0
"Control\Processor"=1,2,1,0
"Control\UsbFlags"=1,2,1,0
"Hardware Profiles"=0,2,0,1
[RootDevicesToDelete.clean]
ramdisk
[RootDevicesToDelete]
ACPI_HAL
ISA_HAL
PCI_HAL
MCA_HAL
ISAPNP
PCI
LEGACY_MGA_MIL
WDMAUD
LEGACY_BEEP
PARALLELCLASS
LEGACY_PARPORT
LEGACY_PARALLEL
*PNP0800
IntelATA
viadsk
pcmcia
MS_IRMODEMMINIPORT
[RootDeviceClassesToDelete]
{456D63F1-3F38-11d1-93C9-0040333C1C05}
{4D36E97B-E325-11CE-BFC1-08002BE10318}
{4D36E97E-E325-11CE-BFC1-08002BE10318}
{6D807884-7D21-11CF-801C-08002BE10318}
[RootDeviceClassesToDelete.nt4]
{4D36E96F-E325-11CE-BFC1-08002BE10318}
{4D36E96B-E325-11CE-BFC1-08002BE10318}
[BiosInfo]
InfName=biosinfo.inf
[nls]
AnsiCodepage=c_936.nls,936
OemCodepage=c_936.nls,936
UnicodeCasetable=l_intl.nls,0804
DefaultLayout=00000804
[FontListE]
"宋体 & 新宋体 (TrueType)"=SIMSUN.TTC
"Tahoma (TrueType)"=TAHOMA.TTF
[DiskDriverMap]
abiosdsk="%1!u! MB Micro Channel Disk"
atdisk="%1!u! MB IDE/ESDI Disk"
disk="%1!u! MB Disk %2!u! at Id %3!u! on bus %4!u! on %5"
[ACPIOptions]
ACPIEnable=2
ACPIBiosDate=01,01,1999

 

要添加viostor驱动,也是对应的在设备列表里面添加一行内容

在[HardwareIdsDatabase]章节添加:

PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4="viostor",{4d36e96a-e325-11ce-bfc1-08002be10318}

在[SCSI.Load]章节添加:

viostor=viostor.sys,4

在[SCSI]章节添加

viostor="Redhat SCSI Controller"

然后viostor.sys拷贝到\WXPE\system32\drivers目录。

最后重新把系统目录打包为ISO文件,再用XCAB压缩,改名为WXPE.IS_,替换原来的文件。

 

然而很不幸地是,经过一番折腾,PE系统启动蓝屏了,原因是viostor.sys导致的。

于是我又去掉这个驱动,改为进入系统后,进入MMC设备管理器,手动安装设备驱动。

结果发现这个驱动确实有问题,安装不了。

查了一下,可能是版本太高,不兼容XP的原因?

于是又去找了一个低版本的驱动,这回可以手动安装驱动了,但是却提示设备无法启动!!!

再加上鼠标经常无响应,最终决定放弃折腾WXPE了。

看来还是另找时间,做一个精简版本的Win7 PE才行,尽量把体积控制到100M以内!!!