Windows Nano Server VHD檔案製作

來源:互聯網
上載者:User

標籤:

  有幸參加盆盆老師的課Windows Nano Server的介紹,有感這次盆盆老師的技術分享,所以簡單的分享一下如何製作Windows Nano Server的過程,同時也非常感謝盆盆老師的技術分享。

 

1.先下載windows_server_technical_preview_2的iso(九叔無私分享提供):連結:http://pan.baidu.com/s/1gd8KP5D 密碼:c0tc

2.下載轉換的指令碼:https://gallery.technet.microsoft.com/scriptcenter/Convert-WindowsImageps1-0fe23a8f 

3.下載完畢windows_server_technical_preview_2,我們可以先掛載ISO,可以看到與以前的windows server 的ISO有所區別:

650) this.width=650;" title="image" style="border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/6D/wKioL1V8cSOhPW_vAANvjT0sTUc515.jpg" width="755" height="583" />

650) this.width=650;" title="image" style="border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6E/6D/wKioL1V8cSPibuk0AAEWdwKMj7s828.jpg" width="689" height="257" />

650) this.width=650;" title="image" style="border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6E/6D/wKioL1V8cSSwnyyHAAHXEIiVmJ0918.jpg" width="733" height="243" />

看到這麼多的cab,大家也好奇這是啥東東,按照我的理解是跟windows添加角色功能的一樣的,只不過是用cab打包好。如果我們需要,就打上相應的cab包添加角色。

Role or feature

Package file

Hyper-V 角色

Microsoft-NanoServer-Compute-Package.cab

容錯移轉叢集角色

Microsoft-NanoServer-FailoverCluster-Package.cab

NanoServer主機虛擬機器驅動(我更喜歡叫它整合服務)

Microsoft-NanoServer-Guest-Package.cab

儲存和網卡驅動

Microsoft-NanoServer-OEM-Drivers-Package.cab

檔案伺服器角色和其他儲存群組件

Microsoft-NanoServer-Storage-Package.cab

從這裡,我們可以看出Windows Nano Server 在整個Windows架構上可以作為Hyper-v,群集,擴充檔案伺服器,容器container以及來賓虛擬機器。

4.我們就開始製作Windows Nano Server吧。先解除指令碼的鎖定,

650) this.width=650;" title="image" style="border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6E/6D/wKioL1V8cSTyUooKAAIBEF5wgFw688.jpg" width="439" height="662" />

5.運行指令碼

指令碼格式如下:.\Convert-WindowsImage.ps1 -Sourcepath <path to wim> -VHD <path to new VHD file> –VHDformat VHD -Edition 1

650) this.width=650;" title="image" style="border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6E/71/wKiom1V8b3qCr8T5AANPxxrrk_c284.jpg" width="1200" height="381" />

PS:這個製作過程大概不超過5分鐘,整個vhd大概是483MB。

650) this.width=650;" title="image" style="border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/71/wKiom1V8b3vAjYvoAABVCd-0Rf4213.jpg" width="594" height="111" />

6.將vhd在windows Server TP2運行(目前只支援在TP2的環境運行),當然需要配置一下才可以作為VM運行。

1)需要在磁碟建立一個目錄名NanoServer

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6E/6D/wKioL1V8cSbBarPOAAJbZz4vvuE489.jpg" height="362" />

2)將windows Server TP2 iso裡面提取cab複製到NanoServer裡面

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6E/71/wKiom1V8b3ygTAi6AAEtYaDZWjI941.jpg" height="201" />

3)建立一個目錄名為mountdir的檔案

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/71/wKiom1V8b3yiKdHUAAEeajYS5pQ745.jpg" height="200" />

4)將nano.vhd掛載映像的形式掛載到mountdir目錄下

dism /Mount-Image /ImageFile:c:\Nano.vhd /Index:1 /MountDir:.\mountdir

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6E/71/wKiom1V8b32RpJcPAADkc9ZdLZo510.jpg" height="104" />

5)將Microsoft-NanoServer-Guest-Package.cab載入到NanoServer裡面(盆盆老師說過nano作為VM的時候要載入這個cab,後來我自己試過沒載入這個cab包啟動vm,一直都是啟動介面的)

dism /Add-Package /PackagePath:.\packages\Microsoft-NanoServer-Guest-Package.cab /Image:.\mountdir

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/6D/wKioL1V8cSexY-t0AAFNYyUZBUM224.jpg" height="127" />

6)這一步是為了顯示NanoServer 的ip資訊(因為只有第一次啟動nanoserver的時候,才會顯示ip資訊),建立兩個檔案,分別為SetupComplete.cmd和Startup.cmd.

SetupComplete.cmd指令碼如下:

netsh advfirewall set domainprofile state off  
netsh advfirewall set privateprofile state off    
netsh advfirewall set publicprofile state off    
netsh advfirewall set currentprofile state off    
ipconfig    
schtasks /create /tn "Start" /tr c:\windows\system32\Startup.cmd /sc onstart /ru "System"

 

Startup.cmd指令碼如下:

ping 192.168.10.101 -n 7  
ipconfig

 

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/6E/6D/wKioL1V8cSiQKsV6AAGaNMmBIcA073.jpg" height="224" />

先為SetupComplete.cmd建立指令碼檔案夾

md .\mountdir\Windows\Setup\Scripts

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/6D/wKioL1V8cSjwsHB9AACheaHNckc520.jpg" height="121" />

將兩個指令碼copy到NanoServer裡面

copy .\SetupComplete.cmd .\mountdir\Windows\Setup\Scripts

copy .\Startup.cmd .\mountdir\Windows\System32

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/71/wKiom1V8b37DP11rAAB1KstFsn4406.jpg" height="35" />

7)卸載NanoServer映像

dism /Unmount-Image /MountDir:.\MountDir /Commit

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6E/71/wKiom1V8b3_RcG-OAADOJUKBDVs217.jpg" height="104" />

7.建立虛擬機器,掛載nano.vhd,啟動虛擬機器

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/6E/6E/wKioL1V8cSnCoxbsAAIzCJeKJAA762.jpg" height="585" />

8.通過PowerShell串連NanoServer

指令碼如下:

$ip=”nano server ip address”

$user=”$ip\administrator”

Enter-PSSession -ComputerName $ip -Credential $user

administrator初始密碼為空白

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/6E/wKioL1V8cSqxLdTUAAB45bY7zcY613.jpg" height="44" />

就可以看到NanoServer的串連會話

650) this.width=650;" title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M00/6E/71/wKiom1V8b4DifEvbAAE_1yyBkBg784.jpg" height="238" />

NanoServer概述和配置具體詳情可以訪問:https://technet.microsoft.com/en-gb/library/mt126167.aspx

NanoServer啟動指令碼配置可以訪問:http://blogs.technet.com/b/nanoserver/archive/2015/05/19/how-to-display-ipconfig-on-nano-server-every-time-it-boots.aspx

 

如果本文章有什麼遺漏或者需要補充什麼,麻煩指點下,多謝。

本文出自 “gs_hao” 部落格,謝絕轉載!

Windows Nano Server VHD檔案製作

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.