Windows DHCP server problem on Xen VM hosts

Posted by Christian Ashby on May 6, 2010

If your XenServer hosted Windows DHCP server(s) are running on the same physical host as linux DHCP clients, then they will not receive a DHCP address.

To work around this problem, turn off checksum offloading on the network adapter. To do this, follow these steps:

  • Click Start, click Run, type regedit, and then click OK.
  • Locate and then click the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  • In the right pane, make sure that the DisableTaskOffload registry entry exists. If this entry does not exist, follow these steps to add the entry:
    • On the Edit menu, point to New, and then click DWORD value.
    • Type DisableTaskOffload, and then press ENTER.
    • Click DisableTaskOffload.
    • On the Edit menu, click Modify.
    • Type 1 in the Value data box, and then press ENTER.
    • Exit Registry Editor.

Note that this doesn’t effect Open-Source Xen as it is specifically related to the XenServer-supplied PV drivers.


 

Remote desktop ‘Exceeded the number of connections’

Posted by Christian Ashby on May 4, 2010

You can optionally connect to the ‘console’ which is a screen 0 (by default screens 1 and 2 are the screens you connect to with a remote desktop client). This option is not in the Windows UI, you need to use the following command from Start->Run:

mstsc -v:{machine address} /f -console

Windows Vista / Windows 7 use the syntax /admin rather than -console.

If you use a mac, you can put /console at the end of the machine name in the machine box.

If you use linux and rdesktop then add -0 to the rdesktop command line.


 

BASH if statements: ‘too many arguments’ error

Posted by Christian Ashby on April 28, 2010

If you are writing a BASH script which searches for a file pattern in a folder using this syntax:

[-f {pattern}]

Instead, use the following syntax:

files=$(ls {pattern} 2> /dev/null | wc -l)
if [ "$files" != "0" ]

This can be replaced with a similar command using find if required.


 

Debian: apt-get interrupted, leaves files in bad state

Posted by Christian Ashby on April 19, 2010

For those using Debian or Ubuntu Linux, there are situations where the package management system can leave files open if a certain package fails, or if you cancel the installation using CTRL+C, you may see the following error when you try another package installation:

debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable

Using the following command will tell you what’s using it:

fuser -v /var/cache/debconf/config.dat

This will give you the process ID in the right-hand column. You can then use kill {process ID} to remove this process and re run your apt-get command.


 

Converting open-source Xen Windows VMs to XenServer

Posted by Christian Ashby on April 13, 2010

A number of people are looking to migrate from the open-source Xen to Citrix XenServer itself, and it’s not immediately obvious how to migrate Windows VMs between the two platforms. Citrix have a tool called ‘XenConvert’ designed to move machines between environments, and the way you can use this to move from open-source Xen is as follows:

  • Download XenConvert from the Citrix downloads centre.
  • Add a virtual disk to the guest machine (at least twice the size of the existing disk) to receive the exported VM.
  • Run the original guest machine and partition / format the new virtual disk (NTFS / FAT, as long as you can mount these filesystems in the host).
  • Install & Run XenConvert on the source guest machine.
  • Select ‘XVA’ and select the new virtual disk as the destination for the XVA image.
  • Shut down the source guest machine.
  • Work out where the new virtual partition starts – something like this:
    root@host:/etc/xen# parted /dev/host-vm/name-XVA
    GNU Parted 1.7.1
    Using /dev/mapper/host--vm-name--XVA
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) unit B
    (parted) print
    
    Disk /dev/mapper/host--vm-name--XVA: 26843545599B
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start   End           Size          Type     File system  Flags
    1      32256B  26839088639B  26839056384B  primary  ntfs
  • Mount the new virtual disk – change ‘offset’ to be the value in the Start column above, replace ntfs with vfat if FAT32 was used:
    mount -o ro,offset=32256 -t ntfs /dev/host-vm/name-XVA /mnt/t
  • Copy the *.xva folder from this mounted drive to somewhere accessible to the new XenServer host.
  • Run XenCenter on a machine and connect to the new host.
  • Import a new VM, select the ova.xml file from the *.xva folder, and follow the import – you’ll need to setup a new Network Interface.
  • If required, reactivate Windows on the new guest as it starts up, and install XenServer Tools.

 

Oracle XE: Clearing out unwanted trace files

Posted by Christian Ashby on April 9, 2010

If left unchecked, Oracle XE installations can balloon in size quite quickly – this is due to the trace files being written by the server. The following run in a cron script can be used to remove files more than 7 days old.

#!/bin/bash
find $ORACLE_HOME/../../../admin/$ORACLE_SID/bdump -name "*.trc" -mtime +7 -exec rm "{}" \;
find $ORACLE_HOME/../../../admin/$ORACLE_SID/udump -name "*.trc" -mtime +7 -exec rm "{}" \;
find $ORACLE_HOME/../../../admin/$ORACLE_SID/cdump -name "*.trc" -mtime +7 -exec rm "{}" \;

This tip was found and modified for XE in the following a useful article ‘Oracle Linux – Using the “find” command to manage files’.


 

Blocking Internet Explorer updates

Posted by Christian Ashby on April 2, 2010

If you are developing websites, or simply don’t want to change browsers, you can stop Microsoft automatic update from installing IE 7 or IE 8 by installing the following updates from Microsoft:

Once run, they will extract files to the location of your choice, then you have to use an elevated command prompt and run the command with a /B switch (block) as follows:

IE70Blocker.cmd /B

You can revert to the normal state (allowing Microsoft / Windows Update to replace your browser) as follows:

IE70Blocker.cmd /U

Note that in order to keep IE6 you need to run both 7 and 8 blockers.

Then, you can keep your system completely up to date whilst maintaining the old-school browsers!


 

Linux: Arrow keys don’t work?

Posted by Christian Ashby on March 26, 2010

Some Linux applications such as sqlplus still use readline to read what you type, which doesn’t properly support arrow keys, home, end, etc in most terminals.

You can fix this with a small wrapper called rlfe (for older Ubuntu/Debian variants) or rlwrap (for RedHat and most new distributions).

Once installed (apt-get install rlwrap for Debian/Ubuntu) you can enable it by default for your user by doing the following:

echo "alias {command}='rlwrap {command}'" >> ~/.bashrc
source ~/.bashrc

 

Linux and Seagate FreeAgent Drives

Posted by Christian Ashby on March 24, 2010

If you’ve bought a Seagate FreeAgent drive with a view to running it on Linux, be aware that it won’t necessarily work out-of-the-box.

The issue is that after about 1min of use the drive spins down and closes the USB connection, causing mounts to fail and the device to be unusable.

It turns out that the drives include some cunning/annoying (delete as applicable) power saving logic which only correctly works in Windows. The solution is to run the following command as root as soon as the drive is plugged in.

sdparm -clear STANDBY -6 /dev/sdX

If you use your drive regularly then you can make this command run whenever the drive is used, by editing the file /etc/udev/rules.d (you can create the file if it doesn’t exist) and adding the following line:

SUBSYSTEMS=="scsi",DRIVERS=="sd",ATTRS{vendor}=="Seagate*",ATTRS{model}=="FreeAgent*",RUN+="/bin/sh
-c 'echo 1 > /sys/class/scsi_disk/%k/allow_restart'"

 

Windows: Linking files and folders

Posted by Christian Ashby on March 13, 2010

At first glance it may not be obviously useful, but if you need to link one folder to another, or store a file somewhere else but refer to it within a different folder, you can do so by the very useful mklink command, available in Windows 7 and Vista. There is an alternative for Windows 2000 and XP called ‘junction‘.

To create links, simply open a command prompt (Start->Run->cmd), and type:

  • For files: mklink {destination} {target}
  • For folders: mklink /d {destination} {target}

Note that it may be necessary to become admin to link some files / folders.