Xenserver nested

Disclaimer done, lets start to play: To enable nested virtualization, go to the XenServer console (e.g. in XenCenter) and find out the UUID of the VM you want to permit being a virtualization host:

# xe vm-list

Go through the list and remember the first characters of your VM´s UUID. After making sure the VM is powered down, turn on nested hardware virtualization. Enter your VM’s UUID instead of <UUID>. After typing the first characters, you can hit TAB to auto-complete:

# xe vm-param-set uuid=<UUID> platform:exp-nested-hvm=true

Boot the VM and check if the virtual processor reports hardware virtualization (“vmx”) capabilities. In Linux this might look like this:

# cat /proc/cpuinfo 
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
[…]
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 smep bmi2 erms invpcid
[…]

XENSERVER6.5 0 安裝 LINUX AGENT TOOLS

  • mount /dev/cdrom /mnt
  • bash /mnt/Linux/install.sh
  • umount /dev/cdrom

    1. The files required are present on the built-in xs-tools.iso CD image, or alternatively can be installed

by using the VM > Install XenServer Tools option in XenCenter.
2. Mount the image onto the guest by running the command:
mount -o ro,exec /dev/disk/by-label/XenServer\\x20Tools /mnt
Note:
If mounting the image fails, you can locate the image by running the following:
blkid -t LABEL="XenServer Tools"
3. Execute the installation script as the root user:
/mnt/Linux/install.sh
4. Unmount the image from the guest by running the command:
umount /mnt
5. If the kernel has been upgraded, or the VM was upgraded from a previous version, reboot the VM now.
Note:
CD-ROM drives and ISOs attached to Linux Virtual Machines appear as devices, such as /
dev/xvdd (or /dev/sdd in Ubuntu 10.10 and later) instead of as /dev/cdrom as you
might expect. This is because they are not true CD-ROM devices, but normal devices. When
the CD is ejected by either XenCenter or the CLI, it hot-unplugs the device from the VM
and the device disappears. This is different from Windows Virtual Machines, where the CD
remains in the VM in an empty state.

XenServer 移除 local storage

1. log in to your xenserver host via ssh

Use your favourite SSH program I prefer using  MTPuTTY myself.

2.List your storage repositories.

type xe sr-list to get the UUID from the local share you want to remove.

You will see something like this:

uuid ( RO) : 62aac8ce-f974-9ecc-5a6f-6e601fcef97a
name-label ( RW): Local storage
name-description ( RW):
host ( RO): xenghetto.sitedevelopments.local
type ( RO): lvm
content-type ( RO): user

uuid string is the Storage Repository uuid (SR-uuid) that you need to be able to do the next step.

name-label This is the name of the local storage so check if that corresponds to the local storageyou want to detach before you go to the next step.

Step 3. Get the Physical Block Device UUID.

Now it’s time to get the Physical Block Device (PBD):

You find that by typing:  xe pbd-list sr-uuid=Your-UUID

[root@xenghetto # xe pbd-list sr-uuid=62aac8ce-f974-9ecc-5a6f-6e601fcef97a
uuid ( RO)                  : 47127040-7e77-749c-ce24-49d33b9df232
host-uuid ( RO): 4b3c5ae2-6b22-4972-bea5-9467b25f519d
sr-uuid ( RO): 62aac8ce-f974-9ecc-5a6f-6e601fcef97a
device-config (MRO): device: /dev/disk/by-id/scsi-SATA_INTEL_SSDSC2CT0CVMP2156091M060AGN-part3
currently-attached ( RO): true

uuid ( RO) This is the PBD-uuid write this down and lets unplug the local storage.

Step 4. Unplug the local storage.

To unplug the local storage you type the following:

xe pbd-unplug uuid=Your-PBD-uuid

In my case it’s:

xe pbd-unplug uuid=47127040-7e77-749c-ce24-49d33b9df232

it should now be unplugged. you can check that in xencenter.

Step 5.Delete the PBD:

xe pbd-destroy uuid=your-PBD-uuid

in my case it’s

xe pbd-destroy uuid=47127040-7e77-749c-ce24-49d33b9df232

if you go to xencenter you will now see that it’s fully detached:detached localstorage

6. Forget ( remove ) the Local storage from showing up as detached.

xe sr-forget uuid=your-SR-uuid

xe sr-forget uuid=62aac8ce-f974-9ecc-5a6f-6e601fcef97a

Now check your XenCenter that it’s removed.

done-removing-localstorage

Xenserver 的那些事

1.用命令列設定 VM 記憶體
xe vm-memory-limits-set uuid="UUID of your VM" static-min=1073741824 dynamic-min=1073741824 dynamic-max=1073741824 static-max=1073741824

2.新增一顆空白硬碟
# ll /dev/disk/by-id
#
xe sr-create content-type=user device-config:device=/dev/disk/by-id/scsi-SATA_QEMU_HARDDISK_QM00002 host-uuid=984d9af1-9924-4a66-a535-a3819e1e1341 name-label="Local storage 2" shared=false type=ext

3.自動啟動VM

Xenserver添加存在資料的第二顆硬碟

  • Do a pvscan to get the Universally Unique Identifier (UUID) of an existing SR on a local disk. This example uses UUID 39baf126-a535-549f-58d6-feeda55f7801:# pvscan
    PV /dev/sda3 VG VG_XenStorage-39baf126-a535-549f-58d6-feeda55f7801 lvm2 [66.87 GB / 57.87 GB free]
    Total: 1 [66.87 GB] / in use: 1 [66.87 GB] / in no VG: 0 [0 ]
  • Note the output above, the VG name of the local drive /dev/sda3 is VG_XenStorage-39baf126-a535-549f-58d6-feeda55f7801 . The VG name contains the SR UUID that resides on this storage media. In this case, the UUID is 39baf126-a535-549f-58d6-feeda55f7801.
  • Introduce the SR with the following command:# xe sr-introduce uuid=39baf126-a535-549f-58d6-feeda55f7801 type=ext name-label=”Local storage” content-type=user
    This command sets up database records for the SR named “Local storage”.
  • Locate the SCSI ID of the device or partition where the SR data is stored:
    # ls -l /dev/disk/by-id/

    total 0
    lrwxrwxrwx 1 root root 9 Jan 15 09:44 scsi-SATA_ST3500320AS_9QM13WP2 -> ../../sdb
    lrwxrwxrwx 1 root root 10 Jan 15 09:44 scsi-SATA_ST3500320AS_9QM13WP2-part1 -> ../../sdb1
    lrwxrwxrwx 1 root root 9 Jan 15 09:44 scsi-SATA_ST380815AS_6QZ5Z1AM -> ../../sda
    lrwxrwxrwx 1 root root 10 Jan 15 09:44 scsi-SATA_ST380815AS_6QZ5Z1AM-part1 -> ../../sda1
    lrwxrwxrwx 1 root root 10 Jan 15 09:44 scsi-SATA_ST380815AS_6QZ5Z1AM-part2 -> ../../sda2
    lrwxrwxrwx 1 root root 10 Jan 15 09:44 scsi-SATA_ST380815AS_6QZ5Z1AM-part3 -> ../../sda3

    In this case, the SCSI ID of the device /dev/sda3 is scsi-SATA_ST380815AS_6QZ5Z1AM-part3. This is the device name to use in the next command, where a PBD (physical block device – a connector between the XenServer host and the SR) is created.

  • Run the xe host-list command to find out the host UUID for the local host:
    # xe host-list

    uuid ( RO) : 83f2c775-57fc-457b-9f98-2b9b0a7dbcb5
    name-label ( RW): xenserver1
    name-description ( RO): Default install of XenServer
  • Create the PBD using the device SCSI ID, host UUID and SR UUID detected above:
    # xe pbd-create sr-uuid=39baf126-a535-549f-58d6-feeda55f7801
    device-config:device=/dev/disk/by-id/scsi-SATA_ST380815AS_6QZ5Z1AM-part3 host-uuid=83f2c775-57fc-457b-9f98-2b9b0a7dbcb5
    aec2c6fc-e1fb-0a27-2437-9862cffe213e
  • Attach the PBD created with xe pbd-plug command:
    # xe pbd-plug uuid=aec2c6fc-e1fb-0a27-2437-9862cffe213e
    The SR should be connected to the XenServer host and be visible in XenCenter.