Multi-Boot Vista + ArchLinux with GRUB

Posted by John
on Thursday, 20 March 2008

After setting up my new HP laptop with Vista and ArchLinux I thought I'd post how to replicate the same setup to help anyone else wanting to do the same, so here's a guide to do this with the latest Windows Vista and Arch Linux; enjoy!

Install Windows Vista

Vista

First off install Vista. Now when it gets to asking you about how much disk space to use, say half (250gb drive => 128gb approx), this will mean the other half will be unused space (perfect for your linux build).

Install Vista and set it up, when you're happy and it's running ok continue to the next step.

Get ArchLinux

By now you should have two hard-drive partitions, one with Vista (NTFS) and one blank; now we're going to sort that second one out.

First download the relevant ISO disc image,

Download it and burn it to CD, it's only 120mb so shouldn't take too long. Once done insert it into your laptop and re-boot with it so it starts up the installer on bootup.

Install ArchLinux

ArchLinux

When the installer boots up and shows the blue install screen you'll see 6 options, let's go thru each one...

1. Prepare Hard Drive

Don't choose Auto-Prepare, it'll wipe your hardrive and destroy Vista, select Partition Hard Drives which will put you in the disk partition tool.

You should see two entries, one will be...

1. [boot] [primary] [ntfs]
2. ...... [unknown] [unknown]

The first is setup as the boot partition (the one which will boot on startup) and you know it's Vista as the filesystem is marked as NTFS, the other is unknown; our target for the Linux install.

So select the unknown one and create, mark it as a primary partition, select write to write the change and then quit to continue. Note the name of the new partition (e.g. hd0/sda2) and goto step 2.

Note: SDA = SATA, the machine i'm using has SATA drives, if you've got older IDE drives it'll be HDA0.

2. Set Filesystem Mountpoints

With this we'll want to set which partition we want to use as a swap disc, but as we didn't create one, select none.

Next you'll be asked which partition will be used as the root one for this install, select hd0/sda2 (or whichever name you wrote down in step 1). Continue to step 3.

3. Select Packages

Here we select which packages we want to install, ArchLinux is broken up into 4 separate blocks; base being the core o/s. Select all four as we'll be wanting all the tools to practice (otherwise you can choose 'base' and customise later). Step 4...

4. Install Packages

This will install ArchLinux to your target FileSystem, shouldn't take long; once done goto 5...

5. Configure System

Now configure your system, with most options choose the defaulty chosen options; afterwards your configuration will be written to the new system. Now onto the important step 6.

6. Install Bootloader

Now we'll install the bootloader to allow you to select on-bootup which O/S to start. Choose GRUB as your bootloader, you'll then be taken to the bootloader's config file.

Scroll down to the bottom of the file and uncomment the bottom entry until it resembles...

# (2) Windows Vista
title Windows Vista
rootnoverify (hd0,0)
makeactive
chainloader +1

This will add to your selection list an entry pointing to your first partition so you can select to boot Vista. Scroll up to the top of the file and check these lines, adjust as appropriately...

  • timeout 5 ...this sets the seconds to wait until booting the default entry

  • default 1 ...once the timeout expires GRUB will boot the option 1, ArchLinux, if you want to boot Vista instead, change it to 2.

  • fallback 0 ...if the default can't be booted, the fallback will be started, in this case the ArchLinux FallBack system created when we just installed ArchLinux (think of it as it's Linux's safe-mode, only much more powerful).

If you're happy with the setup, press CTRL+X to save the file and continue.

You'll next be asked where to place the Bootloader, we want to place it inside the MBR of the Drive so it will be launched when the disc spins up. The MBR is the first sector of the Hard Drive and commonly called the Master Boot Record.

You'll be presented with probably 3 options...

/SDA
/SDA1
/SDA2

Choose the first, this will be where the MBR is located.

Now you're finished, exit the Installer by selecting Exit Install, then type REBOOT to reboot.

The computer should restart and present you with the GRUB bootloader menu, where you'll now be able to select which O/S to start; job done.

Setting ROOT Password

Please note that with this initial install your ROOT account won't have a password assigned to it, posing a poblem later on down the line.

So when you've booted into ArchLinux, and typed 'root' as the username and hit ENTER to login, type...

passwd

To set the 'root' account's password.

Changing The Config

To edit the GRUB config later on, do...

nano /boot/grub/menu.lst

Settings

So as you know, the system config files are located in...

  • /etc/rc.conf (main system config)
  • /boot/grub/menu.lst (grub boot menu)
  • /etc/lilo.conf (lilo boot menu)
  • /etc/mkinitrd.conf
  • /etc/hosts
  • /etc/fstab
  • /etc/modprobe.conf
  • /etc/modules.conf
  • /etc/resolv.conf
  • /etc/conf.d/*
  • /etc/profile

Building a 1U Server, Part 2

Posted by John
on Sunday, 02 March 2008

After a night-long search for parts and voltage configurations I've wound up with a pretty nice shopping list.

Discussion

Started a little discussion over in my favourite Ruby Forum about the subject, really impressed by what some of the guys have offered.

But Power?

Yep that's an issue, the whole 0.5A issue is primarily down to the colo provider. Normal servers run at 1.5 to 2.0A power usage and cost a fair bit to run, however if you can build a server within the 0.5A limit then the cost is less and hence the provider i've chosen charges less.

The trick is building a box which gives you a decent amount of power within the limit, thankfully though with things the way they are there's suddenly a lot of low power options available which still give you a lot of bang for your buck; so the challenge shouldn't be that big a deal.

How Much Power?

So 0.5A is 120 watts (aka 120 volts). Problem is most PSU's don't run at full capacity, so you're probably dealing with 85 watts in all; so be careful what you choose, over-estimating each part to be sure.

If it says only 45w, mark it down as 50w just to give yourself some room.

Ok, What you Buying?

Here's the shopping list...

CPU: AMD A64 3600 X2 AM2
cost: 45w

After tracking down specs from various sources I've found this processor only sucks around 45w of power at full steam. It's judged by it's TDP, Thermal Design Power; the maximum cost the cpu would use running serious apps. The new AM2 socket processors run at a lower power so a good choice to keep the consumption down. The AMD chips also include Cool-n-Quiet which is an essential part of this plan, something that shouldn't be ignored as it keeps the processor running cooler and with lesser power drain under severe conditions.

BOARD: ASUS M2A-VM (HDMI)
cost: unknown (reckon 10w)

Don't know about the connector, may have to get an HDMI > VGA adapter to plug it to my LCD but this board is rated pretty good. It's got an onboard graphics card (ATI), and enough slots for the memory sticks and SATA drives. The nVidia chipsets draw more power so avoid those.

HDD: WESTERN DIGITAL SCORPIO 320GB SATA
cost: 2.5w each (5w total)

These baby's are actually tiny laptop hard drives from Western Digital, my prefered HDD supplier, and run at a lower voltage to be really hit the mark. Normal drives will soak up 8-9w of power and make more heat. These will be setup in a RAID 1 (mirrored) configuration, giving me a dynamic backup copy of the O/S + Files; if one goes down the other takes over and being small they shouldn't heat up too much.

MEMORY: CORSAIR XMS2 DDR2 2GB PC2-6400 x2
cost: 1.2w each (2.4w total)

I haven't had much problem with Corsair sticks in the past, they've usually been pretty reliable so these should fit the bill well. They're low-power chips so shouldn't draw that much power and run fast giving less of a chance of bottlenecking the system at it's most critical point, matched and they should run smoothly.

HEATSINK: Dynatron A48G
cost: 8.4w

This little buddy can easily cool the cpu down to optimum temperatures and blow air thru the side, specifically for 1U cases as we don't have much height to play with; a 1U case only being 1.75" high from the board.

In total the parts i've chosen should total...

2.4w + 5w + 10w + 45w + 8.4 = 70.8w

Nice and with my headroom of Max 120w and Min 85w sounds about right, factor in a couple of fans soaking up 1.5watts each and I should be within the grounds.

Choosing laptop hard-drives also reduces the heat dissipated, as the hotter things run the more power they soak up; especially true for the CPU as at 45'c it'll soak 40w and 60-70 it'll soak 60+w.

Still hunting for the perfect fit, sometimes this really feels like Apollo 13 territory,

Technician: How much power have we got to work with?
John Aaron: Barely enough to run this coffee pot for nine hours

Building ImageMagick 6.3.8 from source

Posted by John
on Sunday, 02 March 2008

Because Ubuntu 7.10 repositories don't have the latest version of ImageMagick, stopping you install the latest RMagick Ruby Gem; here's a guide to help you build it from source.

What had Gone Before

Before all this, I had installed the old version of ImageMagick by,

sudo apt-get install imagemagick
sudo apt-get install libmagick9-dev

So as you know before you start.

Remove ImageMagick

First off you're gonna have to remove your old copy of ImageMagick...

sudo apt-get remove imagemagick

Building & Installing ImageMagick 6.3.8

Now we're going to get the latest source files for ImageMagick and configure them correctly.

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.3.8-11.tar.gz
tar xvvzf ImageMagick-6.3.8-11.tar.gz
cd ImageMagick-6.3.8-11

Now we're in the source directory, G

./configure --prefix=/usr

Excellent, let's build...

sudo make

This will take a while, you may get a few warning pop up but hopefully no show-stoppers; afterwards lets install...

sudo make install

Rmagick Gem

And finally the latest RMagick Gem..

sudo gem install rmagick

If this still fails, you can install the old gem with..

sudo gem install rmagick -v=1.15.12

But fingers crossed let hope the new one works

Did it work?

Yes it all installed, and I've now got the RMagick 2.2.2 gem running on Ubuntu 7.10

So, What does it support?

Simple to find out, run the command below to see what version of ImageMagick you've got and what it can support.

identify -list format

Building a 1U Server

Posted by John
on Saturday, 01 March 2008

Shocked my boss yesterday after telling him i'm building my own rackmount server, well i've built machines for about 20 years and most of those have been custom jobs with 3 running Ubuntu Server for my Rails projects so doing this is the next logical step.

Here's the things I've dug up, which should help you out if you ever decide to go down the same route.

Co-location + Power Limit

For this I've found a company in Manchester (uk) who will host it for me at £32 a-month as long as the power usage doesn't spike over 0.5A

So with a few calculations, that gives me...

0.5a => 120 watts

The company is called RapidSwitch

Case

Next up the case and I've gone for a SuperMicro 1U case, problem is I need specific boards to slide in and so this...

M2N-MX SE Plus

But still looking around for the perfect fit.

Processor

This will probably be an AMD 64 dual core CPU, as they're power efficient, reliable and the O/S i'm choosing (Fedora 8) fits rather well with them.

PSU

For this I'm sourcing the most power efficient model as most PSU's only run at 50-60% operating efficiency.

CPU Heatsink

ThermalTake have a good array at...

Not sure about the availability but your 1U case is 1.75" high so it's a big factor.

HDD

I'm picking 2x 500gb Western Digital Caviar drives, I've always used them, they're not special but reliable.

This'll go in a RAID 1 configuration similar to my NAS box at home, doubling the HDD read speed but lowering the write speed due to the mirroring, reliable though.

Memory

2 sticks of 2gb memory, I'd choose Samsung as they're cheap and just work but having trouble sourcing the OEM sticks, may just go with some corsair sticks.

Power Calculator

Found a power calculator which should give me a judge on how much power I'm gonna be using,

Probably not that accurate but gives me a ballpark figure, with the hardware I've chosen:

  • AMD Athlon 64 X2 5000+ 2600 CPU AM2
  • 2x WD SATA Drives
  • 2x DDR2 2GB Sticks
  • (graphics card on-chipset)
  • 1x 80mm fan, 2x 120mm fans

All comes up to needing a PSU of 177 watts, which fits in with my Sparkle low-power 220w PSU but might be a might too high for the power coming in.

Finally

It's a learning process and one that'll probably not be as easy as it looks but worth the effort for the experience.

Apache 2.2 + PHP on a MacBook ?

Posted by John
on Monday, 19 November 2007

Being a developer and today being my trip to the dentist (and a day off work), I tend to get bored really really easy.

And knowing tomorrow I've got to work with JSON I thought I'd show you how easy it is to install and compile Apache 2.2 Web Server and Enable PHP 4 on your MacBook, so you can get to and build PHP apps natively on OSX.

Now obviously you could download MAMP to get up and running fast, but really that's just not geeky enough for us hard-core developers, so let's begin.

Apple Developer Tools Required

Yes, to build from source you're going to need the GCC compiler which can be obtained for the Apple Developer Connection website (free), search my searchbox for a link otherwise just download from their site.

Apache 2.2

Installing Apache 2.2 Web Server

First goto the Apache site and download the latest sourcecode to your desktop.

Once downloaded, do the following in your TERMINAL window;

cd desktop
gnutar -xzf httpd-2.2.6.tar.gz
cd httpd-2.2.6

Now we've untar'd it to the desktop and have navigated into it, let's build from source.

Run this to setup the sourcefiles for your machine and build spec,

./configure --enable-module=most --enable-shared=max

Now compile the sourcecode, and install

make
sudo make install

Bingo, you now have Apache 2.2 (or whatever version your downloaded) installed on your MacBook.

Starting & Stopping Apache2

Start with...

sudo /usr/local/apache2/bin/apachectl restart

Stop with...

sudo /usr/local/apache2/bin/apachectl stop

Running PHP on OSX

Enabling PHP 4 ?

Now every MacBook comes with PHP4 installed as standard, it just waits until you enable it to work.

So to enable it, type in TERMINAL;

cd /etc/httpd
sudo mate httpd.conf

This will navigate to the httpd Apache config file and open it's INI file in TextMate (I'm baised but you can use NANO or TextEdit if you like to edit the file).

When you've got the file open, search for 'PHP' anywhere in the file.

You should see two occurences, commented out with #'s remove these to enable PHP.

# LoadModule php4_module libexec/httpd/libphp4.so
# AddModule mod_php4.c

Now save and close the file

And restart Apache

sudo apachectl restart

Stop with...

sudo apachectl stop

Hang on this isn't Apache 2.2?

Now what this will do is startup your Mac's native Apache server (which isn't 2.2), sorry but I haven't worked that one out.

Your fresh 2.2 build will also have an *httpd.conf file in...

cd /usr/local/apache2/conf
sudo mate httpd.conf

To edit it's config file, sorry I haven't an answer at the moment but I'll figure it out.

Next question,

Where to stick my WebPages?

First make sure Personal Web Sharing is enabled in System Preferences / Sharing.

Next in your user directory (or the first directory you appear in when opening TERMINAL), create a directory called...

mkdir Sites

Now everything you stick in this directory will be acted upon like it's a website (including PHP).

To test your PHP setup works, create a file in there called test.php and add this in it...

<?php phpinfo() ?>

Now before you leave System Preferences / Sharing, click the info link by Personal Web Sharing.

This will display a dialog and at the bottom of this will be some web addresses, the one's for the web server running on your machine!

Click on one and bookmark the link.

Add /test.php to the end and run it in Firefox or Safari, you should now see the version of PHP installed on your system.

Well done, you have now successfully installed PHP and Apache2 from source on your MacBook.

Enjoy and when I can figure out how to replace Apple's native 1.3 Apache server with 2.2 I'll let you know, but for now it works.