Author Archive

  1. Resizing ext3 or ext4 partition for virtual image

    Note: please backup and make sure that you have a copy of your data and virtual images, this can go wrong and I won’t be held responsible. This worked for me, and might not work for you. For ext4 please use the latest GParted.

    As I migrated from raw or qcow images, some of the partition sizes that I have to work with are not as big as they could be. So I need to resize.

    I generally give some of my hosts a 24Gb LVM virtual group each. But the image files can be as small as 2Gb – A lot of wasted space which the filesystem on the image might as well have. These instructions assume that there are only two partitions, a main partition, and a second linux swap partition (either on an extended partition or a primary).

    First taken the image offline, then get the name of image that you wish to resize, then the disk storage items:

    [cc lang="bash"]
    ls /etc/vm/
    lvdisplay
    [/cc]

    In my case it was “/dev/vdisk05/vm-102-disk-1″. Then you can check to see how large the volume group is set to (vgdisplay) resize:

    [cc lang="bash"]
    lvresize -L 23G /dev/vdisk05/vm-102-disk-1
    [/cc]

    Next I mount a SystemRescueCD on the CDRom, and make sure its the first item in the boot sequence. Then boot into the system, go for the first choice in SystemRescueCD, and it will give you a rootprompt (I am VNC’ing into the system so that I can access the console as if using a physical machine):
    [cc lang="bash"]
    #Change the passwd so that you can ssh in if you need to.
    passwd
    #Start the GUI so you can run Gparted (First choice again).
    wizard
    [/cc]

    From a command prompt do (check file system, repair, remove journal):

    1. fsck -n /dev/sda1
    2. e2fsck -f /dev/sda1
    3. tune2fs -O ^has_journal /dev/sda1

    Then do the following in the GUI:

    1. Choose CD > System > GParted
    2. Delete the swap partition as it will be the last
    3. Resize partition, leaving some space for a new swap partition
    4. Create a swap (type linux-swap) partition twice the size of the amount of RAM you allocate to the image
    5. Click Edit > Apply all operations
    6. Close GParted

    Back on the command prompt do (repair, check file system, journal, shutdown):

    1. e2fsck -f /dev/sda1
    2. fsck -n /dev/sda1
    3. tune2fs -j /dev/sda1
    4. shutdown -h now

    Remove the CDRom device, and change the boot order back then start the Virtual machine. Issue a df -h to see if the partition has changed. It should have done!

    By timc3 on the
    May 2nd, 2011
  2. Virtual host QCow convert to LVM

    Sometimes its better to have your virtual images running directly of LVM instead of using raw or QCow formatted files. So how do we convert? Basically you have to make sure that you have a volume group, of the right size or bigger and then dd the file into a LV on that volume group:

    This should in the directory where you have the image:

    [cc lang="bash"]
    # Get the filesize of the raw image in Kilobytes.
    ls -lk
    #Create lv on vdisk05 (the VG)
    lvcreate -L 5242880K -n vm-102-disk-1 vdisk05
    #Convert from QCow to Raw
    qemu-img convert bld-ubuntu-1004-2.qcow2 -O raw bld-ubuntu-1004-2.raw
    #Copy the image into the lv:
    dd if=bld-ubuntu-1004-2.raw of=/dev/vdisk05/vm-102-disk-1
    [/cc]

    Then change the configuration of your QEMU or whatever you are using on your virtualisation platform.

    Sorry for the briefness of the instructions, its mainly for my own benefit and if you are doing this you should really know about LVM, dd and ls.

    By timc3 on the
    May 1st, 2011
  3. Damn nice bag

    They people have some damn nice bags:

    http://shop.hardgraft.com/bags/2unfold-laptop-bag-brown

    By timc3 on the
    April 27th, 2011
  4. Webcasts to watch

    Recently I was unfortunately quite ill and away from work for an extended time, the only upside being that I had some time to spend learning some new things and watching web conferences on my Apple TV2. Of those that are of interest, I am going to note them down here:

    * LeWeb – Really quite good, european focused web event
    * PyCon 2011 – A must watch for anyone using Python.
    * JSConf – Good Javascript conference, though I got the feeling that it wasn’t quite as friendly as Pycon.
    * Webstock – New Zealand conference.
    * Future – Some interesting interviews.
    * Google Techtalks

    Of course I also watched quite a lot of Ted videos.

    I will keep adding to this list as I find more events to add, as there must be quite a few now.

    By timc3 on the
    April 15th, 2011
  5. My Jenkins nginx proxy script

    Here is a very simple configuration for nginx to proxy Jenkins (the new name for the un-Oracle’d Hudson)
    [cc lang="bash"]
    server {
    listen 80 default;
    server_name bld-master localhost;
    root /var/lib/jenkins;

    access_log /var/log/nginx/jenkins.access.log;

    location / {
    proxy_pass http://127.0.0.1:8080/;
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    }
    [/cc]

    By timc3 on the
    April 15th, 2011
  6. Setting MAC Addresses on Debian and Ubuntu

    I recently had a problem with having duplicate MAC addresses on my network for a couple of machines that I was using in a Linux KVM cluster. Flashing the firmware on the motherboards seem to have reset the MAC address to a default (thanks ASUS) that was the same on each board.

    Changing the MAC address back seems like quite a hard job and looking around on the internet it seems that many people are doing this the hard way with shell scripts and so forth. Instead its easy enough to do this using the scripts that are already setting up the network for Debian (and I am sure this will work for Ubuntu just as well).

    Edit /etc/network/interfaces like so:

    [cc lang="bash"]
    auto eth0
    iface eth0 inet manual
    pre-up ifconfig $IFACE hw ether 00:01:02:03:04:05
    pre-up ifconfig $IFACE up
    pre-down ifconfig $IFACE down
    [/cc]

    What this is doing is manually controlling the startup and shutdown of the eth0 interface. I am using bridging on my KVM boxes, so I don’t actually have to set up the IP address (albeit DHCP or manual IP configuration), but that aside the interesting parts are what happens in pre-up. Firstly I set the hardware address to a new address (and please change it from the example above – thats not the actual one I used either), then we tell it to bring the interface up.

    We also use pre-down to tell it what happens when stopping the network service.

    Probably better than messing around with Shell scripts.

    By timc3 on the
    April 14th, 2011
  7. Slow disks on MacBook Pro

    I really like my MacBook Pro, but I have no idea why they ship with a 5400RPM 2.5″ slooooow disk. Even with the i5 processor it makes everything crawl.

    Part of my standard software stack now is Dropbox, PostgreSQL and CrashPlan. All pieces of software I am really happy with, except they all access the disk all the time.

    fs_usage is a command you can run to see what is current accessing the disk in OS X to see what is slowing down that already slow disk.

    By timc3 on the
    March 22nd, 2011
  8. 2010 – 2011

    EDIT This post has been in draft for ages, I think I am just going to post as is, was going to add lots more personal stuff, but blah – rather do it instead.

    I think most years I have been doing a summary, something I might revisit if I have the time. Instead I think its perhaps more interesting to think about what I might be doing this year instead.

    Websites

    Some of the websites I think I will be visiting more often:

    Work

    Probably going to be redefining Portal, our main product at Cantemo – not only form a design point of view but also in how the code is structured (my Javascript are improving to the point where I have noticed where I can make lots of cool improvements).

    Also probably looking into some other products to go along with Portal and to increase our sales channels.

    By timc3 on the
    February 22nd, 2011
  9. WebM/VP8 and H.264

    This is probably the best over article on the whole WebM/VP8 and H.264 issue:

    http://antimatter15.com/wp/2011/01/the-ambiguity-of-open-and-vp8-vs-h-264/

    Well worth a read.

    By timc3 on the
    January 19th, 2011