Triển khai Windows 7 – Phần 2: Sử dụng DISM

Triển khai Windows 7 – Phần 1: Những cải tiến của Windows AIK 2.0

Mitch Tulloch

Quản trị mạng - Trong phần hai này, chúng tôi sẽ tiếp tục giới thiệu cho các bạn về cách sử dụng Công cụ Deployment Image Servicing and Management(DISM).

Lưu ý: Phần hai này vẫn được viết dựa trên phiên bản Windows 7 RC.

Tìm hiểu về DISM

DISM.exe là một công cụ dòng lệnh mới được tích hợp vào trong bản cài đặt mặc định của hệ điều hành Windows 7 và cũng là một phần của phiên bản Windows Automated Installation Kit (Windows AIK) 2.0.

Tuy nhiên các bạn cần lưu ý rằng sự hỗ trợ các file VHD với tư cách các image Windows khởi động là một tính năng mới trong Windows 7 và sẽ được chúng tôi giới thiệu trong các phần sau.

Bạn có thể sử dụng DISM.exe cho các Windows image, nó gồm có các file Windows image (WIM) , các file virtual hard disk (VHD). Tuy DISM.exe được dự định chủ yếu cho việc phục vụ các Windows image offline (hiện không chạy), nhưng một trong số các tính năng của nó cũng có thể được sử dụng cho các hệ điều hành Windows online. Bằng cách sử dụng một image, chúng ta có thể thực hiện những thứ như thêm hay bớt driver thiết bị, thêm hay bớt các gói phần mềm của hệ điều hành, thêm các hotfixe, cấu hình các thiết lập international và thực hiện các kiểu hoạt động trên image vẫn có khác. DISM cũng có thể được sử dụng cho việc nâng cấp Windows image đối với phiên bản khác (cho ví dụ, nâng cấp từ Business lên Ultimate) và chuẩn bị một Windows PE image để sử dụng.

Bạn có thể sử dụng DISM.exe để phục vụ các image của các phiên bản Windows dưới đây:

  • Windows Vista SP1 hoặc hoặc mới hơn
  • Windows Server 2008
  • Windows 7
  • Windows Server 2008 R2

Sử dụng DISM

Trong Windows Vista (hoặc trong sử dụng Windows AIK 1.1), việc sử dụng một image yêu cầu đến việc sử dụng một số công cụ khác. Cho ví dụ, chúng ta hãy giả sử rằng muốn cài đặt một driver thiết bị trên một image mà bạn đã capture trước đó từ một cài đặt chủ. Để thực hiện điều đó trong Vista, bạn phải thực hiện như sau:

  1. Gắn (Mount) image bằng ImageX
  2. Thêm vào driver thiết bị bằng Package Manager (Pkgmgr.exe)
  3. Unmount image bằng ImageX

Thêm vào đó, nếu image của bạn là Windows PE image thì bạn cần phải sử dụng công cụ Windows Preinstallation Environment (PEimg.exe) để chuẩn bị image. Cuối cùng, nếu cần điều chỉnh ngôn ngữ và định vị các thiết lập của image thì bạn phải sử dụng International Settings Configuration Tool (Intlcfg.exe).

Mặc dù vậy, bắt đầu từ Windows 7, DISM.exe sẽ thay thế các công cụ Pkgmgr.exe, Intlcfg.exe và PEimg.exe như trong phiên bản 1.1 trước đây của Windows AIK. Thêm vào đó, DISM cũng có các chức năng gắn và bỏ các image để bạn có thể sử dụng chúng.

Sử dụng điển hình đối với DISM có thể là bổ sung thêm driver thiết bị vào một Windows image offline trước để triển khai image vào phần cứng yêu cầu driver. Chúng ta hãy thử một kịch bản như vậy để tìm hiểu cách sử dụng DISM từ dòng lệnh như thế nào.

Đầu tiên, trong thư mục C:\Images trên máy tính kỹ thuật viên Windows AIK 2.0 là một Windows install image (file install.wim) cho Windows 7:

C:\Program Files\Windows AIK\Tools\PETools>dir C:\Images
Volume in drive C has no label.
Volume Serial Number is 1C9A-D699
Directory of C:\Images
05/03/2009 12:46 PM <DIR> .
05/03/2009 12:46 PM <DIR> ..
04/22/2009 07:28 AM 2,218,242,699 install.wim
1 File(s) 2,218,242,699 bytes
2 Dir(s) 180,411,486,208 bytes free

Lưu ý: Nhớ lại phần 17 trong loạt bài Triển khai Vista, có hai kiểu Windows image đó là boot và install.

Tiếp đến, trong thư mục C:\Drivers là các driver của Windows 7 beta (phiên bản 2.91) cho phần cứng Microsoft LifeCam:

C:\Program Files\Windows AIK\Tools\PETools>dir C:\Drivers
Volume in drive C has no label.
Volume Serial Number is 1C9A-D699
Directory of C:\Drivers
05/03/2009 01:19 PM <DIR> .
05/03/2009 01:19 PM <DIR> ..
05/03/2009 01:19 PM <DIR> VX6000
0 File(s) 0 bytes
3 Dir(s) 180,411,486,208 bytes free

Chúng ta sẽ gắn các image của mình vào một thư mục trống mang tên C:\Servicing. Hãy bắt đầu lệnh DISM.exe với tham số /get-wiminfo để hiển thị danh sách tất cả các Windows image có trong file install.wim. Nhớ rằng một install image có thể gồm nhiều Windows image.

C:\Program Files\Windows AIK\Tools\PETools>dism /get-wiminfo /wimfile:C:\Images\install.wim

Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Details for image : C:\Images\install.wim

Index : 1
Name : Windows 7 STARTER
Description : Windows 7 STARTER
Size : 7,927,317,234 bytes
Index : 2
Name : Windows 7 HOMEBASIC
Description : Windows 7 HOMEBASIC
Size : 7,983,232,406 bytes
Index : 3
Name : Windows 7 HOMEPREMIUM
Description : Windows 7 HOMEPREMIUM
Size : 8,422,988,972 bytes
Index : 4
Name : Windows 7 PROFESSIONAL
Description : Windows 7 PROFESSIONAL
Size : 8,303,245,818 bytes
Index : 5
Name : Windows 7 ULTIMATE
Description : Windows 7 ULTIMATE
Size : 8,461,373,562 bytes
The operation completed successfully.

Hãy giả sử rằng chúng ta sẽ triển khai Windows 7 Professional, trong trường hợp này, chúng ta có thể thấy từ đầu ra của lệnh trên rằng, chỉ số là 4 cho image này. Chính vì vậy chúng ta hãy gắn Windows image này với thư mục trống C:\Servicing bằng cách sử dụng tham số /mount-wim của lệnh DISM.exe:

C:\Program Files\Windows AIK\Tools\PETools>dism /mount-wim /wimfile:C:\Images\install.wim /index:4 /mountdir:C:\Servicing
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Mounting image
[==========================100.0%==========================]
The operation completed successfully.

Để thẩm định xem image đã được gắn thành công hay chưa, chúng ta có thể sử dụng tham số /get-mountedinfo như sau:

C:\Program Files\Windows AIK\Tools\PETools>dism /get-mountedwiminfo
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Mounted images:
Mount Dir : C:\Servicing
Image File : C:\Images\install.wim
Image Index : 4
Mounted Read/Write : Yes
Status : Ok
The operation completed successfully.

Nếu xem xét tỉ mỉ nội dung của thư mục C:\Servicing, chúng ta có thể thấy được các file và các thư mục của image đã gắn của mình:

C:\Program Files\Windows AIK\Tools\PETools>dir C:\Servicing
Volume in drive C has no label.
Volume Serial Number is 1C9A-D699
Directory of C:\Servicing
04/22/2009 03:36 AM <DIR> .
04/22/2009 03:36 AM <DIR> ..
03/20/2009 10:42 AM 24 autoexec.bat
03/20/2009 10:42 AM 10 config.sys
04/22/2009 01:17 AM <DIR> PerfLogs
04/22/2009 05:26 AM <DIR> Program Files
04/22/2009 03:27 AM <DIR> Users
04/22/2009 05:29 AM <DIR> Windows
2 File(s) 34 bytes
6 Dir(s) 180,321,382,400 bytes free

Lúc này hãy xem kiểu hành động sử dụng mà chúng ta có thể thực hiện trên image đã gắn của mình là gì:

C:\Program Files\Windows AIK\Tools\PETools>dism /image:C:\Servicing /?
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
The following commands may be used to service the image:
WINDOWS EDITION SERVICING COMMANDS:
/Set-ProductKey - Populates the product key into the offline image.
/Get-TargetEditions - Displays a list of Windows editions that an image can be upgraded to.
/Get-CurrentEdition - Displays the editions of the specified image.
/Set-Edition - Upgrades the Windows image to a higher edition.
UNATTEND SERVICING COMMANDS:
/Apply-Unattend - Applies an unattend file to an image.
DRIVER SERVICING COMMANDS:
/Remove-Driver - Removes driver packages from an offline image.
/Add-Driver - Adds driver packages to an offline image.
/Get-DriverInfo - Displays information about a specific driver in an offline image or a running operating system.
/Get-Drivers - Displays information about all drivers in an offline image or a running operating system.
INTERNATIONAL SERVICING COMMANDS:
/Set-LayeredDriver - Sets keyboard layered driver.
/Set-UILang - Sets the default system UI language that is used in the mounted offline image.
/Set-UILangFallback - Sets the fallback default language for the system UI in the mounted offline image.
/Set-UserLocale - Sets the user locale in the mounted offline image.
/Set-SysLocale - Sets the language for non-Unicode programs (also called system locale) and font settings in the mounted offline image.
/Set-InputLocale - Sets the input locales and keyboard layouts to use in the mounted offline image.
/Set-TimeZone - Sets the default time zone in the mounted offline image.
/Set-AllIntl - Sets all international settings in the mounted offline image.
/Set-SKUIntlDefaults - Sets all international settings to the default values for the specified SKU language in the mounted offline image.
/Gen-LangIni - Generates a new lang.ini file.
/Set-SetupUILang - Defines the default language that will be used by setup.
/Get-Intl - Displays information about the international settings and languages.
APPLICATION SERVICING COMMANDS:
/Check-AppPatch - Displays information if the MSP patches are applicable to the mounted image.
/Get-AppPatchInfo - Displays information about installed MSP patches.
/Get-AppPatches - Displays information about all applied MSP patches for all installed applications.
/Get-AppInfo - Displays information about a specific installed MSI application.
/Get-Apps - Displays information about all installed MSI applications.
PACKAGE SERVICING COMMANDS:
/Add-Package - Adds packages to the image.
/Remove-Package - Removes packages from the image.
/Enable-Feature - Enables a specific feature in the image.
/Disable-Feature - Disables a specific feature in the image.
/Get-Packages - Displays information about all packages in the image.
/Get-PackageInfo - Displays information about a specific package.
/Get-Features - Displays information about all features in a package.
/Get-FeatureInfo - Displays information about a specific feature.
/Cleanup-Image - Performs cleanup and recovery operations on the image.
For more information about these servicing commands and their arguments,
specify a command immediately before /?.
Examples:
DISM.exe /Image:C:\test\offline /Apply-Unattend /?
DISM.exe /Image:C:\test\offline /Get-Features /?
DISM.exe /Online /Get-Drivers /?

Các tham số chúng ta muốn sử dụng có thể tìm thấy trong phần DRIVER SERVICING COMMANDS ở trên. Chúng ta hãy sử dụng tham số /get-drivers để hiển thị danh sách các driver đã được cài đặt trong image được gắn:

C:\Program Files\Windows AIK\Tools\PETools>dism /image:C:\Servicing /get-drivers
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
Obtaining list of 3rd party drivers from the driver store...
Driver packages listing:
Published Name : oem0.inf
Original File Name : prnms001.inf
Inbox : No
Class Name : Printer
Provider Name : Microsoft
Date : 6/21/2006
Version : 6.1.7100.0
The operation completed successfully.

Hãy sử dụng tham số để bổ sung thêm LifeCam driver vào image đã gắn:

C:\Program Files\Windows AIK\Tools\PETools>dism /image:C:\Servicing /add-driver /driver:C:\Drivers\VX6000\vx6000.inf
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
Found 1 driver package(s) to install.
Installing 1 of 1 - C:\Drivers\VX6000\vx6000.inf: The driver package was successfully installed.
The operation completed successfully.

Sử dụng /get-drivers lần nữa để thẩm định rằng LifeCam driver đã được bổ sung thành công vào image đã gắn:

C:\Program Files\Windows AIK\Tools\PETools>dism /image:C:\Servicing /get-drivers
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
Obtaining list of 3rd party drivers from the driver store...
Driver packages listing:
Published Name : oem0.inf
Original File Name : prnms001.inf
Inbox : No
Class Name : Printer
Provider Name : Microsoft
Date : 6/21/2006
Version : 6.1.7100.0
Published Name : oem1.inf
Original File Name : vx6000.inf
Inbox : No
Class Name : Image
Provider Name : Microsoft
Date : 7/18/2008
Version : 5.5.3.74
The operation completed successfully.

Kết thúc sử dụng image bằng cách unmount nó:

C:\Program Files\Windows AIK\Tools\PETools>dism /unmount-wim /mountdir:C:\Servicing /commit
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image File : C:\Images\install.wim
Image Index : 4
Saving image
[==========================100.0%==========================]
Unmounting image
[==========================100.0%==========================]
The operation completed successfully.

Các tài nguyên bổ sung

Để có thêm các thông tin về sử dụng DISM.exe, hãy đánh dism /? Trong Deployment Tools Command Prompt trên máy tính của kỹ thuật viên. Bạn cũng có thể tìm thấy các thông tin chi tiết có liên quan đến DISM.exe trong phần Deployment Tools Technical Reference của hướng dẫn sử dụng Windows Automated Installation Kit (WAIK.chm), hướng dẫn có thể được truy cập bằng cách kích Start | All Programs | Microsoft Windows AIK trên máy tính của kỹ thuật viên

Thứ Năm, 04/06/2009 07:04
52 👨 8.048
0 Bình luận
Sắp xếp theo
    ❖ Tổng hợp