Showing posts with label proxmox. Show all posts
Showing posts with label proxmox. Show all posts

Friday, January 16, 2015

Scripting user passwords in Proxmox 3.3

Proxmox has had a bug in their pveum code for some time now in that it won't let you directly script the user passwords when adding a user, or when changing a user's password. The usage info SAYS you can give passwords on the command line, but it doesn't work.

Well, I figured out a workaround. After realizing that pveum is a perl script, I found this post at this post at perlmonks.org which led me to make a small change to the line which reads the password to allow for redirected text to be accepted.

The change is in a subroutine beginning with "my $read_password = sub {" (line 49 on my system) to accept redirection. The blue is from the original file, the red reflects my change.

# diff pveum.original pveum.fixed
49c49
<     my $term = new Term::ReadLine ('pveum');
---
>     my $term = new Term::ReadLine ('pveum', \*STDIN, \*STDOUT);

So now I can update a password by redirecting the password string from Bash.

# printf "mypassword\nmypassword\n" | pveum passwd myuser@pve

Friday, March 14, 2014

Proxmox: Use external VNC without inetd

Alex Harris on his blog gives a method for using external VNC viewer by modifying the VM configuration file as opposed to the INETD configuration which is what I typically see. Note: I have not yet tested this to ensure it works.

... go to the /etc/pve/nodes/proxmox/qemu-server directory. In the 1##.conf file (where 1## is the id of the VM), put the following lines:
args: -vnc 0.0.0.0:10
You can do this with each vm, just make sure the change the number after the last colon, as
each vnc connection has to be on it's own port. Then you can vnc using your favorite vnc viewer, and use the ip address/hostname of the proxmox server followed by a : and the number that's at the end of the line you put in the VM's config file. In this case it would be "vncviewer proxmox-machine:10"

Wednesday, February 27, 2013

Easy conversion from VMDK to Proxmox

I kind of stumbled on this accidentally, but it has worked in the one instance in which I have tried it so far.

Proxmox uses KVM/QEMU for virtualization and stores disk images in raw format. Converting from a VMDK to a raw format is simple:

$ qemu-img convert -f vmdk my-vmdk.vmdk -O raw my-raw-image.raw


You can check the format if you like:

$ qemu-img info my-raw-image.raw 
image: my-raw-image.raw
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: 1.8G

However Proxmox as far as I can tell has no method for simply choosing a virtual drive to use for a VM. So you have to create a VM (not a VZ container) using the regular Proxmox web interface (choose "no media" for the installation step since we won't be installing anything), then replace the raw image created for the new VM with the one created in the step above.

$ scp my-raw-image.raw root@PROXMOX-IP:/var/lib/vz/data/images/VM_ID/vm-VM_ID-disk-1.raw

In my instance this would be basically:

$ scp my-raw-image.raw root@192.168.1.100:/var/lib/vz/data/images/104/vm-104-disk-1.raw


The particularities here can change, so its probably better to ssh to the Proxmox server yourself and make sure the file/folder names are what you expect.

Anyway after this process I booted my VM, and it came right up, although it did inform me that I needed to run fsck (disk checker).

Note: If your virtual machine image has multiple partitions, I have no idea what you need to do, but take a look here for ideas, though the actual steps didn't work for me.