坏气十足 发表于 2018-6-20 07:55:24

挂载WINDOWS虚机镜像

1 rhel7 挂载windows虚机镜像
  在rhel 7.0 内挂载windows虚拟镜像,需要ntfs-3g的软件包。当你安装该软件包后,挂载windows虚拟机镜像时,仍然出现下面问题:
  # mount /opt/windowsxp_32.img/mnt
  mount: /dev/loop0 is write-protected, mounting read-only
  mount: unknown filesystem type '(null)'
  或者使用mount.ntfs-3g进行挂载。
  # 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会跳过开始的几个字节的信息允许查看分区结构。
  # parted/opt/windowsxp_32.imgunit b print
  Model:(file)
  Disk /opt/windowsxp_32.img: 10737418240B

  Sector>  Partition Table: msdos
  Disk Flags:

  NumberStart   End          >  1      32256B10725765119B10725732864Bprimaryntfs         boot
  我们可以看到起始的位置为32kB的地方,我们利用offset设置32kB的分区偏移量。32kB的起始,因为使用的工具太旧了。如果你使用的是512字节的扇区,实际的分区偏移可能是32256对应的63Sector(磁区)。
  我们尝试使用offset进行分区挂载:
  # cd /mnt
  # ls
  bootfont.bin            ntldr
  boot.ini                pagefile.sys
  CONFIG.SYS            Program Files
  Documents and SettingsRECYCLER
  hiberfil.sys            System Volume Information
  IO.SYS                  temp
  Java                  virtio-win-0.1-74
  MSDOS.SYS               WINDOWS
2 libguestfs 挂载windows虚机镜像
  当使用libguestfs挂载windows虚机镜像时,也出现了这个问题.
  # 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
  drwxrwxrwx1 root root       4096 Dec 22 21:46 .
  drwxr-xr-x 23 root root       4096 Dec 22 21:54 ..
  -rwxrwxrwx1 root root          0 Jan82014 AUTOEXEC.BAT
  -rwxrwxrwx1 root root          0 Jan82014 CONFIG.SYS
  drwxrwxrwx1 root root       4096 Mar 102014 Documents and Settings
  -rwxrwxrwx1 root root          0 Jan82014 IO.SYS
页: [1]
查看完整版本: 挂载WINDOWS虚机镜像