====== Virtual Computers ======
pegasus is the virtual machine host
===== permissions =====
Access to images on the nfs volume must have permissions set to at least allow directory access (x) for all users. This is because the files on the NFS cannot be set to local account for users or groups.
===== selinux =====
http://docs.fedoraproject.org/en-US/Fedora/13/html/Virtualization_Guide/sect-Virtualization-Security_for_virtualization-SELinux_and_virtualization.html
setbool virt_use_nfs on
for persistent settings
setsebool -P virt_use_nfs on
http://docs.fedoraproject.org/en-US/Fedora/13/html/Virtualization_Guide/sect-Virtualization-Security_for_virtualization-SELinux_considerations.html
semanage fcontext -a -t virt_image_t "/opt/libvirt/(/.*)?"
restorecon -R -v /opt/libvirt
===== sec503 image =====
https://help.ubuntu.com/community/KVM/FAQ
First convert the vdk to xml. I used Ubuntu and
$ vmware2libvirt -f ./file.vmx > file.xml
$ virsh -c qemu:///system define file.xml
then create a single vmdk file using
vmware-vdiskmanager -r Packetrix503-single.vmdk -t 0 Packetrix503.qcow2
from a vmware-server install. I did not run the configure.pl script when installing VMware since I was not going to run VMware itself.
Then convert to qcow2
qemu-img convert Packetrix503-single.vmdk -O qcow2 Packetrix503.qcow2
http://libvirt.org/drvesx.html
Edit the /etc/libvirt/qemu/Packetrix503.xml file to have the proper disk image location and type
To re-load the new xml file without service libvirtd reload, use
virsh -c qemu:///system define /etc/libvirt/qemu/Packetrix503.xml
http://serverfault.com/questions/287070/how-to-mount-virtual-machines-lvm-partition-on-kvm-host
To mount the vmdk image, convert to flatten the vmdk's using vmware-vdiskmanager as shown above, convert to qcow2 using "qemu-image convert" as shown below then let mapper know about the image using kpartx
qemu-img convert -f qcow2 Packetrix503.qcow2 -O raw Packetrix503.img
kpartx -av Packetrix503.img
mount /dev/mapper/loop1p1 /mnt
===== slow nfs attribute lookup during large writes =====
https://bugzilla.redhat.com/show_bug.cgi?id=688232
/proc/sys/vm/dirty_bytes and /proc/sys/vm/dirty_ratio control how much memory it used for write before being flushed to disk.
Apply this command to pegasus, or machines with a lot of RAM
cat /proc/sys/vm/dirty_ratio
cat /proc/sys/vm/dirty_bytes
echo 268435456 >>/proc/sys/vm/dirty_bytes
cat /proc/sys/vm/dirty_ratio
cat /proc/sys/vm/dirty_bytes
===== Prepare and update .img file for imaging =====
* ssh into pegasus, su up to root
* run virt-manager (making sure that xming or xquarts is running)
* Turn on and open the Win7Deploy2012 Virtual Machine (DON'T start Win7Deploy2012Sysprep yet)
* Update windows, third party apps, and (if needed for raid card) inject raid drivers using pnputil -a
* While updating do not install Symantec or Identity Finder, these will com in through GPO
* After finished updating, shutdown Win7Deploy2012 VM
* open pegasus root shell window and cd to /mnt/libvirt
''# cd /mnt/libvirt''
* Then list the files
''# ls -l''
* Then copy the Win7Deploy2012.img over top of Win7Deploy2012Sysprep.img and replace =yes
''# cp Win7Deploy2012.img Win7Deploy2012Sysprep.img''
* and add permissions to write to it
''# chmod g+w Win7Deploy2012Sysprep.img''
* Then go back to virt-manager window and startup the Win7Deploy2012Sysprep VM
* Log into it and open an Administrator cmd prompt
* type what is below (slashes matter)
''# C:\Windows\System32\sysprep\sysprep.exe /oobe /generalize /shutdown''
* Once VM has shutdown, go back to pegasus root shell window and remove perm's for group to write to the file
''# chmod g-w Win7Deploy2012Sysprep.img''
* You are now ready to dd the image onto multiple computers :)
===== Copy .img file to hardware =====
* The virtual machine image file must be a disk image(.img), not qcow2 or vdk
* Network boot into Linux.
* Check the device id of the target disk.
# blkid
or
# fdisk -l
dd the computers hard drive with zero's to wipe out previous partition, if necessary
# dd if=/dev/zero of=/dev/sda bs=4M
Then copy the .img file from the virtual host to
# ssh @pegasus.aoe.vt.edu 'cat /mnt/libvirt/Win7Deploy2012Sysprep.img' | cat > /dev/sda
or
# ssh @pegasus.aoe.vt.edu "dd if=/mnt/libvirt/Win7Deploy2012Sysprep.img' | dd of=/dev/sda
* Reboot the newly imaged machine.
* expand the disk using disk manager.
* Run Windows Update
* Install vendor drivers
===== Copy partion to .img file on pegasus =====
This will take the partition off of a hard drive that you want in .img form and copy up to 45GB's of data and put it in an .img file so that you can use it in a VM
# dd if=/dev/sda bs=1M count=45000 | ssh jspence@pegasus.aoe.vt.edu 'cat > /mnt/libvirt/Win8tablet2.img'
===== Bridge network =====
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Virtualization/sect-Virtualization-Network_Configuration-Bridged_networking_with_libvirt.html
or
http://wiki.libvirt.org/page/Networking
ifcfg-eth0 defines the physical network interface which is set as part of a bridge:
DEVICE=eth0
# change the hardware address to match the hardware address your NIC uses
HWADDR=00:16:76:D6:C9:45
ONBOOT=yes
BRIDGE=br0
ifcfg-br0 or similar. The br0 is the name of the bridge, this can be anything as long as the name of the file is the same as the DEVICE parameter.
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
IP address configuration, be it dynamic or static, should be configured on the bridge itself (for example, in the ifcfg-br0 file). Network access will not function as expected if IP address details are configured on the physical interface that the bridge is connected to.
Configure iptables to allow all traffic to be forwarded across the bridge.
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
# service iptables save
# service iptables restart
===== commands =====
# virsh -c qemu:///system list
Id Name State
----------------------------------
3 Win2K8Symantec running
6 Win2K8IDFinder running
===== Snapshots =====
==== lvm snapshot ====
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/snapshot_command.html
Create an lvm snapshot on a partition for the snapshot
lvcreate -L800G -s -nlibvirtbackup /dev/vg_pegasus_libvirt/pegasus_libvirt
Mount it somewhere
mount /dev/vg_pegasus_libvirt/libvirtbackup /mnt/libvirt-snapshot/
Copy the snapshot to a backup media somehow
Use this command to monitor the snapshot space
lvs
or
lvdislay
Then remove the snapshot
umount /mnt/libvirt-snapshot/
lvremove /dev/vg_pegasus_libvirt/libvirtbackup
==== qemu-img snapshots ====
qemu-img snapshot -c $(snapshot-name) $(image file)
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/sect-Virtualization-Tips_and_tricks-Using_qemu_img.html
Snapshot
List, apply, create, or delete an existing snapshot (snapshot) of an image (filename).
# qemu-img snapshot [ -l | -a snapshot | -c snapshot | -d snapshot ] filename
-l lists all snapshots associated with the specified disk image. The apply option, -a, reverts the disk image (filename) to the state of a previously saved snapshot. -c creates a snapshot (snapshot) of an image (filename). -d deletes the specified snapshot.
====== Shop Mastercam computer ======
Computer name: VirtualXP-23999
User Name: XPMUser
Password: mooney
====== virsh commands to determine vnet used ======
Use this command to get the id of each running host
virsh list
virsh list [ --all | --inactive ]
then us the id to dump the xml for the host and grep for interface and print the following 6 lines
virsh dumpxml | grep -A 6 \