全球主机交流论坛

标题: 通过debian-installer远程dd安装Windows [打印本页]

作者: LiuJia    时间: 2019-3-25 13:34
标题: 通过debian-installer远程dd安装Windows
系统:debian 9 64位。

过程:

1.apt install kexec-tools # 安装 kexec 热内核切换工具


2.wget http://cdn-fastly.deb.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux # 下载 debian9 的网络安装文件

3.wget http://cdn-fastly.deb.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz # 下载 debian9 的网络安装文件

4.wget https://github.com/fincham/kexec-remote-debian-install/raw/master/build.py # 下载脚本,制作自动安装配置文件

5.vi build.py # 增加ntfs模块,ntfs-3g-udeb ntfs-modules-4.9.0-8-amd64-di fuse-modules-4.9.0-8-amd64-di


6.chmod +x build.py # 增加执行权限

7../build.py initrd.gz enp0s20f0 144.172.126.32 255.255.255.0 144.172.126.1 8.8.8.8 # 假设网卡名是enp0s20f0,设置静态网络信息


8.kexec --command-line="auto=true priority=critical mirror/http/hostname=deb.debian.org" --initrd=initrd.gz linux # 热切换到网络安装的内核上


9.ssh installer@ip # 等一小段时间后,可以通过ssh登录,继续安装

10.选择菜单 Start installer (expert mode)


11.选择菜单, Detect disks # 识别硬盘


12.选择菜单,Execute a shell # 切换到命令控制台


13.Continue # 进到ash


14.fdisk -l /dev/sda # 查看当前的分区信息,有多个Linux分区


15.wget -O- http://url/w2k19-virtio-nic-unattend.vhd.gz | gunzip | dd of=/dev/sda # dd安装


16.fdisk -l /dev/sda # 再次查看分区信息,dd后是仅有一个Windows分区


17.mount.ntfs /dev/sda1 /mnt # 会提示错误,Invalid argument,可能是因为内核没有更新分区表


18.新开一个ssh会话,选择菜单 Partition disks ,选择 Guided - use the largest continuous free space


19.选择菜单 All files in one pration (recommended for new users)


20.选择菜单 Finish partitioning and write changes to disk # 确认第一个Windows分区信息无误的话,更新分区信息


21.再次确认分区更改


22.mount.ntfs /dev/sda1 /mnt # 再次尝试挂载NTFS分区,成功

23.nano /mnt/Windows/panther/Unattend.xml # 编辑Windows无人值守安装文件,更改里边的IP设置


24.umount /mnt # 卸载/mnt

25.reboot

26.Windows完成安装


27.debian-installer还有日志文件,如遇到错误,可通过web查看


参考:

作者: 颠峰布衣飘    时间: 2019-5-3 00:23
ssh installer@ip # 等一小段时间后 这个怎么知道时间和密码
作者: LiuJia    时间: 2019-5-3 09:51
本帖最后由 LiuJia 于 2019-5-6 11:48 编辑
颠峰布衣飘 发表于 2019-5-3 00:23
ssh installer@ip # 等一小段时间后 这个怎么知道时间和密码


时间:大概能ping通公网IP时,一般几分钟后。

密码是在生成preseed.cfg文件时,自动生成,且会打印在屏幕里的。详情可查看:https://github.com/fincham/kexec-remote-debian-install/blob/master/build.py
作者: Cllp    时间: 2019-5-6 11:27
ddwin备用
作者: 颠峰布衣飘    时间: 2019-5-20 01:53
大佬求下无vnc控制台如何在grub里加入 ubuntu的 vnc 网上查的是centos7的
作者: 3002048420    时间: 2019-5-20 10:55
提示: 作者被禁止或删除 内容自动屏蔽
作者: LiuJia    时间: 2019-5-22 20:15
颠峰布衣飘 发表于 2019-5-20 01:53
大佬求下无vnc控制台如何在grub里加入 ubuntu的 vnc 网上查的是centos7的

您好,我也仅是查到CentOS的,如这个:https://www.danpros.com/2016/02/how-to-install-centos-7-remotely-using-vnc

可能Debian的安装器(debian-installer)没有vnc的相关功能,但有类似的network-console功能。

您觉得network-console不好用吗?
作者: 颠峰布衣飘    时间: 2019-5-24 09:59
LiuJia 发表于 2019-5-22 20:15
您好,我也仅是查到CentOS的,如这个:https://www.danpros.com/2016/02/how-to-install-centos-7-remote ...

只要有grub代码 能达到目地就行  大佬有么 地一份给我
作者: LiuJia    时间: 2019-5-24 17:42
颠峰布衣飘 发表于 2019-5-24 09:59
只要有grub代码 能达到目地就行  大佬有么 地一份给我

您好,我没现成的。但debian的wiki里提到有“Using the network console in the Amazon Elastic Computer Cloud”,您可以摸索一下:https://wiki.debian.org/DebianInstaller/NetworkConsole
作者: zxxx    时间: 2022-12-29 15:13
https://github.com/fincham/kexec-remote-debian-install/raw/master/build.py

这个脚本大佬保存了吗
作者: LiuJia    时间: 2022-12-29 15:55
本帖最后由 LiuJia 于 2022-12-29 15:56 编辑
zxxx 发表于 2022-12-29 15:13
https://github.com/fincham/kexec-remote-debian-install/raw/master/build.py

这个脚本大佬保存了吗 ...


大概内容是这样的:

  1. #!/usr/bin/env python
  2. #
  3. # Copyright (c) 2015 Catalyst.net Ltd
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #

  17. import argparse
  18. import os
  19. import random
  20. import shutil
  21. import StringIO
  22. import subprocess
  23. import tempfile

  24. """
  25. Produce an initrd image which can be used to remotely re-install Debian or Ubuntu.

  26. Michael Fincham <[email protected]>
  27. """

  28. def find(root):
  29.     for root, dirs, files in os.walk(root):
  30.         print dirs
  31.         print files

  32. if __name__ == "__main__":

  33.     parser = argparse.ArgumentParser(description=__doc__)
  34.     parser.add_argument('initrd', help='path to initrd.gz file to repack')
  35.     parser.add_argument('interface', help='which interface to configure')
  36.     parser.add_argument('address', help='IP address to configure on INTERFACE')
  37.     parser.add_argument('netmask', help='netmask to configure on interface')
  38.     parser.add_argument('gateway', help='default gateway to use')
  39.     parser.add_argument('nameservers', help='space separated list of name servers to use')
  40.     parser.add_argument('--locale', default='en_NZ.UTF-8', help='locale to use, defaults to en_NZ.UTF-8')
  41.     parser.add_argument('--keymap', default='us', help='keyboard keymap to use, defaults to us')

  42.     args = parser.parse_args()

  43.     password = "".join("{:02x}".format(ord(c)) for c in open("/dev/urandom","rb").read(16))

  44.     preseed_template = """
  45. d-i anna/choose_modules string network-console
  46. d-i preseed/early_command string anna-install network-console

  47. d-i network-console/password password {password}
  48. d-i network-console/password-again password {password}

  49. d-i netcfg/choose_interface select {interface}
  50. d-i netcfg/disable_dhcp boolean true
  51. d-i netcfg/get_ipaddress string {address}
  52. d-i netcfg/get_netmask string {netmask}
  53. d-i netcfg/get_gateway string {gateway}
  54. d-i netcfg/get_nameservers string {nameservers}
  55. d-i netcfg/confirm_static boolean true

  56. d-i debian-installer/locale string {locale}
  57. d-i console-keymaps-at/keymap select {keymap}
  58.     """

  59.     preseed = preseed_template.format(
  60.         password=password,
  61.         interface=args.interface,
  62.         nameservers=args.nameservers,
  63.         address=args.address,
  64.         netmask=args.netmask,
  65.         gateway=args.gateway,
  66.         locale=args.locale,
  67.         keymap=args.keymap,
  68.     )

  69.     print preseed

  70.     initrd_path = os.path.abspath(args.initrd)
  71.     original_cwd = os.getcwd()

  72.     working_directory = tempfile.mkdtemp()
  73.     os.chdir(working_directory)

  74.     with open('initrd.cpio','wb') as initrd_cpio:
  75.         print "Unpacking initrd..."
  76.         subprocess.check_call(("gzip -cd %s" % initrd_path).split(), stdout=initrd_cpio)

  77.     with open('initrd.cpio','rb') as initrd_cpio:
  78.         subprocess.check_call(("cpio -id").split(), stdin=initrd_cpio)

  79.     print ""
  80.     print "Re-packing initrd..."

  81.     os.unlink('initrd.cpio')
  82.     with open('preseed.cfg', 'w') as preseed_file:
  83.         preseed_file.write(preseed)

  84.     file_list = subprocess.check_output("find .".split())

  85.     with open('initrd.cpio', 'w') as initrd_cpio:
  86.         cpio_process = subprocess.Popen('cpio -H newc -o'.split(), stdin=subprocess.PIPE, stdout=initrd_cpio)
  87.         cpio_process.communicate(file_list)

  88.     with open(initrd_path,'wb') as initrd_cpio:
  89.         subprocess.check_call("gzip -c initrd.cpio".split(), stdout=initrd_cpio)

  90.     os.chdir(original_cwd)
  91.     shutil.rmtree(working_directory)
复制代码

作者: zxxx    时间: 2022-12-29 17:37
LiuJia 发表于 2022-12-29 15:55
大概内容是这样的:

感谢




欢迎光临 全球主机交流论坛 (https://91ai.net/) Powered by Discuz! X3.4