一键装机linux_Windows一键重装系统为Linux (netboot,网络安装)

本文介绍了一种通过网络安装Linux的方法,适用于解决某些厂商不支持从Windows重装Linux、需要更大系统盘或不支持VNC的情况。文章提供了详细步骤,包括下载、安装和注意事项,强调在开始前备份数据。该方法涉及DHCP和非DHCP模式,用户可选择手动输入网络参数或使用预设选项。
摘要由CSDN通过智能技术生成

文章核心内容转载自@

特别提醒:一键重装有一定的风险,请做好数据备份,做好抢救方案!

有些厂商的机器因策略问题,不支持Windows重装为Linux. 例如: 腾讯云非大陆区域.

有些厂商Windows系统盘会比Linux系统盘大,想要大一点系统盘. 例如: AZURE.

有些厂商不支持VNC,这对于转换系统实在不方便.

这篇文章可以解决以上问题.

使用前,请耐心看完文章.

如果造成损失,萌咖(原大佬)不负任何责任.

使用方法

下载

双击打开此文件.

自行选择选项.

按回车重启,并等待安装完成.

注意事项

如果对提供安装的发行版不满意,请参考此文章:CentOS/Debian/Ubuntu网络重装系统一键脚本

默认提供的是Debian8(Jessie),添加了firmware包,提供了更多的驱动支持,DHCP模式一键.

非DHCP模式,如果要一键,则需要自己定制镜像.

定制Debian系镜像应该没问题,其他未作测试.

默认root账户密码 Vicer .

如需要Linux一键重装为Windows,请参考:

如果厂商不支持VNC,则需要自己定制镜像.

定制方法参考上面提到的:CentOS/Debian/Ubuntu网络重装系统一键脚本

主要在镜像中添加机器的网络参数,以便支持一键安装.

命令示例:

1

bashInstallNET.sh-d8-v64-a--ip-addr--ip-mask--ip-gate--loader

完成后将 initrd.img 和 vmlinuz 存放到能直链下载的位置.

如果厂商支持VNC,则可以直选全部选 1 .

安装的时候,自己填 IP地址,子网掩码, 网关, DNS服务器.

DNS服务器推荐填: 8.8.8.8

区分是否为DHCP模式

非DHCP模式: 如上图,显示了详细的IP地址.(选项为:使用下面的IP地址)

DHCP模式: 参考上图.(选项为:自动获得IP地址)

源码备份

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

@ECHOOFF&PUSHD%~DP0&TITLEWin32Loader

setlocalenabledelayedexpansion

::AuthorMoeClub.org

color87

cd.>%windir%\GetAdmin

ifexist%windir%\GetAdmin(del/f/q"%windir%\GetAdmin")else(

echoCreateObject^("Shell.Application"^).ShellExecute"%~s0","%*","","runas",1>>"%temp%\Admin.vbs"

"%temp%\Admin.vbs"

del/s/q"%temp%\Admin.vbs"

exit/b2)

cls

echo *InitWin32Loader.

setURL=https://moeclub.org/attachment/WindowsSoftware

setdownload=0

settry_download=1

:Init

mkdir"%SystemDrive%\win32-loader">NUL2>NUL

ifexist"%SystemDrive%\Windows\System32\WindowsPowerShell"(

setuse_ps=1

)else(

setuse_ps=0

)

if%use_ps%equ1(

gotoInitIt

)else(

gotoInitFail

)

:InitIt

settry_download=0

powershell.exe-command"& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/g2ldr','%SystemDrive%\g2ldr')}">NUL2>NUL

powershell.exe-command"& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/g2ldr.mbr','%SystemDrive%\g2ldr.mbr')}">NUL2>NUL

powershell.exe-command"& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/grub.cfg','%SystemDrive%\win32-loader\grub.cfg')}">NUL2>NUL

gotoInitDone

:InitFail

echoNotfoundpowershell,pleasedownloadthembyyourself.

echo'%SystemDrive%\g2ldr'

echo'%SystemDrive%\g2ldr.mbr'

echo'%SystemDrive%\win32-loader\grub.cfg'

echoPress[ENTER]whenyoufinished.

pause>NUL2>NUL

gotoInitDone

:InitDone

if!try_download!equ0(

setInitOption=InitFail

)else(

setInitOption=Init

)

ifnotexist"%SystemDrive%\g2ldr"goto!InitOption!

ifnotexist"%SystemDrive%\g2ldr.mbr"goto!InitOption!

ifnotexist"%SystemDrive%\win32-loader\grub.cfg"goto!InitOption!

:Image

echo.

echo *Pleaseselectinitrdmode.

echo[1]Onlinedownload

echo[2]Localfile

choice/n/c12/mSelect:

iferrorlevel2gotoLocalMode

iferrorlevel1gotoOnlineMode

gotoImage

:OnlineMode

echo.

echo *Pleaseselectsource.

echo[1]byMoeClub(DHCPorVNCSupport)

echo[2]byyourself

choice/n/c12/mSelect:

iferrorlevel2gotoYourself

iferrorlevel1gotoMoeClub

gotoOnlineMode

:Yourself

echo.

echoif'initrd.img'URLis'https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie/initrd.img',Pleaseinput'https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie'.

set/pIMG_URL=URL:

ifdefinedIMG_URL(

gotoDownload

)else(

gotoMoeClub

)

:MoeClub

setIMG_URL=https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie

gotoDownload

:Download

if%use_ps%equ1(

echo.

echoDownloading'initrd.img'...

powershell.exe-command"& {$client = new-object System.Net.WebClient; $client.DownloadFile('!IMG_URL!/initrd.img','%SystemDrive%\win32-loader\initrd.img')}">NUL2>NUL

echoDownloading'vmlinuz'...

powershell.exe-command"& {$client = new-object System.Net.WebClient; $client.DownloadFile('!IMG_URL!/vmlinuz','%SystemDrive%\win32-loader\vmlinuz')}">NUL2>NUL

setdownload=1

)else(

echoNotsupportonlinedownload,autochangeLocalinitrd.

gotoLocalMode

)

:LocalMode

if!download!equ0(

echo.

echoPleaseput'initrd.img'and'vmlinuz'to'%SystemDrive%\win32-loader'.

echoPress[ENTER]whenyoufinished.

pause>NUL2>NUL

)

:Done0

setdownload=0

ifexist"%SystemDrive%\win32-loader\initrd.img"(

gotoDone1

)else(

echoNotfound'%SystemDrive%\win32-loader\initrd.img'.

gotoLocalMode

)

:Done1

setdownload=0

ifexist"%SystemDrive%\win32-loader\vmlinuz"(

gotoDone

)else(

echoNotfound'%SystemDrive%\win32-loader\vmlinuz'.

gotoLocalMode

)

:Done

echo.

echoPress[ENTER]toreboot...

pause>NUL2>NUL

ifnotexist"%SystemDrive%\g2ldr"echoNotfound'%SystemDrive%\g2ldr'.&&exit1

ifnotexist"%SystemDrive%\g2ldr.mbr"echoNotfound'%SystemDrive%\g2ldr.mbr'.&&exit1

ifnotexist"%SystemDrive%\win32-loader\grub.cfg"echoNotfound'%SystemDrive%\win32-loader\grub.cfg'.&&exit1

ifnotexist"%SystemDrive%\win32-loader\initrd.img"echoNotfound'%SystemDrive%\win32-loader\initrd.img'.&&exit1

ifnotexist"%SystemDrive%\win32-loader\vmlinuz"echoNotfound'%SystemDrive%\win32-loader\vmlinuz'.&&exit1

setid={01234567-89ab-cdef-0123-456789abcdef}

bcdedit/create%id%/d"Debian GUN/Linux"/applicationbootsector>NUL2>NUL

bcdedit/set%id%devicepartition=%SystemDrive%>NUL2>NUL

bcdedit/set%id%path\g2ldr.mbr>NUL2>NUL

bcdedit/displayorder%id%/addlast>NUL2>NUL

bcdedit/bootsequence%id%/addfirst>NUL2>NUL

shutdown-r-t0

No related posts.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值