Had a problem copying a VM with cygwin, it won't import “Add VM to inventory”. The directory copy did not work. “Add to VM Inventory” could see dir but not browse inside. Symptom: you see group names like “????????” and “mkgroup-l-d” in cygwin (ls).
Copy dir with windows works, then rename. But wished to script the VM creation and using xcopy and copy (cmd built in) wasn't easy enough. Script does copy of the whole VM directory and contents then edit the .vmx file inside, just change the “displayName”. This does the copy and rename:
FROM=Node2_XXX
TO=Node3_XXX
cp -R -p -a $FROM $TO
perl -i.bak -pe 's/(displayName *= *").*(")/$1'$TO'$2/' $TO/*.vmx
# we're matching this one: displayName = "Node2_XXX"
# and ignoring this and all others: extendedConfigFile = "QNX_641_xxx.vmxf"
After thisscript is run in VM interface do “Add VM to Inventory", browse to dir. Select the vmx file. Select “I copied it” (this assigns a new mac address). Then power on machine. Edit network settings etc..
We can copy it with cygwin, if we fix up groups. It was a wrong group problem. Solution do this: cp /etc/group /etc/group.bak; mkgroup -l -d >/etc/group
See below for more detail.
I'm sure this groups thing has caused me trouble before. e.g. the mysterious differences running sshd as windows service vs running on command-line. (Note: running on command-line can change permissions/ownership on files used and make it not work when running as server).
More details (cygwin mkgroup -l -d and {set,get}facl )
Copying one file example:
# BEFORE:
$ cp -a -p VM1_lab/*.vmx test.vmx
$ ls -al VM1_lab/*.vmx test*.vmx
-rwx------+ 1 me ???????? 0 Nov 2 18:51 VM1_lab/QNX_641_xxx.vmx
-rwx------ 1 me mkgroup-l-d 0 Nov 3 11:35 test.vmx
# AFTER:
$ cp /etc/group /etc/group.bak; mkgroup -l -d >/etc/group
$ cp -a -p VM1_lab/*.vmx test2.vmx
$ ls -al VM1_lab/*.vmx test*.vmx
-rwx------+ 1 me Domain Users 2189 Nov 2 18:51 VM1_lab/QNX_641_xxx.vmx
-rwx------ 1 me Users 2196 Nov 3 11:35 test.vmx
-rwx------ 1 me Domain Users 2189 Nov 2 18:51 test2.vmx
See below the result of cygwin cp VM1_lab Node2_XXX make the group owner of dir mkgroup-l-d. Highlighted in orange. That dir shows up in VM Add machine to inventory but the .vmx files inside are not visible.
me@mine /cygdrive/c/Virtual Machines
$ ls -al
total 1967096
drwxrwx---+ 14 Administrators SYSTEM 0 Nov 2 18:15 .
drwxrwxr-x+ 25 Administrators SYSTEM 0 Oct 30 14:48 ..
drwx------+ 2 me mkgroup-l-d 0 Nov 2 18:25 Node2_XXX
-rwx------+ 1 me ???????? 643830909 Aug 4 18:15 QNX641_XXX_template.tar.gz
drwx------+ 3 me ???????? 0 Nov 2 17:55 VM1_lab
drwx------+ 4 me ???????? 0 Oct 30 13:33 VM2_lab
-rwx------+ 1 me ???????? 732909568 Aug 31 14:14 ubuntu-9.04-desktop-i386.iso
drwx------+ 2 me ???????? 0 Oct 27 09:35 zenoss-2.4.5-380-x86
Re: CYGWIN=ntsec, "cp -a", and NT acls
It's worth fixing/using cygwin because md/mkdir/copy is cmd builtin, xcopy is prompty-fussy (prompts Y/N file copy can be overcome but prompts File/Dir cannot?)
$ getfacl $FROM>moo.facl; setfacl -f moo.gfacl $TO
setfacl: illegal acl entries
More direct: getfacl $FROM | setfacl -f - $TO
me@mine /cygdrive/c/Virtual Machines
$ cat moo.facl
# file: VM1_lab
# owner: me
# group: ????????
user::rwx
group::---
group:root:rwx
group:SYSTEM:rwx
group:mkgroup-l-d:rwx
mask:rwx
other:---
default:user::rwx
default:group:root:rwx
default:group:SYSTEM:rwx
default:group:mkgroup-l-d:rwx
default:mask:rwx
For reference, a VM template dir contents might be somthing like this:
$ tar -zxvf QNX641_xxx_template.tar.gz
drwxr-xr-x root/root 0 2009-08-04 17:06 QNX641_xxx/
-rw------- root/root 8684 2009-08-04 17:05 QNX641_xxx/QNX_641_xxx.nvram
-rw-r--r-- root/root 44488 2009-08-04 17:05 QNX641_xxx/vmware-0.log
-rw-r--r-- root/root 43871 2009-08-04 17:05 QNX641_xxx/vmware-2.log
-rw-r--r-- root/root 45331 2009-08-04 17:05 QNX641_xxx/vmware-1.log
-rw------- root/root 0 2009-08-04 17:05 QNX641_xxx/QNX_641_xxx.vmsd
-rwxr-xr-x root/root 2037 2009-08-04 17:05 QNX641_xxx/QNX_641_xxx.vmx
-rw-r--r-- root/root 240400 2009-08-04 17:05 QNX641_xxx/vmware.log
-rw------- root/root 2147483648 2009-08-04 17:06 QNX641_xxx/QNX_641_xxx-flat.vmdk
No comments:
Post a Comment