Editing files in VMWare disk images

Submitted by Falken on

Rather annoyingly VMWare's 'vmware-mount' command mounts the image read-only, so if, for instance, you need to remove the device drivers that make [node:1580, title="VirtualBox choke"], you can't.

This is easy enough to get around, however:

# vmware-mount -f /home/chivertont/.VirtualBox/HardDisks/Windows\ XP/Windows\ XP\ Professional.vmdk /mnt/loopback/
# mount -t ntfs-3g -o loop,offset=32256,context= /mnt/loopback/flat /mnt/t
$LogFile indicates unclean shutdown (0, 0)
Failed to mount '/dev/loop0': Operation not supported
Mount is denied because NTFS is marked to be in use. Choose one action:

Choice 1: If you have Windows then disconnect the external devices by
clicking on the 'Safely Remove Hardware' icon in the Windows
taskbar then shutdown Windows cleanly.

Choice 2: If you don't have Windows then you can use the 'force' option for
your own responsibility. For example type on the command line:

mount -t ntfs-3g /dev/loop0 /mnt/t -o force

Or add the option to the relevant row in the /etc/fstab file:

/dev/loop0 /mnt/t ntfs-3g defaults,force 0 0

Well, I'm working on a copy of the image, so let's just go for it:

# mount -t ntfs-3g -o loop,offset=32256,context=,force /mnt/loopback/flat  /mnt/t
$LogFile indicates unclean shutdown (0, 0)
WARNING: Forced mount, reset $LogFile.
# mv t/WINDOWS/system32/drivers/AGP440.SYS t/WINDOWS/system32/drivers/AGP440.SYS.old
# mv t/WINDOWS/system32/drivers/intelppm.sys t/WINDOWS/system32/drivers/intelppm.sys.old

Now we just need to unmount everthing. This went a big gaga but was fine in the end. I used 'lsof' to check nothing was really using it and killed it.

# umount /mnt/t
# vmware-mount -d /mnt/loopback/
umount: /mnt/loopback: device is busy
umount: /mnt/loopback: device is busy
Failed to unmount partition '/mnt/loopback/': umount command failed
# sync
# vmware-mount -d /mnt/loopback/
umount: /mnt/loopback: device is busy
umount: /mnt/loopback: device is busy
Failed to unmount partition '/mnt/loopback/': umount command failed
# lsof +D /mnt/loopback
# ps -efw|grep vmw
root      3060     1  1 16:32 ?        00:00:03 vmware-mount -f /home/chivertont/.VirtualBox/HardDisks/Windows XP/Windows XP Professional.vmdk /mnt/loopback/
root      3132  5580  0 16:35 pts/1    00:00:00 grep vmw
# kill 3060

 

Sections