-
15th Jun, 2007No Comments
Originally, it was possible to access the QEMU console from within a VNC viewer window, by pressing Ctrl-Alt-1. Since this made for a major security breach - users are able to mount any file on Dom0 this way, the feature has been disabled in recent Xen releases. That makes for a major problem, since mounting, ejecting and changing CD’s in Windows seems only possible by rebooting the Virtual Machine.
After a bit of trial and error, we came to a solution that allows the mounting and ejecting of CD’s from within Windows:
In your Xen guest config file, you must specify an empty CD device - since without it Windows will fail to recognize a CD-rom device:
disk=['phy:/dev/...,ioemu:hda,w',',hdc:cdrom,r']Mounting a CD-rom
Execute xm block-list to view the configured bloack devices for your Xen guest:
# xm block-list <vm-id> –long
(768
((backend-id 0)
(virtual-device 768)
(device-type disk)
(state 1)
(backend /local/domain/0/backend/vbd/1/768)
)
)
(5632
((backend-id 0)
(virtual-device 5632)
(device-type cdrom)
(state 1)
(backend /local/domain/0/backend/vbd/1/5632)
)
)Note the cdrom’s device number and detach it from the guest. Use the –force switch, else detaching will fail.
# xm block-detach 1 5632 -fNow reattach the device with the correct path specified ( phy:/dev/cdrom, file:/path/to/some/iso, … ):
# xm block-attach 1 phy:/dev/cdrom /dev/hdc rUnmounting a CD-rom
Eject the cdrom from Windows by right-clicking on its icon and selecting ‘Eject’.
Eject the cdrom physically from Dom0 if needed:
# eject /dev/cdromRemounting a CD-rom
Now’s the fun part: it appears that if you try to remount exactly the same backend device, e.g. /dev/cdrom, the Windows HVM guest will not be signalled that a new device has been inserted. A workaround for this is to attach and to detach another device first - any will do, as long as it’s different:
# xm block-attach 1 phy:/dev/sda /dev/hdc r
# xm block-detach 1 5632 -fThen attach your new device:
# xm block-attach 1 phy:/dev/cdrom /dev/hdc r -
7th Jun, 2007No Comments
Since XenServer and XenEnterprise do not support installing the operating system on an MD software RAID device during the installation, you’ll have to undertake a few steps afterwards if you want to mirror your boot disks.
This article is largely based on Harry de Jong’s solution, as posted on the XenSource forums, with a few differences:
- There’s no need to copy mdadm.static from another server to the Xen host;
- The initrd ramdisk’s configuration is a bit simpler;
- There’s no need to swap the physical disks, which means the procedure can be accomplished remotely.
Create identical partitions to your boot disk /dev/sda on your second disk /dev/sdb
If /dev/sda looks like this:
# fdisk -l /dev/sdaDisk /dev/sda: 249.3 GB, 249376538624 bytes
255 heads, 63 sectors/track, 30318 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 499 4008186 83 Linux
/dev/sda2 500 998 4008217+ 83 Linux
/dev/sda3 999 30318 235512900 83 Linux/dev/sdb should look like this:
# fdisk -l /dev/sdbDisk /dev/sdb: 249.3 GB, 249376538624 bytes
255 heads, 63 sectors/track, 30318 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sdb1 * 1 499 4008186 fd Linux raid autodetect
/dev/sdb2 500 998 4008217+ fd Linux raid autodetect
/dev/sdb3 999 30318 235512900 fd Linux raid autodetectDo not forget to set the partition type to ‘fd’ (Linux RAID autodetect) instead of the default 83 (Linux).
Create the necessary device nodes
# mknod /dev/md0 b 9 0
# mknod /dev/md1 b 9 1
# mknod /dev/md2 b 9 2Create your MD RAID 1 arrays (with missing disks)
# mdadm –create /dev/md0 –level=1 –raid-devices=2 /dev/sdb1 missing
# mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sdb2 missing
# mdadm –create /dev/md2 –level=1 –raid-devices=2 /dev/sdb3 missing/dev/sda2 is just an empty, unmounted partition used by XenServer for upgrades.
Copy the Xen Storage Manager data over to RAID
# pvcreate /dev/md2
# vgextend VG_XenStorage-3553b468-fca7-46c0-baeb-7cd471a6a9ab /dev/md1
# pvmove /dev/sda3 /dev/md2Replace the uuid in the vgextend line above with the uuid of your own Xen SR. Use ’sm info’ to display your SR’s uuid.
Remove /dev/sda3 from the SR volume group and add it to the RAID array
# vgreduce VG_XenStorage-3553b468-fca7-46c0-baeb-7cd471a6a9ab /dev/sda3
# pvremove /dev/sda3
# mdadm -a /dev/md2 /dev/sda3Mount /dev/md0 and copy the filesystem to it
# mkfs.ext3 /dev/md0
# mount /dev/md0 /mnt
# cd /
# cp -axv . /mntMake a new initrd ramdisk containing the MD RAID drivers
Modify /mnt/etc/fstab so the system will mount / from /dev/md0 instead of LABEL=/-main. Replace "LABEL=/-main" by "/dev/md0".
Create a new boot image and uncompress it:
# mkdir /mnt/root/initrd-raid
# mkinitrd –fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img 2.6.16.38-xs3.2.0.531.3960xen
# cd /mnt/root/initrd-raid
# zcat initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img | cpio -iSince mkinitrd looks at /etc/fstab to determine what device the root volume is on, it has now added the necessary raid drivers to the new boot image.
Uncompress the current ramdisk and add the raid drivers to it
# mkdir /root/initrd
# cd /root/initrd
# zcat /boot/initrd-2.6.16.38-xs3.2.0.531.3960xen.img | cpio -iNow add the raid module from the new ramdisk and modify the init file:
# cp /root/initrd-raid/lib/raid1.ko lib
# vi initAdd the following lines before the second line containing "/sbin/udevstart":
echo "Loading raid1.ko module"
insmod /lib/raid1.koAdd the following lines before the line containing "echo Creating root device":
raidautorun /dev/md0
raidautorun /dev/md1
raidautorun /dev/md2Note: if you’ve created other MD raid devices, add a ‘raidautorun’ statement for them as well.
Copy the new ramdisk to the /mnt/boot folder and add modify GRUB’s boot menu
# find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img
# rm /mnt/boot/initrd-2.6-xen.img
rm: remove symbolic link `/mnt/boot/initrd-2.6-xen.img’? y
# ln -s initrd-2.6.16.38-xs3.2.0.531.3960xen-raid.img /mnt/boot/initrd-2.6-xen.img
# vi /mnt/boot/grub/menu.lstReplace "root=LABEL=/-main" by "root=/dev/md0" in all menu entries.
Unmount /dev/md0
# cd /root
# umount /dev/md0
# syncSet up the Master Boot Record on /dev/sdb
# grubgrub> device (hd0) /dev/sdb
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfdgrub> setup (hd0)
Checking if "/boot/grub/stage1" exists… yes
Checking if "/boot/grub/stage2" exists… yes
Checking if "/boot/grub/e2fs_stage1_5" exists… yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"… 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
/boot/grub/grub.conf"… succeeded
Done.grub> quit
Modify GRUB’s boot menu to boot from the second disk
# vi /boot/grub/menu.lstReplace the line in the first XenServer entry that says "root (hd0,0)" with "root (hd1,0)". Also replace "root=LABEL=/-main" by "root=/dev/md0" in all menu entries. This will allow you to boot from /dev/md0 instead of /dev/sda. In case something goes wrong, you could always reboot using one of the other entries, which still point to /dev/sda.
Reboot
# shutdown -r nowIf all goes well, you should see your system mounting /dev/md0 as the filesystem root. If not, reboot using one of the other GRUB menu entries and check out the previous steps.
Change /dev/sda’s partition types from Linux to Linux RAID autodetect
# fdisk /dev/sdaThe result should be something like this:
Disk /dev/sda: 249.3 GB, 249376538624 bytes
255 heads, 63 sectors/track, 30318 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sda1 * 1 499 4008186 fd Linux raid autodetect
/dev/sda2 500 998 4008217+ fd Linux raid autodetect
/dev/sda3 999 30318 235512900 fd Linux raid autodetectAdd the missing partitons to the RAID arrays
# mdadm -a /dev/md0 /dev/sda1
mdadm: hot added /dev/sda1
# mdadm -a /dev/md1 /dev/sda2
mdadm: hot added /dev/sda2
# mdadm -a /dev/md2 /dev/sda3
mdadm: hot added /dev/sda3Then wait for the sync to complete:
# watch cat /proc/mdstatCopy the running RAID setup to /etc/mdadm.conf
# mdadm –detail –scan >> /etc/mdadm.confBe sure to add a line ‘DEVICE partitions’ at the top of /etc/mdadm.conf if you want to define MD devices that span a whole disk instead of just a partition. Without this line, MD won’t be able to detect your drives as MD components at boot.
That’s it!







