VMware Communities
Bill349
Contributor
Contributor
Jump to solution

How to edit files in a Linux vmdk

I am trying to edit a couple config files in a Linux vmdk.

I am using the Disk-Mount utility (ver 5.1.0) from within a Linux host running CentOS 2.6 - 64 bit.

(The vmdk I am trying to edit is not part of this host)

I can mount the vmdk and see all the files, but if I try to edit, I am told it is a read-only filesystem.

If I run the mount command - it looks as if the filesystem is rw.

Any help would be appreciated.

Thanks.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

I have extracted the vmdk from an ova template.

This is probably why it's mounting R/O as it is of createType=streamOptimized which is a compressed .vmdk file and compressed virtual disks can only be mounted R/O.

I want to edit some files before ever installing the VM.

Not sure if what I am attempting is even possible.

I want to tweak a couple setup files before the OS is installed.

Not a big deal if I can't.

Yes this is possible if you convert the OVF Package to a normal Virtual Machine then either mount and edit the files or boot from Linux Live OS CD/DVD/ISO Image and edit the files, then repackage the Virtual Machine to an OVF.  You can use vmware-vdiskmanager to convert just the virtual hard disk from a type 5 to a type 0 or 1 and then make the edits and then convert back to a type 5.  However I'm not sure that you can then inject that back into the OVF, haven't tried it before.  That's why I mention converting the full package, do your thing and then repackage the whole thing.

View solution in original post

0 Kudos
10 Replies
WoodyZ
Immortal
Immortal
Jump to solution

While the default is to mount R/W nonetheless I'd try two things.  Explicitly use the /m:w option and mount the disk as root.

mfelker
Expert
Expert
Jump to solution

As a test this is what I did and it was plretty easy

1)  $sudo nautilus

2)  Go to the vmware folder that contains your vm.  Since I had a shared vm of Windows 2012 Server Essenials I went to /var/lib/vmware/"Windows 2012 Server Essentials".  I am still in a root nautilus.  Then open the .vmdk - natulilus will ask what progralm to use to open the file. It will first say at first  it doesnt't know and can't find a program.  Ignore this. Choose to  open with another program.  In this case I used gedit. I found this.

-----

# Disk DescriptorFile

version=1

encoding="UTF-8"

CID=6abc0e36

parentCID=ffffffff

isNativeSnapshot="no"

createType="twoGbMaxExtentSparse"

test

# Extent description

RW 4192256 SPARSE "Windows Server 2012 Essentials-s001.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s002.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s003.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s004.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s005.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s006.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s007.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s008.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s009.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s010.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s011.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s012.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s013.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s014.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s015.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s016.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s017.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s018.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s019.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s020.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s021.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s022.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s023.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s024.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s025.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s026.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s027.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s028.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s029.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s030.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s031.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s032.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s033.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s034.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s035.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s036.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s037.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s038.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s039.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s040.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s041.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s042.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s043.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s044.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s045.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s046.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s047.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s048.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s049.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s050.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s051.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s052.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s053.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s054.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s055.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s056.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s057.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s058.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s059.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s060.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s061.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s062.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s063.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s064.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s065.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s066.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s067.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s068.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s069.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s070.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s071.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s072.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s073.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s074.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s075.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s076.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s077.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s078.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s079.vmdk"

RW 4192256 SPARSE "Windows Server 2012 Essentials-s080.vmdk"

RW 163840 SPARSE "Windows Server 2012 Essentials-s081.vmdk"

# The Disk Data Base

#DDB

ddb.toolsVersion = "9283"

ddb.adapterType = "lsilogic"

ddb.geometry.sectors = "63"

ddb.geometry.heads = "255"

ddb.geometry.cylinders = "20886"

ddb.uuid = "60 00 C2 90 57 2a 21 c9-e9 6f 15 dd e4 32 4f ca"

ddb.longContentID = "8eda363b1e682547d69d33b06abc0e36"

ddb.virtualHWVersion = "9"

Then inserted a line testing this and saved.  It remained in the vmdk file.  Of course I then used undo.  You will edit the file (or other .vmd) as you need

PS.  The next time you open the vmdk file using nautilus in root it will remember your choice - exactly like Windows.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Why are you even posting this!?  Bill349 is not trying to edit the "Disk DescriptorFile" of the virtual hard disk!  He is mounting a Linux virtual hard disk as he wants to edit some configuration files that reside on the virtual disk itself!  After all he does say, "I am trying to edit a couple config files in a Linux vmdk." ... "I am using the Disk-Mount utility..." and "I can mount the vmdk and see all the files, but if I try to edit, I am told it is a read-only filesystem."  So where in the world do you get he's trying to edit the virtual disks "Disk DescriptorFile"?  Unbelievable! Smiley Wink

0 Kudos
Bill349
Contributor
Contributor
Jump to solution

WoodyZ

Thanks for the response.

I did see that r/w switch, but I seem to be having trouble using it.

You wouldn't happen to have the exact syntax?

It does not show that switch in the command line help.

If I use this, I can see the files as read-only:

vmware-mount abc.vmdk  7 /abcvmdk

I am mounting the 7th partition.

If I put the /m:w, I get a syntax error - no matter where I put it in the command line.

I am root.

I've set the vmdk, and the mount point with 777 permisions.

Still no luck.


0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

I just took a quick look at the VMware Disk Mount User’s Guide (VMwareDiskMount.pdf) I had handy and when mounting under Linux that option is not available which leads me to believe that one can only mount R/O although I'm not in a position to test at the moment.

Another suggestion, if this is available to you, is to boot the VM from a Linux Live OS CD/DVD/ISO Image and edit the file from there.

Message was edited by: WoodyZ - BTW That option was under the Windows Host section and that R/W was default however under the Linux Host section it didn't mention anything about R/W.  In the document it states under "Limitations on Mounting Virtual Disks" it effectively says "you can mount and read Linux virtual disks on Linux hosts" yet it doesn't mention being able to write to them.

Bill349
Contributor
Contributor
Jump to solution

Thanks again.

I should give a little more info as to exactly what I am trying to do;

I have extracted the vmdk from an ova template.

I want to edit some files before ever installing the VM.

Not sure if what I am attempting is even possible.

I want to tweak a couple setup files before the OS is installed.

Not a big deal if I can't.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

I have extracted the vmdk from an ova template.

This is probably why it's mounting R/O as it is of createType=streamOptimized which is a compressed .vmdk file and compressed virtual disks can only be mounted R/O.

I want to edit some files before ever installing the VM.

Not sure if what I am attempting is even possible.

I want to tweak a couple setup files before the OS is installed.

Not a big deal if I can't.

Yes this is possible if you convert the OVF Package to a normal Virtual Machine then either mount and edit the files or boot from Linux Live OS CD/DVD/ISO Image and edit the files, then repackage the Virtual Machine to an OVF.  You can use vmware-vdiskmanager to convert just the virtual hard disk from a type 5 to a type 0 or 1 and then make the edits and then convert back to a type 5.  However I'm not sure that you can then inject that back into the OVF, haven't tried it before.  That's why I mention converting the full package, do your thing and then repackage the whole thing.

0 Kudos
Bill349
Contributor
Contributor
Jump to solution

Thanks - I appreciate your input.

Not sure how much effort I'm willing to put into this.

It was just for a home project.


0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Thanks - I appreciate your input.

You're welcome! Smiley Wink

Not sure how much effort I'm willing to put into this.

For me it would be nothing for me to do as I know how to do this without much thought and off the top of my head, so to speak.  If it's a matter for you to have to learn some of this on the fly then it would be a good educational process, if you have the time and willingness to do so. Smiley Happy

0 Kudos
Bill349
Contributor
Contributor
Jump to solution

I'll update this thread if I decide to try - I just might.

That's what weekends are for, right Smiley Happy


0 Kudos