Archive for the ‘usefulthings’ Category.

Adding iscsi devices

[root@sn-b07-a ~]# iscsiadm -m session
tcp: [9] 172.16.4.201:3260,1 iqn.1984-05.com.dell:powervault.6001c23000cd3f8300000000485684e3
tcp: [10] 172.16.4.202:3260,2 iqn.1984-05.com.dell:powervault.6001c23000cd3f8300000000485684e3
tcp: [11] 172.16.5.202:3260,2 iqn.1984-05.com.dell:powervault.6001c23000cd3f8300000000485684e3
tcp: [12] 172.16.5.201:3260,1 iqn.1984-05.com.dell:powervault.6001c23000cd3f8300000000485684e3
[root@sn-b07-a ~]# iscsiadm -m session -r 9 --rescan

From here.

Word 2011 fail

Earlier today I was writing up a design in Microsoft Word for Mac 2011. When the inbuilt gamma checker highlighted the following word:

OK, I’ll give it that I, spreadsheet is probably correct, so I let it correct it and continued with my writing. Then a couple of seconds later I notice it has underlined the word again, but this time in red. This is the suggestion from the spelling checker when I right clicked on the word…

I’m at this point feeling stuck in some computer ‘helping’ me write hell!

mdadm Linux software Raid raidhotadd

I’m sure there used to be a thing called raidhotadd, anyway these days it seems to be mdadm. We have a few machines with software raid, and very occasionally a md device flags a disk as dead but adding it back into the array fixes the problem.

Anyway, I never remember this, so to remove and then re-add a disk from a md device do the following:


[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md0 : active raid1 sdc1[0] sdd1[2](F)
143371968 blocks [2/1] [U_]

md2 : active raid1 sdb2[1] sda2[0]
71577536 blocks [2/2] [UU]

unused devices:
[root@host ~]# fdisk -l /dev/sdd

Disk /dev/sdd: 146.8 GB, 146815737856 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdd1 * 1 17849 143372061 fd Linux raid autodetect
[root@host ~]# mdadm /dev/md0 --remove /dev/sdd1
mdadm: hot removed /dev/sdd1
[root@host ~]# mdadm /dev/md0 --add /dev/sdd1
mdadm: re-added /dev/sdd1
[root@host ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md0 : active raid1 sdd1[2] sdc1[0]
143371968 blocks [2/1] [U_]
[>....................] recovery = 0.2% (297280/143371968) finish=32.0min speed=74320K/sec

md2 : active raid1 sdb2[1] sda2[0]
71577536 blocks [2/2] [UU]

unused devices:
[root@host ~]#

And there we can see from /proc/mdstat that the md device will be synchronised and happy again soon.

Parted, GPT and LVM

Always forget this:


(parted) mklabel gpt
(parted) mkpart primary 0 100%
(parted) set 1 lvm on

That is all.

CentOS 4.x and OMSA 6.1 – Update breaks IPMI

Just recently I upgraded a Centos 4 machine which broke OMSA, this post helped me fix it.

Linux Setting processor affinity for a certain task or process

Just recently I wanted to be able to lock a single process to a specific CPU for testing purposes. A bit of googling lead me to thisnice explanation of how it works.

Essentially you use the taskset command to run a new proc locked to a specific CPU:

% taskset -c 1 sleep 10

Will run ‘sleep 10′ locked to CPU #0.

% taskset -c -p 1
pid 1's current affinity list: 0,1

Shows you what PID 1 has its affinity set to.

Connecting HUAWEI E220 to your Mac

Every time I need to use this modem on a new mac I end up fighting with it and often giving up. I’ve made it work this time, so I intend to document the process here so I dont spend hours googling next time.

These instructions worked on my iMac and my MacBook Pro both of which were running 10.5.7.

Before you start, make sure the modem is not connected.

First off download the drivers, the ones buried in the three.co.uk support site lack a actual installer even though the documentation suggests you just need to run the installer. WTF am I supposed to do with a bunch of .kext files three? Have you heard of a nice user experience? Clearly not. Click this link and download the zip file from here, inside is a standard OSX installer package. run that.

After that has installed, you dont need to reboot. Plug in the modem and wait a few minutes. The little LED started flashing blue occasionally for me which I think means I’ve got 3G coverage.

Once its calmed down open up network preferences where you should see a few new devices down the left hand side:

network-preferences

The device you are interested in is the HUAWEI Mobile, select that. Then in the ‘Telephone Number’ field enter *99#:

modem-options

After you have done that click the ‘Advanced’ button. On the resulting pane, select ‘Generic’ from the Vendor drop down. Then select ‘GPRS (GSM/3G)’ from the Model field. If you are in the UK, enter ‘three.co.uk’ into the APN field and leave the CID as 1:

advanced-modem-options

Click ok, and then click Apply on the main Network Preferences pane. After you’ve done this try clicking connect and you should see the following connection confirmation:

connected

A nice little utility to monitor your connection is CheetahWatch which you can get from here.

Enabling vmware-tools clock sync from inside the guest

Just found out how to turn on vmware-tools clocking syncing from inside the guest, rather than editing the .vmx file on the host.

Once you have vmware-tools installed and configured try this:

/usr/sbin/vmware-guestd --cmd "vmx.set_option synctime 0 1"

To verify this has worked look for this line in the corresponding .vmx file:

tools.syncTime = "TRUE"

vmrun – Control VMware Fusion from the command line

I’ve just needed to snapshot a virtual machine running under VMware Fusion on my Mac but I only had SSH access. I’ve discovered the vmrun utility which is hidden away in XXX. VMware have a PDF of how to use it here. Very handy!

% export PATH=/Library/Application\ Support/VMware\ Fusion/:$PATH
% vmrun listSnapshots SpaceWalk.vmx

Total snapshots: 1
Fresh 5.2 all updates
% vmrun -T fusion snapshot SpaceWalk.vmx "SpaceWalk Installed"
% vmrun listSnapshots SpaceWalk.vmx
Total snapshots: 2
Fresh 5.2 all updates
SpaceWalk Installed
%

Bravo!

Scripting DynDNS

I recently needed to bulk load some entries to the DynDNS custom DNS service, I ended up using wget and a couple of bash for loops. This was the crux of it:

To login:

wget --keep-session-cookies \
--save-cookies cookies.txt \
--post-data="__login=1&username=${USERNAME}&password=${PASSWORD}" \
https://www.dyndns.com/account/

To check you are logged in:

wget --keep-session-cookies \
--load-cookies cookies.txt \
https://www.dyndns.com/account/services/zones/dns/

grep the page for ‘Logged’ you should see it say something like ‘Logged in user: blah’.

Also look towards the bottom of the page for the ‘multiform’ hidden form element, you need the value which is a string, something like ‘jaoEEPpxzAhfadQZ/dpO/A341374′

To add an entry:

NAME=test
IP=1.2.3.4
MULTIFORM="jaoEEPpxzAhfadQZ/dpO/A341374"
wget --keep-session-cookies \
--load-cookies cookies.txt \
--post-data="name_new=${NAME}&ttl_new=600&type_new=A&data_new=${IP}&submit=submit&multiform=${MULTIFORM}" \
https://www.dyndns.com/account/services/zones/dns/