• Home
  • About Me

ukstokes.com

tech stuff from a tech bloke

Feed
  • Working with Logical Volumes

    Apr 1st 2009

    By: ben

    No comments

    I'm actually coming around to Linux LVM - once you get the hang of the concepts and the associated commands it can be a straightforward exercise to extend your existing volumes after adding new physical disks. This differs from software RAID, as you have the ability to lay an LVM filesystem over a single disk and later take advantage of the LVM commands to resize your volumes if you so desire.

    I recently was confronted with a VM that was out of space on /usr/local. The filesystem was already using LVM so I just added a new virtual disk and stretched the /usr/local volume over the new disk. The whole process is even easier in VMware as you can add the new disk while the machine is running and run through the whole process without a reboot, providing you don't have daemons or processes running in /usr/local that stop it from being unmounted. Here's how I did it:

    init 1
    umount /usr/local

    Going to runlevel 1 may not always be necessary but was in my case. pvcreate enables the new physical disk for use with LVM. Then vgextend extends the volume group, and lvresze resizes the logical volume. In my case the new disk that was added became known to the system as /dev/sdc.

    pvcreate /dev/sdc
    vgextend VolGroup00 /dev/sdc
    lvresize /dev/VolGroup/lvol0 -L 12.7G

    Then use resize2fs to extend the file system into the free space. You are required to fun a filesystem check first.

    e2fsck -f /dev/VolGroup/lvol0
    resize2fs /dev/VolGroup00/lvol0 12700M
    mount -a
    init 3

    In my example the previous size was 7.7Gb, I added a 5Gb disk and extended to 12.7Gb.

    Enterprise Linux, VMware

    Linux, Logical Volumes, LVM, VMware

  • 6 Free ways to encode video for your N95

    Feb 28th 2009

    By: ben

    No comments

    Nokia N95

    For basic video converting and playback on N95 there is an application bundled with the Nokia PC Suite that can convert some video formats into the Real Player format. But, for some reason the 'high quality' option is greyed out for me, and it also does restrict you to using Real Player on your phone to watch your content which I have to tell you sucks, if you want to rewind or fast forward then forget it, this sucker only does Play and Stop. My recommendation is to forget Real Player and use Divx Mobile Player, and encode your video in the Divx format.

    So here are some free tools that can do this for you - I've only commented on the ones I've used (I stopped trying out new ones once I found one that worked for me).

    • Avidmux (Not tested)
    • Dr DivX

    This is an Open Source converter from DivX Labs. Works pretty well and is very easy to use - to convert DVD to N95, select the VOB files in your Video_TS folder on the disk in the correct sequence in one chunk and add them all to your project. On the Advanced tab, click to the Pre-Processing tab and change the aspect ratio to 4:3, and size to 320x240. Save your Encode settings so you don't have to go through this process again and hit Encode (after the analysis has finished). Then select your job, and click Resume.

    Dr DivX OSS

    Dr DivX - It does the job

    • Super

    Super is the one everyone seems to recommend, particularly in Nokia forums. It's probably good if you know what you're doing, but if you don't you will find the array of options confusing. Also their website is highly annoying, forcing you to click through pages of waffle to reach the download. But if you're still interested, here's a blog post about encoding video on Super for an N95.

    • MediaEncoder (Another one I did not try yet)
    • Pocket DivX Encoder

    I used to use Pocket Divx Encoder when I had an iMate Jam and it worked pretty well. Apparently you can select use the default PDA settings for N95, but when I tried this it looked like pink flickery garbage when I played it back on my phone.

    • HandBrake (Open Source)

    I like HandBrake. It can rip directly from DVD into a format of your choice (but not DivX), unlike most of the others which expect your input file to be an existing mpg or avi file rather than a DVD. It's also pretty easy to use ... a lot of people are reporting success with Handbrake but when I encoded a DVD to Xvid, when I play it back in Media Player it works fine, but on Divx Mobile Player the video causes the application to bomb out every time. Your mileage may vary.

    Handbrake - has Linux, Mac and WIndows versions
    Bonus
    I've also got a bonus 7th cheating way: DivX Converter. This is really the best solution if you don't care about messing with any baffling settings. It just gives you 3 options - small, medium or large screen, and a "GO" button that kicks off the process. Select small and press GO, 10 Minutes later it spits out the file and you can play it on your N95 using DivX Mobile Player. But here's the catch - and the reason this is a cheating method ... it's only free for 15 days, after that you have to pay. So this is great for a one time conversion utility, but not so great if this is something you will need to do from time to time.

    But even if you don't use DivX Converter, I would still recommend you get DivX Mobile Player anyway. It's basically a free edition of SmartMovie with all the same options and features.

    Conclusion
    There are lots of converter programs to choose from - many more than I have listed here, but my recommendation goes to Dr DivX due to it working first time for me and being easy to operate without in -depth knowledge of codecs or video encoding.

    One final thing to note is if you notice your audio is playing back slightly behind or ahead of your video in DivX Mobile Player, there is an option in the settings to configure the A/V sync gap in miliseconds. Making an adjustment here will allow the video to play perfectly on your N95.

    Mobile

    DivX, Dr DivX, Mobile, N95, Video Encoding

  • Mapping printers using a login script

    Feb 11th 2009

    By: ben

    No comments

    Here's how:

    [lang='vb']Dim objNetwork, strPrintServer
    Set objNetwork = WScript.CreateObject("WScript.Network")

    strPrintServer = "\\Your_Print_Server"

    Private function GetUserObject
    On Error Resume Next
    Set GetUserObject = GetObject("WinNT://"  objNetwork.UserDomain  "/"  objNetwork.UserName)
    End function

    set UserObject = GetUserObject

    For Each Group in UserObject.Groups
    Select case Group.Name
    Case "Your_AD_Security_Group"
    objNetwork.AddWindowsPrinterConnection strPrintServer  "\Your_Printer_Name"
    End Select
    Next[/lang]

    To set the default printer:

    [lang='vb']  Select case Group.Name
    Case "Your_AD_Security_Group DEFAULT"
    objNetwork.setDefaultPrinter strPrintServer  "\Your_Printer_Name"[/lang]

    Job done.

    Scripting

    Scripting

  • A quick mention for 2 useful tools

    Feb 10th 2009

    By: ben

    No comments

    Here's just a quick mention for a couple of decent tools.

    Syntax Highlighter plus (plugin for wordpress). Link

    IMO this is the best code highlighting plugin for WordPress. Here's a quick example: 

    [lang='bash']ls -la
    apt-get update
    apt-get upgrade[/lang]

    Does exactly what is says on the tin and has the 'view source' button to you to copy and paste the plain text version of your code into notepad or Putty sessions.

    Second quick mention is EasyVMX. Link

    Ever wondered how to create a new VM for VMware player? Just visit the EasyVMX site, fill in the form and click go, and your VMX file is created. Then just give the file to VMware player and you can boot into your new machine. Genius!

    Random stuff, VMware

  • Adventures in wine

    Jan 13th 2009

    By: ben

    No comments

    I've been working a lot with Wine at the moment. No, that doesn't mean I've been getting sloshed at my desk at work. Actually for the last month or so I have been running Linux on my laptop - not dual booting - I've been using Linux as my sole operating system. Since time at work is divided 50/50 between Windows and Linux administration, I wondered it if might be helpful to administer Linux, from Linux, and I also wanted to use it as an opportunity to learn more about the inner workings of the OS. Since we use Red Hat only at work I've gone for CentOS 5.2 (for those that don't know, it's a very close clone of Red Hat) as my distro of choice.

    I do still need to run Windows software though. I tried just using Citrix for my WIndows apps at first, but it became annoying after a while for various reasons - mainly copy and paste not working, and not being able to browse my own filesystem from the Citrix server, for say adding an attachment to a message.

    Instead I am running Windows apps in Linux by using Wine (which stands for Wine Is Not an Emulator). It's an open source implemtation of the Windows API that can run on Linux, Unix and Mac systems.

    There are really 2 things that I want to mention in this post, and the first is winetricks. Presuming you have first installed Wine, using:

    [lang="bash"]yum install wine[/lang]

    Winetricks can can just be downloaded and run like this:

    [lang="bash"]wget http://www.kegel.com/wine/winetricks
    chmod 755 ./winetricks
    ./winetricks[/lang]

    This presents you with a GTK menu where you can select the Windows apps you want installed. Winetricks then fetches the download and installs in your 'fake windows' for you. I found this especially handy for .NET Framework 2.0 and Windows Installer 2.0, which I wanted for the VMware Virtual Infrastructure Client. The VI Client then installed using Wine, but incidentally still would not run. Nonetheless winetricks is the best Wine helper-app I've seen so far.


    winetricks

    I can't say that I'm completely happy still, I've given up on Outlook 2007 as it was too buggy and am now using Office 2003, it is still a bit ropey in places (my preview window quite often breaks) but I guess I can work around the problems as they are not showstoppers. I've tried using Evolution as an open source alternative to Outlook, but being a guy why has used Outlook every day for many years, it seemed inferior in almost every way, and of course the integration with Exchange is never going to be as good as Microsoft's own Exchange client.

    By the way if you're going to use Crossover Linux, I would use it exclusively for managing your Windows apps, rather than using Crossover, winetricks, and installing your own stuff just by running wine setup.exe. I found mixing and matching caused Office to become even more buggy than usual.

    The second thing I wanted to mention is Codeweavers Crossover Linux. Wine is actually not difficult to use, but the general consensus on the Internet is it's not possible to get Outlook 2003/2007 working on Linux using Wine. This is where Crossover Linux steps in and makes it possible, and also makes it very easy to do so using a nice graphical interface. Crossover Linux is not free (usually it's $44), but I was lucky to get in there a few months back when they were giving it away free for a day.

    Desktop Linux

  • Exchange mailbox store restores

    Oct 16th 2008

    By: ben

    1 comment

    This week I've had to refresh my memory with something I've not done in a long time. I had to recover a mailbox store for an urgent mailbox restore, but in this case the server that was the home of the mailbox at the date they wanted had been decommissioned long ago. This presents a problem with a) the recovery storage group, as the 'add database to recover' dialog will not show the store, and b) backup exec, which wants to log on to the old server for some reason! This is how it was done (our servers are all Exchange 2003 SP2 (native mode) and backup exec is 11d).

    Also for a quick sanity check before kicking off the restore I had checked the database tab on all the stores, just to check 'this database can be overwritten by a restore' was not checked.

    For an older Exchange restore (Exchange 5.5) you would need a temporary server to rebuild to replicate your old 5.5 environment.

    Starting up

    1.    Recall the tape!
    2.    Inventory the drive and catalog the tape. Note the mailbox store name that contains your target mailbox.
    3.    On the server you are using for recovery, create the recovery storage group (this can have any name, just ensure there is enough disk space for the database files where you create it)
    4.    Say for example the store you need to recover is called “Mailbox Store 1 (SVHEXBETEMP01)”. Obviously when you right click on the RSG and select “add database to recover”, this database will not be in the list. To get around this, you have to create a new mailbox store that has this name. You can do this on any server in your org. The name has to match exactly with the store you are recovering.
    5.    Now right click on the RSG and select ‘add database to recover’ and add the new store.
    6.    Go back to Backup Exec. Click Restore -  new restore job (not by wizard)
    7.    Change beginning backup date as required.
    8.    View by resource, and drill down to the required store
    9.    Under Microsoft Exchange Redirection, check ‘Redirect Exchange sets’. Enter the server name to redirect to
    10.    Under Microsoft Exchange, select ‘Restore all transaction logs until point-in-time; skip transaction logs after this time’
    11.    Change path for storage of temporary files to a volume that has plenty of free space.
    12.    Uncheck mount database after restore.
    13.    Run now!

    Restoring the mailbox

    1.    If the mailbox you are restoring still exists in your org, migrate the mailbox to your new store (e.g. “Mailbox Store 1 (SVHEXBETEMP01)”)
    2.    If they mailbox does not exist, create one with the same name in this store.
    3.    In the RSG, right click on the target mailbox and use the recovery option. Select the target (you probably will not be able top modify this option)
    4.    Copy option is safer than Merge.
    5.    Now you can use ExMerge to extract the PST, or just tell the user their data has been recovered.

    Cleaning up

    1.    Migrate the user back to their original location.
    2.    Delete the temporary mailbox store.
    3.    Delete the recovered mailbox store and recovery storage group.
    4.    Delete the database files from disk.

    Exchange, Messaging

  • Run a scheduled task using VBS

    Oct 16th 2008

    By: ben

    No comments

    One of our users has an occasional requirement to manually run a scheduled task on a server. I wanted him to do this without logging on via RDP. Scheduled tasks can be run remotely using the SVHTASKS program (on Windows XP and Server 2003) so I started writing a VB Script to call this app. The tricky part was capturing the output of the command and displaying that back to the user, so he would know if it was a success or failure. It turns out this is actually quite difficult to do, so I hacked up various other scripts I found on the web until I eventually got this to work. The working version is below.

    A copy you can download is here - I'm having a problem with character encoding on the site which is ruining code snippets like the one below. 

    [lang='vb']

    strServer = "your_server_name"
    strTask = "task_name"

    Continue = MsgBox ("Scheduled job " & strTask & " will run on " & strServer & ". Are you sure?",vbYesNo + VBQuestion, "Run scheduled task")

    If Continue = vbYes then

    Const OpenAsASCII = 0
    Const FailIfNotExist = 0
    Const ForReading = 1

    sExe = "SCHTASKS /Run /S " & strServer & " /TN " & strTask

    Set oShell = CreateObject("WScript.Shell")
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
    sTempFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName
    oShell.Run "%comspec% /c " & sExe & " " & sTempFile, 0 , True
    Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, OpenAsASCII)

    ' capture output and inject into a variable

    sResults = fFile.ReadAll
    fFile.Close
    oFSO.DeleteFile(sTempFile)
    MsgBox sResults , vbInformation , "Result"

    Else

    wscript.quit

    End If

    [/lang]

    Scripting

  • Resize swap partitions on Red Hat Linux

    Aug 12th 2008

    By: ben

    3 comments

    First of all a little disclaimer - although I've done this a few times and never had any problems, one should never consider resizing partitions a completely foolproof exercise. Things can go wrong. With regards to swap though, don't worry if your swap partition is destroyed as this will not harm your system - most healthy systems will not ever need swap and unlike Windows, Linux only starts using swap when it needs it and can quite easily survive without it. You can trash it and format it as many times as you like as long as it's not in use. And of course take backups of any important data first!

    Resize swap partition in Red Hat Linux

    • Is your swap on a logical volume (LVM)? If so then skip below to the LVM section. If not then read on:
    • Download gparted (Gnome Partition Manager), burn the iso and then boot into it.
    • Gparted will identify the filesystems on each partition so your target will be clearly labelled as swap.
    • Reize your partitions as required. Try to minimise the overall number of resize and move operations as this can take several hours to complete.

    When you reboot swap not be enabled - if you check using top (or htop) or free -m, you will see 0 mb of swap available. The reason for this is the UUID of the partition changed when it was resized by GParted, and this confuses the system when it tries to mount the volumes in /etc/fstab. The solution is to relabel your swap partition, by reformatting it as swap and specifying the correct label.

    fdisk -l | grep swap

    Note down the device name of your swap partition. e.g:

    /dev/cciss/c0d0p3 1926 3837 15358140 82 Linux swap

    Make a note of the label for the swap partition from fstab:

    cat /etc/fstab | grep swap

    e.g.

    LABEL=SW-cciss/c0d0p3 swap

    Now format your partition as swap, specifiying the label exactly as shown in the fstab.

    mkswap /dev/cciss/c0d0p3 -L SW-cciss/c0d0p3

    You can then enable the swap space straight away by using swapon devicename, or just reboot and check with free -m again, and all should be ok.

    Resizing swap on LVM
    If your swap partition is on a logical volume it can be resized without rebooting your system. However you will need free space to extend into, if you do not have free space you will need to shrink another volume or add another physical disk into your volume group (see this post which explains how to do this).

    cat /etc/fstab | grep swap
    /dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0

    lvdisplay will show you the size of your logical volume:

    lvdisplay /dev/VolGroup00/LogVol01
    
    --- Logical volume ---
    LV Name                /dev/VolGroup00/LogVol01
    VG Name                VolGroup00
    LV UUID                RVIFz3-B8kp-z9KV-JYtG-N997-JOQ6-ETaJaJ
    LV Write Access        read/write
    LV Status              available
    # open                 1
    LV Size                512.00 MB
    Current LE             24
    Segments               1
    Allocation             inherit
    Read ahead sectors     0
    Block device           253:1

    To resize an LVM you need to unmount it, or in this case swapoff.

    swapoff /dev/VolGroup00/LogVol01

    Resizing the volume to 768Mb (assuming you have the space to extend into)

    lvresize /dev/VolGroup00/LogVol01 -L 768M
    Extending logical volume LogVol01 to 768.00 MB
    Logical volume LogVol01 successfully resized
    
    swapon /dev/VolGroup00/LogVol01
    free -m
    total       used       free     shared    buffers     cached
    Mem:           375        343         32          0         48        120
    -/+ buffers/cache:        174        201
    Swap:          767          0        767

    Enterprise Linux

    Linux, Red Hat

  • bash vs vbs (bash wins)

    Aug 7th 2008

    By: ben

    No comments

    I've been asked by a group of users if they can have a daily report of everything the fax server has sent. Since the fax software we're using doesn't have this feature, I thought I'd write some vb script to pull all of lines containing yesterday's date from the log file (called sendlog.txt) and email them to a public folder. This took an hour or so to create and looks like this:

    [lang="vb"]Const ForReading = 1

    Dim fso, TempFile, yesterday, strSubject
    yesterday = Date - 1

    Set objRegEx = CreateObject("VBScript.RegExp")
    objRegEx.Pattern = yesterday

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    If (objFSO.FileExists("C:\temp\output.txt")) Then
    objFSO.DeleteFile "C:\temp\output.txt"
    End If

    Set objFile = objFSO.OpenTextFile("C:\Program Files\GFI\FaxMaker\sendlog.txt", ForReading)
    Set TempFile = objFso.CreateTextFile("C:\Temp\output.txt", True)
    Set wshShell = WScript.CreateObject ("WSCript.shell")

    TempFile.Write "Fax Server sendlog for " & yesterday & vbCRLF & "----------------------------------" & vbCRLF & vbCRLF

    Do Until objFile.AtEndOfStream
    strSearchString = objFile.ReadLine
    Set colMatches = objRegEx.Execute(strSearchString)
    If colMatches.Count > 0 Then
    For Each strMatch in colMatches
    TempFile.Write strSearchString & vbCRLF
    Next
    End If
    Loop

    objFile.Close
    TempFile.Close

    strSubject = "FaxMaker_Sendlog_" & yesterday
    wshShell.run "C:\monitoring\blat262\full\blat.exe" & " " & "C:\temp\output.txt" & " -to " & "myaddress@mydomain.com" & " -subject " & strSubject[/lang]

    Partial credit goes to the MS Scripting Guy who had already published part of this for me. Also you'll notice I called blat to email the file, which is considerably less complex than sending it in the vbs (or cheating, as some might call it) ... using vbs to send the message would have doubled the amount of code!

    To accomplish the same task using a bash script, you could do it like this:

    [lang="bash"]echo "Fax server sendlog for `date +%d/%m/%y`" > /tmp/tempfile.txt
    cat /var/log/sendlog.txt | grep `date +%d/%m/%y` >> /tmp/tempfile.txt
    mail -s "Fax Server log for `date +%d/%m/%y`" myaddress@mydomain.com < /tmp/tempfile.txt[/lang]

    Much simpler I think - only 3 lines of code!! People say Linux is harder than Windows but I think this proves that is not always the case. Manipulating files and data in Linux can take considerably less effort if you know which tools to use and how to use them.

    Scripting

  • Oracle RAC, CentOS and GFS

    Jun 24th 2008

    By: ben

    No comments

    One thing I'm currently working on is a 2 node CentOS cluster using GFS as the shared file system, with the storage on a fibre attached HP MSA SAN. This is a proof of concept before investing in RHEL AS licences (which will be the better part of £2000). CentOS is free and is intended to clone RHEL as closly as possible, removing the Red Hat branding and of course professional support. The cluster suite and GFS are available in CentOS as they are both open source.

    The hardware I am using is 2 HP DL580 G4 servers with 12GB of RAM, Qlogic HBA's, and an MSA1000 SAN. I'm using this guide on Red Hat's website and have been making my own notes along the way. I've got as far as installing cluster suite on one node but I'm unable to choose the grand unified lock manager as it doesn't appear as an option. I expect this may take a bit of reading to get working ... I'll post a mini howto here when I make some decent progress.

    A while ago I undertook a similar exercise and had problems getting the HP ACU to see the SAN under Red Hat, I had to get HP involved as there were specific versions of the kernel and drivers required for it to work properly. I've noticed I have the same problem time time, but now I am on CentOS and it's the x64bit version, so it looks like I will have to experiment with driver versions and see what I can get to work without any support this time.

    Enterprise Linux

    • <
    • 1
    • 2
    • 3
    • 4
    • 5
    • ...
    • 9
    • >
  • Subscribe

  • Recent Posts

    • Connect Skydrive as a Windows mapped drive
    • D-Link DWA-131 and Ubuntu
    • Configure a non-enterprise Blackberry handset for Exchange
    • Upgrading bugzilla from 3.0.x to 3.4.6
    • Compile your own droid – Part 1a
  • Spam Blocked

    12,952 spam comments blocked by
    Akismet
  • Recent Comments

    • Andrew Montague on How to purge an orphaned mailbox
    • Orval Eske on Configure automatic login on OCS 2007
    • ben on Vista: Run a script at shutdown
    • Jakob G on Vista: Run a script at shutdown
    • Jakob G on Vista: Run a script at shutdown
  • Categories

    • Android
    • Blackberry
    • Blogging
    • Desktop Linux
    • Enterprise Linux
    • Exchange
    • Messaging
    • Mobile
    • News
    • Nintendo
    • OCS
    • Random stuff
    • Rants
    • Scripting
    • Technology
    • VMware
    • Windows Servers
    • Windows Vista
  • Tags

    Active Directory Android Bash scripting BES Blackberry Bugzilla Cacti CentOS Citrix Desktop Linux DivX Dr DivX Enterprise Linux Google iptables K2 Wordpress 2.5 kickstart Linux Logical Volumes LVM Messaging Mobile N95 netfilter networking Open Source Performance Putty Random Rant Red Hat Red Hat Summit RHEL routing Scripting SSH thin client Ubuntu VBScript Video Encoding VMware Windows Windows Vista wireless
  • Tweets

    • @THErealDVORAK filezilla 2010/07/30
    • Office 2007 tip of the day. Ctrl+F1 hides the ribbon! Useful on a laptop screen. 2010/07/29
    • @Danielsaan what's demob? 2010/07/28
    • @Jedipottsy I haven't tried opendesire for about 3 weeks. Been using Pays froyo rom and it rocks. How about you? 2010/07/28
    • @Jedipottsy mythreed loads faster I think, there's not much in it though. Nice work btw! 2010/07/28

© Copyright ukstokes.com. All rights reserved.

Theme designed by Nischal Maniar