在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
当使用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 p_w_picpaths.
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
转载于:https://blog.51cto.com/aireal/1786944