Okay since someone just asked me if I have twitter, the answer is no I don’t.. well rather I didn’t but I do now, so if you want to get in contact with me or comment on something you can now tweet (is that the term?) me @idiomatically
Category Archives: Technical
Modify your PATH on Linux
Normally this only comes up these days if you are compiling your binaries or have downloaded some out side your package management system. I come from Solaris so I like to use /opt for all my self compiles and I prefix that with my initials ie /opt/mwd/bin this way I know it’s software I’ve compiled 6 months down the track when I am cursing it’s not got support for something I now need.
I use a multitude of linux distributions based on the hardware or purpose of the machine in question, ie servers are normally centos for greater vendor support or debian, and opensuse for my desktops.. I find this method works more or less for all the different linux flavours kicking around. I am assuming like most people bash is the shell of choice.
As most will know the PATH environment is a variable that get set every time you spawn a new session, login or source it by a group of system configuration files. These configuration files are basically read in the following sequence;
/etc/profile
,- then every
/etc/profile.d/*.sh
file that your user has access to, - then
/etc/profile.local
if it exists (by default it won’t), - and finally by
$HOME/.bashrc
and$HOME/.profile
Every time you spawn a session or shell, the new shell process will inherit all the environment variables that have been provided by the configuration files above, what I mean is they have a flow on effect in that no one files dismisses the previous they build on each other.
When it comes to setting your personalised PATH environment you really don’t want to use a configuration location that will get clobbered in system updates so /etc/profile is out, don’t touch it. I also don’t like using $HOME configuration files as I have users on my systems that I generally want to make this software available to and since /etc/profile.local doesn’t exist by default and will be globally read by all users on the system I choose it 🙂
If it was just for your user, then apply the change to $HOME/.profile
other wise do as I do and apply the changes to /etc/profile.local
.
I find the quickest way to achieve this is to simple issue the following command;
echo ‘PATH=/opt/mwd/bin:$PATH’ >> /etc/profile.local
(remember mwd are my initial this could easily be foo)
I would like to mention that in my example here we are appending to /etc/profile.local by using “>>” instead of just “>” as this creates / overwrites existing files. This is a safety feature, as on some distributions this file may already exist and we might not want to blindly clobber it. Also as stated previously the process inherits any variable that has been set previously by an earlier configuration file so in this case we do not need to “export” our new path.
Once you have made this chance you most likely won’t feel like having to respawn your session or logout and back in, so we’ll just source our new configuration with;
source /etc/profile.local
It’s that simple, one last thing.. if your linux system only has one user and that user is you and you are compiling your own stuff it may be easier just to install to $HOME/bin as most modern distro’s will read this path already in the default profiles.
WinXP install from USB Key
So the inevitable happened today we had to reinstall a netbook for one of our staff, there are probably offical methods for doing this from HP and co they involve restore partitions and they like but well since I don’t like reading we have our own method for installing Windows XP sp3 from a USB Key.
First of all you are going to need a few things;
Working USB Key (must be about 1GB is size we use Corsair GT’s)
Windows XP sp3 media CD
Good copy utility like Roadkil’s
Hiren’s Boot CD (http://www.hirensbootcd.net/download.html)
I’m going to assume if you are reading this you are somewhat savy and able to burn a cd.
Step 1.
We need to make our USB key bootable, to do this we are going to format it and install grub4dos.
Grab http://www.hiren.info/download/freeware/usb_format.zip
Then Grab http://www.hiren.info/download/dos-files/grub4dos.zip
After these two steps you should now have a bootable USB key.
Step 2.
We now need to copy the Hiren’s Boot CD and Windows CD to the USB key using Roadkil’s (or some other method of choice).
First copy the entire Hiren’s Boot CD contents to your USB key, then create a new folder in the keys root directory called ‘WinXP’. Copy the entire contents of the Windows Media CD here.
You should end up with two directories on the key, a HBCD directory (about 180mb) and a WinXP directory (about 580mb).
Step 3.
Configure grub4dos by coping the files grldr and menu.lst from HBCD directory to the usb keys root directory.
Step 4.
Now that the USB key is setup we need to boot it. To boot from USB you will have to either set it as the primary boot option in the bios of the netbook or just hit the select boot function key as the netbook starts (HP is F9, most seem to be F12 though).
Step 5.
If you are not a muppet you will be looking at a dos menu screen;
Boot from hard disk, or
Launch Hiren’s Boot CD, or
Launch Mini Windows XP.
You want the ‘Launch Mini Windows XP’ option.
Step 6.
The cut down mini windows xp will boot pretty quickly and you’ll be presented with a familiar XP desktop enviroment. We now want to invoke the Windows XP installation but opening a command prompt. Navigate to the USB key drive and select the ‘WinXP\i386’ directory, right click it and select the “Command Prompt Here” option.
Once you are looking at the command prompt simply type;
“winnt32.exe /makelocalsource /syspart:C: /tempdrive:C: /s:.” without the quotes of course and hit enter.
This will start the first phase of the install by coping temp files to the netbooks local hard drive, just answer it’s questions till it completes then it’s time to reboot and start the install in earnest from the hard drive.
Step 7.
Reboot, boot from the hard drive as per normal and continue to install windows as you would any other machine.. ie click next a dozen times and drink a beer or two.
Enjoy.
Open Source is Inferior
Well at least it is according to the dumb bitch sitting next to me at the moment. Take about a red rag at a bull, what a stupid stupid statement to make. With that end in mind here’s a list of great open source / freeware applications for windows I love and they are certainly not inferior (in no particular order);
1. ISO Magic http://www.magiciso.com/tutorials/miso-magicdisc-overview.htm
2. 7-Zip http://www.7-zip.org/
3. Audacity http://audacity.sourceforge.net/download/windows
4. Avidemux http://avidemux.sourceforge.net/
5. BRL-CAD http://brlcad.org/
6. Bid-O-Matic http://sourceforge.net/projects/bom/
7. ClamWin http://www.clamwin.com/
8. Cream http://cream.sourceforge.net/home.html
9. Filezilla http://filezilla-project.org/
10. Pidgin http://pidgin.im/
11. Juice http://juicereceiver.sourceforge.net/
12. Mozilla http://www.mozilla.org/
13. PDF Creator http://www.pdfforge.org/pdfcreator
14. Gimp http://gimp-win.sourceforge.net/
15. Open Office http://www.openoffice.org/
16. True Crypt http://www.truecrypt.org/
17. VLC http://www.videolan.org/vlc/index.html
18. Utorrent http://www.utorrent.com/
19. WinSCP http://winscp.net/eng/index.php
20. Miro http://www.getmiro.com/
21. Putty http://www.chiark.greenend.org.uk/~sgtatham/putty/
22. Handbrake http://handbrake.fr/downloads.php
23. Inkscape http://inkscape.org/download/
24. XChat http://www.silverex.org/download/
25. Notepad++ http://notepad-plus.sourceforge.net/uk/site.htm
26. GnuUtils http://unxutils.sourceforge.net/
27. Scribus http://www.scribus.net/
28. Blender http://www.blender.org/
29. JDiskReport http://www.jgoodies.com/freeware/jdiskreport/
30. Speak Tools http://www.speaktools.com/
31. Eclipse http://www.eclipse.org/
32. InfraRecorder http://infrarecorder.org/
33. ImgBurn http://www.imgburn.com/
34. Clonezilla http://clonezilla.org/
35. KonBoot http://www.piotrbania.com/all/kon-boot/
Expanding Zimbra Ext3 Mail Store.
Recently I noticed that our primary mail store was becoming alarmingly large and running out of disk space. Origianlly 200gb seemed ample but fast forward a couple of years and well it’s vastly inadequate with 92% of the available disk space consummed and growing rapidly. Infact if it wasn’t for the GFC I would dare say we’d have well exceeded it by now.
Since the mail store is an iScsi volume mounted as a phyisical disk (dev/sdc) increasing the volume size was easy, I just allocated more resources to it at the SAN but that doesn’t really do much for us as the Operating System doesn’t know to use the additional space as we can see from;
Disk /dev/sdc: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 26108 209712478+ 83 Linux
We need to grow our /dev/sdc1 partition to use these new disk cylinders. But before you start messing with any partition or file system the golden rule must be back up and not just once or in the same format when it comes to mission critical data, a mistake here is likely to get you in the shit at the least and maybe fired or worse.
So the next step is all this is to do a couple of “FULL” backups, the first I did was from within Zimbra itself this will not only compress the mail store but also grab all the LDAP info etc as well. This back up would let you deploy to another server instance if things went really bad;
zmbackup -f -s $server.domain.net.au -a all -t /mnt/SANBackup/zimbra.backup/ -z
where server.domain.net.au is the fully qualified domain name of your mail server. The syntax is simple -f = full -s = server -a = attributes -t = path and -z = compress.
Now comes a long waiting game, as you can see from this query this backup process took some 8+ hours to complete;
zmbackupquery -lb full-20091204.005207.351 -t /mnt/SANBackup/zimbra.backup/
Label: full-20091204.005207.351
Type: full
Status: completed
Started: Fri, 2009/12/04 10:52:07.351 EST
Ended: Fri, 2009/12/04 19:17:24.923 EST
Redo log sequence range: 3102 .. 3106
Number of accounts: 171
But of course since I like to cover myself I didn’t stop here I also decided to create an rsync copy of the mail store;
/sbin/rsync -avpHK /mnt/home/zimbra/ /mnt/SANBackup/MailRsync/
again go away for a few hours, then come back and hopefully you’ll have this;
du -h /mnt/home/zimbra/
167G /mnt/home/zimbra/
du -h /mnt/SANBackup/MailRsync/
167G /mnt/SANBackup/MailRsync/
Awesome we have two exact copies, the rsync syntax I use is a = archive v = verbose p = perseve permissions H = preserve hardlinks and K = keep directory links, ie treat a symlink as a directory.
Now that I felt we had a point to come back to if all went to hell it’s time to attack that partition. There are a couple of ways people will tell you to do this and the most commin would feather a Knoppix CD with gparted or similar. In the home use environment that would probably do the job and be less hands on but in this production environment it’s not an option and besides I am 200k’s from the server looking at a beach.
Will have to do the the console way and besides it’s quicker. There is a great GNU tool called parted and it’s what gparted is a front end for but in my experience it has issues with ext3 and journals, infact every time I’ve used it with ext3 I’ve gotten the error;
Error: Filesystem has incompatible feature enabled
to get around this you need to remove the file system features and we’ll do that later but for now I just suggest people forget about parted and use good ole fdisk
Of course I can hear the crys of “but fdisk can’t resize, only create and destroy” and you’d be right but we can use this to our advantage. See we don’t want to alter the starting cylinders just expand the partition to use more cylinders then before. Before we start you need to run;
/sbin/fdisk -l
Disk /dev/sdc: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 26108 209712478+ 83 Linux
The reason we do this is to find our starting cylinder in my case it’s easy as I only have the 1 partition, so my starting cylinder is 1.. but if this partition was in the middle of the disk say you’d need to carefully write down this starting point because get it wrong later and you’re in for some pain as you’ll do damage to your data. From that output we can also see that my partition ends at 26108 but we want it to continue on till the end of the available space at 52216.
Here comes the fun part 🙂
First we need to stop all services in zimbra using the mail store;
zmcontrol stop
Stopping stats…Done
Stopping mta…Done
Stopping spell…Done
Stopping snmp…Done
Stopping archiving…Done
Stopping antivirus…Done
Stopping antispam…Done
Stopping imapproxy…Done
Stopping mailbox…Done
Stopping logger…Done
Stopping ldap…Done
you should just comfirm it really is all stopped with;
zmcontrol status
Unable to determine enabled services from ldap.
Enabled services read from cache. Service list may be inaccurate.
Host grange.langs.net.au
antispam Stopped
zmmtaconfigctl is not running
zmamavisdctl is not running
antivirus Stopped
zmmtaconfigctl is not running
zmamavisdctl is not running
zmclamdctl is not running
ldap Stopped
logger Stopped
logmysql.server is not running
zmlogswatchctl is not running
mailbox Stopped
zmmtaconfig is not running.
zmmtaconfigctl is not running
mysql.server is not running
zmconvertctl is not running
mailboxd is not running.
zmmailboxdctl is not running
mta Stopped
zmmtaconfigctl is not running
postfix is not running
zmsaslauthdctl is not running
snmp Stopped
zmswatch is not running.
spell Stopped
zmapachectl is not running
stats Stopped
and because I don’t have alot of faith I also run a script I came up with;
cat /opt/packages/killuser
#!/bin/bash
USER=$1
MYNAME=`basename $0`
if [ ! -n “$USER” ]
then
echo “Usage: $MYNAME username” >&2
exit 1
elif ! grep “^$USER:” /etc/passwd >/dev/null
then
echo “User $USER does not exist!” >&2
exit 2
fi
while [ `ps -ef | grep “^$USER” | wc -l` -gt 0 ]
do
PIDS=`ps -ef | grep “^$USER” | awk ‘{print $2}’`
echo “Killing ” `echo $PIDS | wc -w` ” processes for user $USER.”
for PID in $PIDS
do
kill -9 $PID 2>&1 >/dev/null
done
done
echo “User $USER has 0 processes still running.”
This will clean up any left over processes. Second part of this exercise is unmounting the file system the mail store uses;
umount /mnt/home
This has effectively parked our ext3 file system making it ready for manipulation.
We need to ensure the file system is in good order before we begin;
/sbin/fsck -n /dev/sdc1
fsck 1.35 (28-Feb-2004)
e2fsck 1.35 (28-Feb-2004)
/dev/sdc1: clean, 504961/26214400 files, 44472606/52428119 blocks
Okay looking good, now we need to remove those features that give parted a hard time by basically making our ext3 file system an ext2 file system, to do this we need to remove journaling;
/sbin/tune2fs -O ^has_journal /dev/sdc1
tune2fs 1.35 (28-Feb-2004)
Now it’s fdisk time, we’re going to delete the partition but don’t be alarmed because we’re not changing that starting cylinder remember and only going to expand the cylinder count this will be none destructive if you have claimly written down that starting cylinder and beside we took all those awesome backups;
[root@grange matthewd]# /sbin/fdisk /dev/sdc
The number of cylinders for this disk is set to 52216.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdc: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 26108 209712478+ 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdc: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
At this point we’ve now removed the partition and it’s time to create the new one encompassing all the new space;
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-52216, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-52216, default 52216): 52216
Command (m for help): p
Disk /dev/sdc: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 52216 419424988+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Right now it’s time for some husbandry on our new parition and file system;
/sbin/e2fsck -f /dev/sdc1
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdc1: 504961/26214400 files (25.1% non-contiguous), 44464404/52428119 blocks
Note this part takes some time so don’t be alarmed your data is safe, for me this was about an hour. Next do;
/sbin/resize2fs /dev/sdc1
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/sdc1 to 104856247 (4k) blocks.
The filesystem on /dev/sdc1 is now 104856247 blocks long.
This is actually the step that grows your file system to now match the partition size. We need to check it one last time with;
/sbin/fsck -n /dev/sdc1
fsck 1.35 (28-Feb-2004)
e2fsck 1.35 (28-Feb-2004)
/dev/sdc1: clean, 504961/52428800 files, 45289879/104856247 blocks
Remember how we removed those file system features? Time to put them back getting our ext3 back in order;
/sbin/tune2fs -j /dev/sdc1
tune2fs 1.35 (28-Feb-2004)
Creating journal inode: mount done
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Now lets remount our file system and see if a) the new size is there and b) that yes indeed we still have data;
mount /mnt/home/
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md0 178G 12G 157G 7% /
none 2.0G 0 2.0G 0% /dev/shm
pluto:/sanbackup 1.8T 871G 870G 51% /mnt/SANBackup
/dev/sdc1 394G 167G 212G 45% /mnt/home
Woot it’s mounted and our extra space is there.. now how about our data;
# ls -la /mnt/home
total 32
drwxr-xr-x 4 root root 4096 May 8 2008 .
drwxr-xr-x 4 root root 4096 May 8 2008 ..
drwx—— 2 root root 16384 Aug 1 2006 lost+found
drwxr-xr-x 4 zimbra zimbra 4096 Sep 13 2008 zimbra
# ls -la /mnt/home/zimbra
total 16
drwxr-xr-x 4 zimbra zimbra 4096 Sep 13 2008 .
drwxr-xr-x 4 root root 4096 May 8 2008 ..
drwxr-xr-x 3 zimbra zimbra 4096 Aug 29 2006 index
drwxr-xr-x 4 zimbra zimbra 4096 Aug 29 2006 store
All seems in order, so let s go ahead and restart our mail server;
zmcontrol start
Starting ldap…Done.
Starting logger…Done.
Starting mailbox…Done.
Starting antispam…Done.
Starting antivirus…Done.
Starting snmp…Done.
Starting spell…Done.
Starting mta…Done.
Starting stats…Done.
zmcontrol status
antispam Running
antivirus Running
ldap Running
logger Running
mailbox Running
mta Running
snmp Running
spell Running
stats Running
There we have it, mail system is back up and we no longer have to worry about the mail store running out of space and we didn’t lose anything so we even get to keep our job. A warning however do NOT try this with a windows box or if you are faint of heart, nor can I stress enough that you must always have the backups to go with it.
I promise you the day you don’t have a decent backup is the day you will need it, that’s just Murphy.
Windows 7 Homegroup Icon
Ok so MS sent me a freebie copy of Windows 7 Ultimate last week and this weekend I decided to upgrade my vista test machine. First thing I notice is this new “homegroup” service they have included and in typical MS form there is no straight forward way to piss it and it’s persistant desktop icon off.
Thankfully they haven’t removed regedit yet so lets look in door number 3….
Computer\HKEY_LOCAL_MACHINE\SOFWARE\Microsoft\Wind ows\CurrentVersion\Explorer\Desktop\NameSpace\
There are a number of Keys here but the one of interest to us today is {B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}. Export it, and then delete this key. Refresh the desktop (F5) and voila the homegroup icon is gone. This will not effect it’s actual use, so I would take this one step further by opening the homegroup settings and choosing the leave homegroup option.
Lastly go into your services.msc and disable the 2 homegroup services to prevent them running.
Ax09 Export Master Items
I had to export the Master Items from one company to another in differing databases as someone made a mistake with the Items and needed them restored, as there were a lot of other changes doing a straight up SQL DB restore wasn’t a good option. So anyway I created a new definition group and added the 3 tables I wanted (inventtable, inventtablemodule and inventitemlocation) to export in the source company, and then replicated that definition group in the target company.
From here you export the definition group to a file as binary this gives you 2 files a file.def and file.dat, one being the layout and the other the actual data. In the target company you then select the definition group and import validating and skipping existing records.
InventDim table won’t be necessary for this exercise as it is required when the InventDimId field on InventItemLocation is not “allBlank”. However should that field not be “allblank” you either have to add the InventDim table to your definition group for export/import or use a job to alter that field once imported to be “allblank”.
An example of such a job is;
static void MWD_UpdateInventDimIdInvItemLoc(Args _args)
{
InventItemLocation itl;
;
ttsBegin;
delete_from itl where itl.inventDimId != ‘ID00000635’;
update_recordset itl
setting
inventDimId = ‘ALLBlank’
where itl.inventDimId == ‘ID00000635’ &&
itl.dataAreaId == ‘ts1’;
ttsCommit;
info(“Processing Finished.”);
}
Event ID 1030
If you are getting a lot of Event Id 1030 errors that appear in the event log like “Windows cannot query for the list of Group Policy objects”. I recommend you remove badly stored domain credentials via the registry.
1. Run Regedit
2. Drill down to HKLM\System\CurrentControlSet\Control\Lsa
3. In the right pane locate the disabledomaincreds key
4. Change the disabledomaincreds value to 1 to stop store domain credentials.
TS 2003, Event ID 1500 & 1508
Users will be presented with an error message regarding their profile and some applications may cease to function to correctly perform the following step to resolve;
1. Click Start, click Run, type regedit, and then click OK.
2. Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
3. On the Edit menu, point to New, and then click DWORD Value.
4. In the New Value #1 box, type PoolUsageMaximum, and then press ENTER.
5. Right-click PoolUsageMaximum, and then click Modify.
6. In the Value data box, type 60, click Decimal, and then click OK.
7. If the PagedPoolSize registry entry exists, go to step 8. If the PagedPoolSize registry entry does not exist, create it. To do this, follow these steps:
1. On the Edit menu, point to New, and then click DWORD Value.
2. In the New Value #1 box, type PagedPoolSize, and then press ENTER.
8. Right-click PagedPoolSize, and then click Modify.
9. In the Value data box, type ffffffff, and then click OK.
10. Exit Registry Editor, and then restart the computer.
once completed I recommend you install the HIVE cleanup service as well as ensuring your page file is 1.5 times the size of the hosts physical memory.
Sunray Server 3.1 DHCP options
A mate rang me this morning as he received some new sunrays to add to his fleet (good man) but they wouldn’t boot with the 27B error. This stumped him as he as 30 odd sunrays already in use and working fine. I noticed in his DHCP server options he was missing 2 settings I use.
066 and 049, these should both be pointed at your Sunray 3.1 Server, they are definitely needed if you are booting your DTU’s over a WAN but can be optional on a lan but as seen here it’s not set in stone that it will work without issue on the lan. Better safe then sorry in my book.