找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 17798|回复: 33

使用openwrt的tftp(pxe)及smb服务安装win7/10

  [复制链接]
发表于 2017-2-16 12:22 | 显示全部楼层 |阅读模式
本帖最后由 99010 于 2018-4-28 01:17 编辑

前言:上次写了个使用tftp的pxe启动服务维护电脑的教程,有朋友问能不能用来安装全新系统,答案是可以的

教程以openwrt官方15.05.1固件及win7x86的iso安装镜像作为示例。另外,请准备好相应的U盘,建议格式为ext3/4

如何挂载U盘、安装配置smb服务,这里不做详解了,论坛里很多教程。
本例U盘挂载目录为/mnt/sda1,smb服务目录为/mnt/sda1/win7x86

1.下载附件解压后上传到/mnt/sda1

2.在网盘下载winpe.iso、maxdos.img并上传到/mnt/sda1/pxeboot/bios/os目录里面

3.在luci界面点网络--DHCP/DNS--TFTP设置,
勾上启用TFTP服务器
TFTP服务器根目录填上/mnt/sda1/pxeboot/bios
网络启动镜像填上pxelinux.0
保存&应用

4.在luci界面点服务--网络共享
共享名openwrt
目录/mnt/sda1/win7x86
勾上允许匿名用户
新文件权限7777
新目录权限7777
保存&应用

5.把win7的安装镜像iso解压后,把所有文件及文件夹上传到/mnt/sda1/win7x86

6.启动电脑并设置pxe网络启动,启动到菜单时进入winpe,winpe启动完成后在界面点加载网卡驱动并应用及确定,运行命令提示符输入

  1. net use z: \\192.168.1.1\openwrt
  2. z:
  3. setup.exe
复制代码


------------------------------------分割线---------------------------------------------------

以下教程合适喜欢折腾的研究

安装工具

  1. opkg update
  2. opkg install wget tar
复制代码
准备 PXE 引导文件,下载syslinux软件包
  1. cd /tmp
  2. wget --no-check-certificate https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz
  3. tar -xf syslinux-6.03.tar.xz
复制代码
进入该目录,复制一堆文件到U盘的PXE启动目录中
  1. cd syslinux-6.03

  2. # 这里是BIOS启动文件
  3. mkdir -p /mnt/sda1/pxeboot /mnt/sda1/pxeboot/bios
  4. cp ./bios/core/pxelinux.0 /mnt/sda1/pxeboot/bios
  5. cp ./bios/com32/elflink/ldlinux/ldlinux.c32 /mnt/sda1/pxeboot/bios
  6. cp ./bios/com32/lib/libcom32.c32 /mnt/sda1/pxeboot/bios
  7. cp ./bios/com32/libutil/libutil.c32 /mnt/sda1/pxeboot/bios
  8. cp ./bios/com32/menu/vesamenu.c32 /mnt/sda1/pxeboot/bios
  9. cp ./bios/memdisk/memdisk /mnt/sda1/pxeboot/bios

  10. # 然后是UEFI启动文件(用的是64位 UEFI启动文件),可忽略跳过。
  11. mkdir -p /mnt/sda1/pxeboot /mnt/sda1/pxeboot/uefi
  12. cp efi64/efi/syslinux.efi /mnt/sda1/pxeboot/uefi
  13. cp efi64/com32/elflink/ldlinux/ldlinux.e64 /mnt/sda1/pxeboot/uefi
  14. cp efi64/com32/menu/vesamenu.c32 /mnt/sda1/pxeboot/uefi
  15. cp efi64/com32/lib/libcom32.c32 /mnt/sda1/pxeboot/uefi
  16. cp efi64/com32/libutil/libutil.c32 /mnt/sda1/pxeboot/uefi
复制代码


创建syslinux配置文件
  1. mkdir -p /mnt/sda1/pxeboot/pxelinux.cfg
  2. vi /mnt/sda1/pxeboot/pxelinux.cfg/default

  3. #写入以下内容
  4. DEFAULT vesamenu.c32
  5. MENU TITLE OpenWRT PXE-Boot Menu
  6. PROMPT 0
  7. TIMEOUT 100


  8. label Windows7 netinst x32
  9.         MENU LABEL Windows7 netinst x32
  10.         KERNEL memdisk
  11.         INITRD os/winpe_x86.iso
  12.         APPEND iso raw

  13. label Windows7 netinst x64
  14.         MENU LABEL Windows7 netinst x64
  15.         KERNEL memdisk
  16.         INITRD os/winpe_amd64.iso
  17.         APPEND iso raw

  18. LABEL dos
  19.         MENU LABEL maxdos
  20.         KERNEL memdisk
  21.         APPEND initrd=os/maxdos.img
复制代码

在BIOS和UEFI目录下建立相应目录的软链接
  1. mkdir -p /mnt/sda1/pxeboot/os
  2. cd /mnt/sda1/pxeboot/bios/
  3. ln -s ../pxelinux.cfg/
  4. ln -s ../os/
  5. #以下为uefi可忽略跳过
  6. cd /mnt/sda1/pxeboot/uefi
  7. ln -s ../pxelinux.cfg/
  8. ln -s ../os/
复制代码
配置 DHCP 以及 TFTP
编辑 /etc/dnsmasq.conf 文件:
  1. #在最后添加以下几行,这里会根据client类型自动选择镜像
  2. enable-tftp
  3. tftp-root=/mnt/sda1/pxeboot
  4. dhcp-boot=/mnt/sda1/pxeboot/bios/pxelinux.0
复制代码
然后重启dnsmasq服务:
  1. /etc/init.d/dnsmasq restart
复制代码

把win7的安装镜像iso上传到挂载的U盘根目录(也可以解压后上传到/mnt/sda1/win7x86)
  1. cd /mnt/sda1
  2. mkdir -p /mnt/sda1/win7x86
  3. mkdir -p /mnt/sda1/cdrom
  4. mount -o loop win7.iso  /mnt/sda1/cdrom
  5. cp -r /mnt/sda1/cdrom/* /mnt/sda1/win7x86
复制代码
把winpe_x86.iso以及winpe_amd64.iso上传到/mnt/sda1/pxeboot/os

#这2个pe镜像是微软官方的,自带了大部分网卡驱动,如果你的网卡不能驱动请换个第三方winpe。

到这里已经架设完成,需要安装系统的电脑经过网络启动,根据菜单选项进入pe后,有一个cmd命令框,在里面分别输入

  1. net use z: \\192.168.1.1\openwrt
  2. z:
  3. setup.exe
复制代码
可以看到已经可以开始安装干净的系统了。
注:如果smb服务用了身份验证,请使用以下命令指定用户名。

  1. net use \\192.168.1.1\openwrt  /user:samba_password
复制代码


------------------------------------分割线---------------------------------------------------
附录:如何获取纯净的winpe_x86.iso以及winpe_amd64.iso

步骤1:下载并安装Windows自动安装工具包

1. 登录到Windows 7操作系统计算机,转到Microsoft下载中心,并使用以下链接下载Windows自动安装工具包ISO映像文件。

https://www.microsoft.com/zh-CN/download/details.aspx?id=5753

2. AIK ISO映像完成下载后,使用Windows安装软件(Daemon Tools Lite免费版将执行此操作)安装映像,然后安装Windows自动安装工具包软件。

步骤2:在Windows 7上创建WinPE ISO映像

3.在您的系统上安装Windows AIK软件后,转到Windows开始 - >所有程序 - > Microsoft Windows AIK - >右键单击部署工具命令提示符,选择以管理员身份运行,并在您的屏幕上打开一个新的Windows Shell控制台。

4.现在是通过在部署工具命令提示符上发出以下命令来构建Windows 7预安装环境(WinPE)x86引导映像的时候了。
  1. copype x86 C:\winPE_x86
  2. copy "C:\Program Files\Windows AIK\Tools\PETools\x86\winpe.wim" C:\winpe_x86\ISO\Sources\Boot.wim
  3. copy "C:\Program Files\Windows AIK\Tools\x86\Imagex.exe" C:\winpe_x86\ISO\
  4. oscdimg -n -bC:\winpe_x86\etfsboot.com C:\winpe_x86\ISO C:\winpe_x86\winpe_x86.iso
复制代码


5.虽然对于本教程只需要WinPE x86 Boot ISO映像,下面你可以找到命令来构建用于Windows 7 64位和Windows 8架构的PE映像。

要为Windows 7 64位构建WinPE启动映像,请使用以下命令:
  1. copype amd64 C:\winPE_amd64
  2. copy "C:\Program Files\Windows AIK\Tools\PETools\amd64\winpe.wim" C:\winpe_amd64\ISO\Sources\Boot.wim
  3. copy "C:\Program Files\Windows AIK\Tools\amd64\Imagex.exe" C:\winpe_amd64\ISO\
  4. oscdimg -n -bC:\winpe_amd64\etfsboot.com C:\winpe_amd64\ISO C:\winpe_amd64\winpe_amd64.iso
复制代码


要构建Windows 8 32位WinPE可启动映像,请运行以下命令:
  1. copype x86 C:\Win8PE_x86
  2. MakeWinPEMedia /ISO C:\Win8PE_x86 C:\Win8PE_x86\WinPE_x86.iso
复制代码


要构建Windows 8 64位WinPE可启动映像,请运行以下命令:
  1. copype amd64 C:\Win8PE_amd64
  2. MakeWinPEMedia /ISO C:\Win8PE_amd64 C:\Win8PE_amd64\Win8PE_amd64.iso
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 2恩山币 +2 收起 理由
9违D温柔 + 1 感谢你的分享,无论怎样,你都是最无私的人.
kp_wu + 1 我来恩山就是为了看你!

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
头像被屏蔽
发表于 2017-2-23 13:25 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-4-15 22:49 | 显示全部楼层
不错  收藏了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-5-16 16:08 | 显示全部楼层
感谢分享。。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-9-10 22:55 来自手机 | 显示全部楼层
不错很厉害,记录了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-9-17 13:35 | 显示全部楼层
#在这里快速回复#        强大的恩山!(以下重复1万次)
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-10-4 15:31 | 显示全部楼层
太牛逼  水水水水
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-11-5 07:30 | 显示全部楼层
这个配置能从UEFI 用 网络 能启动吗?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2017-11-5 07:39 来自手机 | 显示全部楼层
6666666,收藏下次研究
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2018-4-16 01:36 | 显示全部楼层
顶一个。这个实用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2018-10-21 14:42 | 显示全部楼层
感谢分享,定一个。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2018-10-23 15:57 | 显示全部楼层
求分享winpe_amd64.iso这个PE
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-1-4 10:26 | 显示全部楼层
不错.得支持!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-9-17 00:59 | 显示全部楼层
不错.得支持!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-11-26 15:58 来自手机 | 显示全部楼层
谢谢分享了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-20 01:53

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表