你可以在沒啟動虛擬電腦的狀態下, 直接掛載虛擬硬碟檔 (*.qcow2, *.vmdk,...), 進行系統修改, 操作步驟如下 :
1. 將 VMware 虛擬硬碟檔 (*.vmdk) 掛載至 /dev/nbd0 區塊裝置, 命令如下 :
$ sudo kvm-nbd --connect=/dev/nbd0 ./NS88.vmdk
2. 檢視虛擬硬碟檔內部資訊 (檔案系統, 分割區)
$ sudo fdisk /dev/nbd0
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/nbd0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
所用裝置 Boot Start End Blocks Id System
/dev/nbd0p1 * 1 522 4192933+ 83 Linux
3. 將 /dev/nbd0p1 裝置掛載至指定目錄
由前一步驟的資訊中, 可以得知存在 /dev/nbd0p1 這裝置, 其內容為 Linux 檔案系統, 掛載命令如下 :
$ sudo mkdir /tmp/mydisk
$ sudo mount /dev/nbd0p1 /tmp/mydisk
4. 檢視虛擬硬碟檔內部的檔案系統
$ ll /tmp/mydisk
總計 32
drwxr-xr-x 5 root root 4096 2011-08-20 17:33 ./
drwxr-xr-x 23 root root 4096 2011-07-16 19:18 ../
drwxr-xr-x 3 root root 4096 2011-08-19 12:03 boot/
drwx------ 2 root root 16384 2011-08-19 12:03 lost+found/
drwxrwxr-x 3 xman staff 4096 2011-08-19 14:04 tce/
5. 卸載 /dev/nbd0 裝置
$ sudo umount /tmp/mydisk
$ sudo kvm-nbd -d /dev/nbd0
/dev/nbd0 disconnected
沒有留言:
張貼留言