掛載WINDOWS虛機鏡像

1 rhel7 掛載windows虛機鏡像

在rhel 7.0 內掛載windows虛擬鏡像,需要ntfs-3g的軟件包。當你安裝該軟件包後,掛載windows虛擬機鏡像時,仍然出現下面問題:

[root@selinuxplus.com]# mount /opt/windowsxp_32.img  /mnt

mount: /dev/loop0 is write-protected, mounting read-only

mount: unknown filesystem type '(null)'

或者使用mount.ntfs-3g進行掛載。

[root@selinuxplus.com]# mount.ntfs-3g /opt/windowsxp_32.img  /mnt -o loop

NTFS signature is missing.

Failed to mount '/opt/windowsxp_32.img': Invalid argument

The device '/opt/windowsxp_32.img' doesn't seem to have a valid NTFS.

Maybe the wrong device is used? Or the whole disk instead of a

partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

問題是無法掛載分區,詳細信息見上面的報錯信息。
主要是因爲windowsxp_32.img鏡像的起始分區是1,因爲磁盤的第一個字節包含主引導記錄和一些磁盤結構,如MS-DOS結構。如果你使用0作爲第一個分區的起始,我們使用parted查看該分區結構,libparted會跳過開始的幾個字節的信息允許查看分區結構。

[root@localhost ~]# parted  /opt/windowsxp_32.img  unit b print

Model:  (file)

Disk /opt/windowsxp_32.img: 10737418240B

Sector size (logical/physical): 512B/512B

Partition Table: msdos

Disk Flags:

 

Number  Start   End           Size          Type     File system  Flags

1      32256B  10725765119B  10725732864B  primary  ntfs         boot


我們可以看到起始的位置爲32kB的地方,我們利用offset設置32kB的分區偏移量。32kB的起始,因爲使用的工具太舊了。如果你使用的是512字節的扇區,實際的分區偏移可能是32256對應的63Sector(磁區)。
我們嘗試使用offset進行分區掛載:

[root@selinuxplus.com opt]# cd /mnt

[root@selinuxplus.com mnt]# ls

bootfont.bin            ntldr

boot.ini                pagefile.sys

CONFIG.SYS              Program Files

Documents and Settings  RECYCLER

hiberfil.sys            System Volume Information

IO.SYS                  temp

Java                    virtio-win-0.1-74

MSDOS.SYS               WINDOWS


2 libguestfs 掛載windows虛機鏡像

當使用libguestfs掛載windows虛機鏡像時,也出現了這個問題.

[root@selinuxplus.com opt]# guestfish -a windowsxp_32.img

 

Welcome to guestfish, the guest filesystem shell for

editing virtual machine filesystems and disk images.

 

Type: 'help' for help on commands

      'man' to read the manual

      'quit' to quit the shell

 

><fs> run

100%

><fs> list-filesystems

/dev/sda1: ntfs

><fs> mount /dev/sda1 /

libguestfs: error: mount: /dev/sda1 on / (options: ''): mount: unknown filesystem type 'ntfs'

需要安裝libguestfs-winsupport

><fs> mount /dev/sda1 /

><fs> ll /

total 2097129

drwxrwxrwx  1 root root       4096 Dec 22 21:46 .

drwxr-xr-x 23 root root       4096 Dec 22 21:54 ..

-rwxrwxrwx  1 root root          0 Jan  8  2014 AUTOEXEC.BAT

-rwxrwxrwx  1 root root          0 Jan  8  2014 CONFIG.SYS

drwxrwxrwx  1 root root       4096 Mar 10  2014 Documents and Settings

-rwxrwxrwx  1 root root          0 Jan  8  2014 IO.SYS



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章