mail me! sindicaci;ón

Archive for Linux

VMware tools installation on OpenMediaVault on ESX

I recently setup an OpenMediaVault VM after finding that both FreeNAS and OpenFiler weren’t up to this specific job. VMware tools installation was pretty easy – OMV uses Debian so it’s just a matter of apt-getting the requisite packages:

#> uname -a
Linux archos 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64 GNU/Linux
#> apt-cache search headers | grep 2.6.32-5
linux-headers-2.6.32-5-all-amd64 – All header files for Linux 2.6.32 (meta-package)

#> apt-get install build-essential linux-headers-2.6.32-5-all-amd64

The interesting part was the fact that VMware tools (i.e. vmware-tools-config.pl) refused to use the gcc included in the build-essential meta package. The kernel headers package included (or rather recommended) gcc 4.3, which VMware tools had no issue with.

Ubuntu, pptpd and the iPhone

I’ve got a (fake – i.e. OpenVZ) VM with BHost.net and use it as a VPN gateway amongst other things for accessing my home network. This works great with OpenVPN in a site-to-site configuration – I use a port knocking app on my iPhone to open up a port for SSH on the VM, shell in using a cert, and then from there I can access my home network via the site-to-site OpenVPN link. Alternatively if I’m after more than SSH, I knock again, connect via OpenVPN to the VM and then access the internal network across the tunnel.

This works great for PCs/Macs – but it’s no good for my iPhone/iPad which don’t have support for OpenVPN unless you jailbreak. So reluctantly I setup PPTP this evening, and when trying to connect the iPhone was telling me that it “Cannot connect. Contact your system administrator.” or words to that effect. On the server I was seeing this error logged in /var/log/messages:

Jan 6 23:00:51 orbit pppd[9820]: Using interface ppp0
Jan 6 23:00:51 orbit pppd[9820]: Connect: ppp0 <–> /dev/pts/1
Jan 6 23:00:51 orbit pppd[9820]: LCP terminated by peer (MPPE required but peer negotiation failed)
Jan 6 23:00:51 orbit pppd[9820]: Hangup (SIGHUP)
Jan 6 23:00:51 orbit pppd[9820]: Modem hangup
Jan 6 23:00:51 orbit pppd[9820]: Connection terminated.

A quick bit of Googling and I worked out that you had to have both of these lines in your /etc/ppp/pptpd-options file:

require-mschap-v2
require-mppe-128

(128-bit encryption requires MS-CHAPv2…)

Et voila!

Installing Java EE SDK in Ubuntu 11.04

If you’re trying to install the J2EE SDK in 11.04 and it’s getting stuck at 45%, cancel the installation, restart it, and untick ‘Install Update Tool’. :)

(As a side note – it’s ridiculous that you can’t install Java EE SDK without having X11 installed, i.e. you can’t do a command line only installation).

Netgear MA401, WPA2, and Debian.

This post has been saved as a draft for a long time, and unfortunately I can’t remember the exact specifics. I’m publishing just in case it (albeit in a very rough, unfinished form) may help someone!

For the past couple of days I’ve been trying to get the Netgear MA401 wireless card working with my WPA2 secured wireless network.

In order to do this, yo

Stop the PCMCIA card from using IRQ3 by putting the following line in /etc/pcmcia/config.opts

exclude irq 3

Install hostap-utils, which should automatically blacklist the orinoco drivers:

apt-get install hostap-utils

If after a lsmod | grep orinoco they’re still in use, blacklist the orinico modules within /etc/modprobe.d/blacklist:
blacklist orinoco
blacklist orinoco_cs

The hostap modules should be automatically loaded. If not, run:

modprobe hostap_cs

If you do a iwconfig, you should see a wlan1 and a wifi0. The fact that udev has renamed it from wlan0 to wlan1 will cause problems with the prism2_srec program we’ll use to flash the card later, so change the device name by editing /etc/udev/rules.d/70-persistent-net.rules

# PCMCIA device 0×7300:0x000b (hostap_cs)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:09:5b:28:0b:48″, ATTR{type}==”1″, KERNEL==”wlan*”, NAME=”wlan1″

# PCMCIA device 0×7300:0x000b (hostap_cs)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:09:5b:28:0b:48″, ATTR{type}==”1″, KERNEL==”wlan*”, NAME=”wlan0″

You can implement this change immediately by running udevadm trigger, or if you have problems try a restart.

You should now be able to probe the card by using the hostap_diag utility:

vaio:~# hostap_diag wlan0
Host AP driver diagnostics information for ‘wlan0′

NICID: id=0x800c v1.0.0 (PRISM II (2.5) PCMCIA (SST parallel flash))
PRIID: id=0×0015 v1.0.7
STAID: id=0x001f v1.3.6 (station firmware)
vaio:~#

So as you can see, I’m using v1.0.7 of the Primary Firmware, and v1.3.6 of the Station Firmware. I intend to update mine to v1.1.1 and v1.8.4 as various places online report that they work with WPA2 (though I’m sure earlier/later firmwares do too).

So next we need to flash the Prism firmware on the MA401 to enable support for WPA/WPA2. You can download the firmware here (**zip file**). [1]

Now, if you try and flash the card using prism2_srec as shown below (and as detailed at Jun Sun’s blog), you’ll no doubt get an error as shown:

Downloading to non-volatile memory (flash).
Note! This can take about 30 seconds. Do _not_ remove card during download.
Odd.. Download request for the kernel driver failed.
Are you sure you have compiled (and loaded the correct version of)
hostap.o module with PRISM2_DOWNLOAD_SUPPORT definition in
driver/module/hostap_config.h?
In addition, non-volatile download requires PRISM2_NON_VOLATILE_DOWNLOAD
to be defined.
ioctl[PRISM2_IOCTL_DOWNLOAD]: Operation not supported

You’ll also get the following message in dmesg:

wifi0: non-volatile downloading not enabled

Once you’ve extracted the firmware, you will need to recompile your kernel to allow support for the firmware flashing. First off, install the necessary packages:

apt-get install kernel-package libncurses5-dev fakeroot wget bzip2

Download the appropriate kernel source from www.kernel.org – for my laptop I used 2.6.26.

cd /usr/src
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.tar.bz2

Unpack the source and create a symlink:

tar xjf linux-2.6.18.1.tar.bz2
ln -s linux-2.6.18.1 linux
cd /usr/src/linux

Copy your current kernel config to the sources directory:

cp /boot/config-`uname -r` ./.config

Now, ensuring we’re within the /usr/src/linux folder, run:

make menuconfig

You’ll be presented with a ncurses GUI, select “Load an Alternate Configuration File”, and then specify .config (should already be specified).

Then within the ncurses GUI navigate to the following:

Device Drivers —>
Network device support —>
Wireless LAN (non-hamradio) —>
IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
Support downloading firmware images with Host AP driver
Support for non-volatile firmware download
Host AP driver for Prism2.5 PCI adaptors

Ensure that the “Support for non-volatile firmware download” is marked with an asterisk (change it by using space bar). Once that’s selected, keep selecting ‘Exit’ to leave the GUI. You’ll be prompted to ask if you want to save the new kernel configuration, select Yes.

Now you can build the kernel using the following commands:

make-kpkg clean
fakeroot make-kpkg –initrd –append-to-version=-hostap kernel_image kernel_headers

This can take a few hours (it’s advisable to do the kernerl build on your most powerful machine; once the kernel has been recompiled you can transfer it to any other system and install it there).

Once the kernel has compiled, you should be able to see the .deb packages within /usr/src.

Install them using dpkg:

dpkg -i linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb

Once they’re installed, reboot, and then check that the new kernel has loaded by running:

uname -r

This should display something like 2.6.26-2-486-hostap.

In Kernel:

Device Drivers —>
Network device support —>
Wireless LAN (non-hamradio) —>
IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
Support downloading firmware images with Host AP driver
Support for non-volatile firmware download
Host AP driver for Prism2.5 PCI adaptors

[1] http://linux.junsun.net/intersil-prism/

Use a swap file instead!

I’ve only recently stumbled across this, but you can now (and probably have been able to since god knows what kernel :P ) use a swap file instead of having to create a swap partition. There’s no performance impact, and it’s easy to setup/configure.

Enter the following at the CLI:

#> dd if=/dev/zero of=/opt/512MB.swap bs=1M count=512
#> mkswap /opt/512MB.swap
#> swapon /opt/512MB.swap

Obviously you can put the file wherever you want. The real benefit of utilising a swap file rather than a swap partition may already be obvious: if you want to increase your swap size, simply swapoff, create a new, bigger file – and swapon again.

Quick BASH tips

If like me you use history extensively, then you’ve probably been annoyed at the fact that it forgets that complicated command from six months previous due to its size limitations.

Increasing the size of your history is an easy change, simply edit ~/.bashrc and insert the following line:

export HISTSIZE=10000

(Set HISTSIZE=0 if you want to disable the history all together).

As is already documented over at the ‘Linux Quick Tips‘ section, perhaps one of the most useful BASH shortcuts is the CTRL-R command, that allows you to search through the command history.

Also, it’s probably a good idea to stop duplicate lines from being entered one after another and taking needless space, so uncomment the following line to leave it as shown:

export HISTCONTROL=ignoredups

If you’re privacy conscious – you can change that line to read:

export HISTCONTROL=ignoreboth

That (and indeed having HISTCONTROL=ignorespace) will mean that any lines starting with a space will be ignored.

Whilst you’re in that file, you can also fix one of my pet hates when using BASH on other people’s servers – auto-completion features for programs that can use them, i.e. apt-get. If you’re logged in as a normal user, auto-completion for apt-get et al is already enabled. But for root, it isn’t.

To enable auto-completion, scroll to the bottom of the file and uncomment the appropriate section so it looks like the following:

if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

Finally, once you’ve saved and quitted vi/nano/vim/pico etc, to apply all the changes in your current shell, you can respawn bash by doing:

#> bash
#>

Cyrus Squat File Problem

If you’re getting the following (non-)error in your log files (/var/log/mail.log), then there’s a quick way to fix it if you’re not interested in ignoring it:

Feb 21 13:57:53 zivi cyrus/imaps[4648]: SQUAT failed to open index file
Feb 21 13:57:53 zivi cyrus/imaps[4648]: SQUAT failed

The error is caused by a user doing a search within a mailbox, and a squatter file (aka a search index) is not available. Fix this by running the following as your cyrus user (typically ‘cyrus’):

#> squatter -r user.username

If you’re doing a tail -f of /var/log/mail.log you’ll see the indexes being created.

Et voila – no more errors:

Feb 21 14:10:11 zivi cyrus/imaps[5073]: SQUAT returned 277 messages

If you want to take it a step further, you can automate this by creating a cronjob. Or if you’re using a standard Cyrus installation, the last few lines of your /etc/cyrus.conf will have some useful settings commented out that will allow Cyrus to schedule the SQUAT operations automatically:

# reindex changed mailboxes (fulltext) approximately every other hour
#squatter_1 cmd=”/usr/bin/nice -n 19 /usr/sbin/squatter -s” period=120
# reindex all mailboxes (fulltext) daily
#squatter_a cmd=”/usr/sbin/squatter” at=0517

As hinted at the beginning of this entry, this is a sort of non-error in as much as it can be safely ignored, and squat indexes need only be created if their is an advantage to doing so (that is, searches are often carried out).

How to tell Link Speed in Linux

I could have sworn that ifconfig used to tell me what link speed a connection was established at, but I must have been imagining it (?)…

root@box:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:11:11:82:9e:8c
inet addr:192.168.x.10 Bcast:192.168.69.255 Mask:255.255.255.0
inet6 addr: fe80::211:11ff:fe82:9e8c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2515495 errors:0 dropped:0 overruns:0 frame:0
TX packets:1007536 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3552713819 (3.5 GB) TX bytes:81240550 (81.2 MB)
Interrupt:16

Anyway, after a quick install (apt-get install ethtool) ethtool tells you a host of things, including Link Speed:

root@box:~# apt-get install ethtool
root@box:~# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: yes

Now the real question is why am I only achieving 5.2MB/s via Gigabit… Samba perhaps?

25 hours remaining to transfer 339GB =/

Update: My bad, should have never have suspected Samba without first checking Windows :$ Windows is only connected at 10/100 for reasons as of yet unbeknownst to me…

Redirect *all* BASH errors

A friend helped me out with a shell script I’m currently creating. I was trying to avoid having to append 2> to the end of every command within the script, and lo-and-behold my friend knew a way: use the exec command.

If you run exec with no arguments, all redirects apply to the current shell, so placing:

#!/bin/bash
exec 2> $errorlog
errorlog=”/var/log/custom.log”

Worked a treat!

Installing Debian on an old Sony

This post gives brief details on reviving an extremely old Sony Vaio PCG-505TX and loading the Debian net installer via floppy disk

I was recently given an old Sony PCG-505TX, with a monster spec of Pentium 300 MMX and 64MB of RAM. Whilst most phones come with a more powerful processor and more RAM nowadays, you can’t* install Debian on a phone, and the keyboard on the laptop still makes it a winner.

However, with only a floppy disk drive at my disposal, I had limited choices with what distribution to install. Luckily, whilst Debian is no longer released with floppy disk netinst images, the old Etch repo’s still contain them. I’ve uploaded them here in case the etch repo’s are ever dropped.

The old HDD in the laptop had also died, so I decided to replace it with a 10GB relic from an old ThinkPad I had lying around. After removing all the screws from the base of the unit, I was still unable to pry the keyboard away from the shell. After ten minutes of Googling I stumbled upon this site, which gave me the final clue – I needed to remove the ‘hinge caps’ from around the hinges of the monitor.

To do so – you need to apply a fair bit of force, you may think you’re about to break the plastic – but as long as you’re only using your finger(nail)s you shouldn’t worry. Just pry each end of the cap away until it finally succumbs to the pressure. Following that there should be no more screws to unscrew, just lift the keyboard gently away – note that you’ll have to release the clips holding the three ribbon cables in place.

With the new hard drive installed and the floppy images written to disk – I booted up with the ‘boot.img’ floppy inserted. The installation is pretty painless, and it will prompt you for each disk in turn. I had both a PCMCIA 10/100 network card installed and a USB network jack installed, and to my surprise both were detected and installed correctly once I’d loaded both ‘net-drivers’ disks.

The installation took about an hour, and I decided to forego installing X during the initial installation. After first boot-up I had 31MB out of 64MB free =)

Stupidly, I then did a:

apt-get install xorg xfce4

A couple of minutes later and following a startx, I was presented with a somewhat basic, but functioning, X windows environment. However, doing a free -m revealed that I only had 1MB of RAM free - so X was promptly uninstalled.

I'm soon to buy a new battery for the unit so it can act as my permanent portable console.

* This probably has been done!

Next entries »