根本原因和解决方案Alpine Linux 使用 musl libc 而非标准的 glibc，而大多数预编译的 Linux 二进制文件都是针对 glibc 编译的。这就是问题所在。解决方案：安装 glibc 兼容层（推荐）# 安装 gcompat（Alpine 的 glibc 兼容层） apk add --no-cache gcompat
给boot.wim打补丁创建临时目录New-Item -Path "C:\temp_pe" -ItemType Directory -Force挂载 boot.wim# 查看 boot.wim 有几个映像 Get-WindowsImage -ImagePath "D:\win2025\sources\boot.wim"# 一般有 2 个，Index 1 是普通 PE，Index 2 是setup # 挂载 Index 2 Mount-WindowsImage -ImagePath "D:\win2025\sources\boot.wim" -Index 1 -Path "C:\mount_pe"创建自动启动命令行的脚本# 创建 Winpeshl.ini，它会替代默认的 setup.exe 启动 @" [LaunchApps] %SYSTEMROOT%\System32\cmd.exe "@ | Out-File -FilePath "C:\mount_pe\Windows\System32\winpeshl.ini" -Encoding ascii打驱动# 打磁盘驱动 dism /Image:"C:\mount_pe" /Add-Driver /Driver:"D:\virtio\viostor\2k25\amd64\viostor.inf"保存修改后的 boot.wim# 卸载并保存 Dismount-WindowsImage -Path "C:\mount_pe" -Save将index2保存为单独的wimdism /Export-Image /SourceImageFile:"D:\win2025\sources\boot.wim" /SourceIndex:2 /DestinationImageFile:"D:\win2025\sources\boot_setup.wim" bcdedit 添加启动菜单# 1. 设置 ramdisk 选项 $null = cmd /c bcdedit /create "{ramdiskoptions}" /d "Ramdisk 选项" 2>&1 cmd /c bcdedit /set "{ramdiskoptions}" ramdisksdidevice partition=D: cmd /c bcdedit /set "{ramdiskoptions}" ramdisksdipath \win2025\boot\boot.sdi # 2. 创建新启动项并捕获 GUID $output = cmd /c bcdedit /copy "{current}" /d "Windows PE 恢复环境" $guid = ($output | Select-String '{[^}]+}').Matches.Value Write-Host "新启动项 GUID: $guid" -ForegroundColor Green # 3. 配置启动项 cmd /c bcdedit /set $guid device "ramdisk=[D:]\win2025\sources\boot_setup.wim,{ramdiskoptions}" cmd /c bcdedit /set $guid osdevice "ramdisk=[D:]\win2025\sources\boot_setup.wim,{ramdiskoptions}" cmd /c bcdedit /set $guid winpe yes cmd /c bcdedit /set $guid detecthal yes cmd /c bcdedit /set $guid systemroot \Windows # 4. 显示启动菜单 cmd /c bcdedit /set "{bootmgr}" displaybootmenu yes cmd /c bcdedit /set "{bootmgr}" timeout 5 Write-Host "`n设置完成！重启后选择 'Windows PE 恢复环境' 即可进入。" -ForegroundColor Yellow
Alpine 的 swap 服务位于 /etc/init.d/swap，需将其加入默认运行级别：rc-update add swap default
DISM /online /Set-Edition:ServerDatacenter /ProductKey:D764K-2NDRG-47T6Q-P8T8W-YP6DF /AcceptEula
﻿set timeout=1 menuentry "Linux lts" { linux (hd0,msdos2)/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage quiet initrd (hd0,msdos2)/boot/initramfs-lts } rm /etc/initramfs-tools/hooks/resize2fs rm /etc/initramfs-tools/hooks/resize2fs cat > /etc/initramfs-tools/hooks/resize2fs <<"EOF" #!/bin/sh PREREQ="" prereqs() { echo "$PREREQ" } case "$1" in prereqs) prereqs exit 0 ;; esac . /usr/share/initramfs-tools/hook-functions copy_exec /sbin/findfs /sbin copy_exec /sbin/e2fsck /sbin copy_exec /sbin/resize2fs /sbin copy_exec /sbin/fdisk /sbin copy_exec /sbin/sfdisk /sbin copy_exec /sbin/parted /sbin copy_exec /bin/bash /sbin EOF chmod +x /etc/initramfs-tools/hooks/resize2fs cat > /etc/initramfs-tools/scripts/init-premount/resize <<"EOF" #!/bin/sh PREREQ="" prereqs() { echo "$PREREQ" } case "$1" in prereqs) prereqs exit 0 ;; esac /sbin/bash EOF chmod +x /etc/initramfs-tools/scripts/init-premount/resize update-initramfs -v -u 顺序 e2fsck -f /dev/vda1 resize2fs -f /dev/vda1 35G fdisk /dev/vda a 1 resize2fs /dev/vda1 exit http://mirrors.ustc.edu.cn/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso wget http://mirrors.ustc.edu.cn/alpine/v3.16/releases/x86_64/alpine-standard-3.16.2-x86_64.iso mkfs.ext4 /dev/vda2 mount -t ext4 /dev/vda2 /mnt mkdir /cd mount -o loop alpine-standard-3.16.2-x86_64.iso /cd cd /cd cp -r * /mnt mv /root/alpine-standard-3.16.2-x86_64.iso /mnt 84857599 13106700 9175040 insmod ext2 set root=(hd0,msdos1) set isofile='/alpine.iso' loopback loop ${isofile} linux (loop)/boot/vmlinuz-virt modules=loop,squashfs,sd-mod,usb-storage quiet initrd (loop)/boot/initramfs-virt linux (hd0,msdos1)/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage quiet initrd (hd0,msdos1)/boot/initramfs-lts boot #禁用ipv6 vi /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 sudo sysctl -p #格式化 apk add e2fsprogs mkfs.ext4 -O ^has_journal /dev/vda1 mount -t ext4 /dev/vda1 /mnti #如果启动时认不出，就用ext2格式 cd /media/vda2 mount -o loop -t iso9660 alpine-standard-3.16.2-x86_64.iso /media/cdrom setup-alpine apk add syslinux dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/vda extlinux --install /mnt setup-disk /mnt cp /boot/* / apk add e2fsprogs-extra fdisk resize2fs /dev/vda1 cp /usr/share/syslinux/memdisk /boot/memdisk --------------------------------------------------------------- insmod part_msdos insmod part_gpt insmod ext2 set root=(hd0,msdos1) linux16 /boot/memdisk iso raw initrd16 /netboot.xyz.iso --------------------------------------------------------------- linux16 /boot/memdisk iso raw initrd16 /netboot.xyz.iso boot imgfree kernel http://mirrors.ustc.edu.cn/alpine/v3.16/releases/x86_64/netboot/vmlinuz-lts alpine_repo=http://mirrors.ustc.edu.cn/alpine/v3.16/main/ modules=loop,squashfs modloop=http://mirrors.ustc.edu.cn/alpine/v3.16/releases/x86_64/netboot/modloop-lts quiet nomodeset initrd http://mirrors.ustc.edu.cn/alpine/v3.16/releases/x86_64/netboot/initramfs-lts md5sum vmlinuz-lts initramfs-lts boot imgfree kernel http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/netboot/vmlinuz-virt alpine_repo=http://dl-cdn.alpinelinux.org/alpine/v3.17/main modules=loop,squashfs modloop=http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/netboot/modloop-virt quiet nomodeset initrd http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/netboot/initramfs-virt md5sum vmlinuz-lts initramfs-lts boot fdisk setup-alpine setup-disk -m sys -s 0 ----------------------------------------------------------------- apk add syslinux If you're using GPT partitions, install the GPT MBR onto the drive you want to install the bootloader on (in this case /dev/sda): dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=/dev/sda Or if you're using DOS partitions, install the DOS MBR instead: dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/vda extlinux --install /mnt mkdir -p /mnt/syslinux cp /usr/share/syslinux/efi64/* /mnt/syslinux/ cp /mnt/boot/syslinux/syslinux.cfg /mnt/syslinux/syslinux.cfg cp /mnt/boot/vmlinuz* /mnt/ cp /mnt/boot/initramfs* /mnt/ blkid root=UUID=3c7ba8c1-c862-4826-8b0e-088131e17a84 apk add e2fsprogs-extra alpine win10 /boot/extlinux.conf 加上 LABEL win10 LINUX memdisk INITRD win10.iso APPEND iso raw iso 放/boot,文件系统用ext2
1.ipxe启动 netbootset net0/ip <ip> set net0/netmask <netmask> set net0/gateway <gateway> set dns <nameserver> ifopen net0 chain --autofree http://boot.netboot.xyz 2.禁用ipv6echo 1 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6 3.alpine安装setup-alpine setup-disk -s 0 /dev/vda 4.分区调整apk add e2fsprogs-extra apk add ntfs-3g-progs apk add cfdisk 一定要先e2fsck -f /dev/vda2 resize2fs -f /dev/vda2 35G再用cfdisk5.换grub启动apk del syslinux apk add grub grub-bios grub-install /dev/vda blkid cat <<EOF >> /etc/grub.d/40_custom menuentry "Alpine Linux" { set root=(hd0,1) linux /boot/vmlinuz root=UUID=caff7641-b9d3-435a-8282-fc3b15ae8b3a modules=sd-mod,usb-storage4,ext3 quiet initrd /boot/initramfs-vanilla } EOFUUID为blkid显示的vda2grub-mkconfig -o /boot/grub/grub.cfg 6.把memdisk复制到/boot,启动grub时按clinux16 (hd0,msdos1)/boot/memdisk iso rawinitrd16 (hd0,msdos2)/win10.isoboot
sudo mkdir -p /etc/systemd/system/docker.service.d sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<-'EOF' [Service] Environment="HTTP_PROXY=http://proxy.example.com:8080" Environment="HTTPS_PROXY=http://proxy.example.com:8080" Environment="NO_PROXY=localhost,127.0.0.1,.example.com" EOF
bcdedit /create {ramdiskoptions} /d "win 10 pe" bcdedit /set {radiopticons} ramdisksdidevice partition=D: bcdedit /set {ramdiskoptions} ramdisksdipath \win10\Boot\boot.sdi Bcdedit /create /d "Boot from Wim" /application osloader 运行完上面会生成guid,替换下面的guidbcdedit /set {acd191c6-69d3-11ed-80cd-c9ce13ba6396} device ramdisk=[D:]\win10\Sources\boot.wim,{ramdiskoptions} bcdedit /set {acd191c6-69d3-11ed-80cd-c9ce13ba6396} osdevice ramdisk=[D:]\win10\Sources\boot.wim,{ramdiskoptions} bcdedit /set {acd191c6-69d3-11ed-80cd-c9ce13ba6396} path \windows\system32\boot\winload.exe bcdedit /set {acd191c6-69d3-11ed-80cd-c9ce13ba6396} systemroot \windows bcdedit /set {acd191c6-69d3-11ed-80cd-c9ce13ba6396} winpe yes bcdedit /set {acd191c6-69d3-11ed-80cd-c9ce13ba6396} detecthal yes bcdedit /displayorder {acd191c6-69d3-11ed-80cd-c9ce13ba6396} /addlast
https://learn.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings?tabs=config1.更新time serverw32tm /config /manualpeerlist:"3.openwrt.pool.ntp.org time.ustc.edu.cn ntp1.aliyun.com" /syncfromflags:manual /update w32tm /config /update /manualpeerlist:"0.pool.ntp.org,0x8 1.pool.ntp.org,0x8 2.pool.ntp.org,0x8 3.pool.ntp.org,0x8" /syncfromflags:manual 2.更新一次时间w32tm /resync
#如虚拟机名称为win10 Set-VM -Name "win10" -AutomaticStopAction TurnOff Set-VM -GuestControlledCacheTypes $true -VMName "win10" # 设置MMIO，总的io映射内存，我们直接设置为32GB(通用大小)，出现其他问题再扩大即可 Set-VM -LowMemoryMappedIoSpace 1Gb -VMName "win10" Set-VM -HighMemoryMappedIoSpace 32Gb -VMName "win10" # 添加虚拟化， Add-VMGpuPartitionAdapter -VMName "win10" # 指定显卡添加，这个显卡ID通过Get-VMHostPartitionableGpu命令获取到的“Name”字段值 # 注意，低版本的window10是无法使用这个命令指定的 # Add-VMGpuPartitionAdapter -VMName "win10" -InstancePath "显卡ID" # 例如我的显卡ID是：\\?\PCI#VEN_10DE&DEV_1F91&SUBSYS_1AB11043&REV_A1#4&1885b93c&0&0008#{064092b3-625e-43bf-9eb5-dc845897dd59}\GPUPARAV # 添加后，设置自动配置显卡 Set-VMGpuPartitionAdapter -VMName "win10" # 删除虚拟显卡的分配，配置错误可重新来 Remove-VMGpuPartitionAdapter -VMName "win10" 我们先复制物理机系统的C:\Windows\System32\nvapi64.dll放到虚拟机的：C:\Windows\System32\nvapi64.dll再复制物理机中的C:\Windows\System32\DriverStore\FileRepository目录中以nv开头的文件夹到虚拟机中的C:\Windows\System32\HostDriverStore\FileRepository目录下，其中HostDriverStore\FileRepository目录需要自己创建：重启虚拟机即可$vm = "你的虚拟机名称" Remove-VMGpuPartitionAdapter -VMName $vm Add-VMGpuPartitionAdapter -VMName $vm Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionVRAM 1 Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionVRAM 11 Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionVRAM 10 Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionEncode 1 Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionEncode 11 Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionEncode 10 Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionDecode 1 Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionDecode 11 Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionDecode 10 Set-VMGpuPartitionAdapter -VMName $vm -MinPartitionCompute 1 Set-VMGpuPartitionAdapter -VMName $vm -MaxPartitionCompute 11 Set-VMGpuPartitionAdapter -VMName $vm -OptimalPartitionCompute 10 Set-VM -GuestControlledCacheTypes $true -VMName $vm Set-VM -LowMemoryMappedIoSpace 1GB -VMName $vm Set-VM -HighMemoryMappedIoSpace 32GB -VMName $vm Start-VM -Name $vm