2011/03/05

Installing Debian GNU/Linux 6 from network using a USB flash drive and HP firmware for HP DL360 G7

UPDATE: A better way!

To install Debian GNU/Linux 6 in a server HP Proliant DL360 G7 using the network installer and a USB flash drive I wrote a shell script. Maybe you find it useful too.

You must know there is some proprietary firmware needed for the server to install (network at least).

After doing a little research, the know-how is in these sites:


http://wiki.debian.org/HP/ProLiant
http://wiki.debian.org/DebianInstaller/NetbootFirmware

In my case, the target architecture was amd64 (x86-64), but you would need some little modifications for any other architecture.

Before to run the shell script you need:

1- the network installer image from http://cdimage.debian.org/debian-cd/6.0.0/amd64/iso-cd/debian-6.0.0-amd64-netinst.iso

2- A USB flash drive (250 MB minimum).

3- A linux machine where you can run the shell script, I used a Debian GNU/Linux  Lenny.

The shell script is interactive, will download some files and write the USB flash drive. Be careful, data will be destroyed (after confirmation) because of formatting!

Remember to grant the needed permissions: chmod u+x script.sh


Use it on your own risk .



#!/bin/bash
function show
{
cat <<End-of-message
--------------------------------------------------
$0 TargetDevice TargetISO

Prepare a bootable pendrive with some HP Firmware!

Use it on your own risk.
-------------------------------------------------

End-of-message
}

##################################################################

show

# Validations

TARGET_DEVICE=$1
TARGET_ISO=$2
myPWD=$(pwd)

if [ $UID -ne 0 ]
then
    echo "You need to be root! (sudo?)"
    exit 3
fi

if [ -z "$TARGET_DEVICE" ]
then
    echo "You must specify the target device!"
    exit 1
fi

if [ -z "$TARGET_ISO" ]
then
        echo "You must specify the target iso!"
        exit 2
fi

echo "The current status of your device, beware any data will be destroyed!"

fdisk -l $TARGET_DEVICE

echo

ls -l $TARGET_ISO

echo

echo "Data will be destroyed!, press [Y] to continue"
read input

if [ "$input" != "Y" ]
then
    echo "Your answered [$input]"
    exit 0
fi

echo
echo "Creating bootable pendrive..."

if [ -n "$(mount | grep $TARGET_DEVICE)" ]
then
    echo "Unmounting $TARGET_DEVICE..."
    umount $TARGET_DEVICE

    if [ $? -ne 0 ]
    then
        echo "Error umounting the device!"
        exit 5
    fi
fi

if [ ! -e boot.img.gz ]
then
    echo
    echo "Downloading... boot.img.gz..."
    wget http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/hd-media/boot.img.gz
fi

echo
echo "Formatting..."

zcat boot.img.gz > $TARGET_DEVICE
rm -fr /mnt/pendrive.tmp
mkdir -p /mnt/pendrive.tmp
mount $TARGET_DEVICE /mnt/pendrive.tmp

echo
echo "Copying iso..."

cp $TARGET_ISO /mnt/pendrive.tmp/

ls -l /mnt/pendrive.tmp/*.iso

echo
echo "Updating the initrd.gz with HP firmware..."

# Make a temp dir and transform the firmware tarball into an firmware initramfs addon
FWTMP=$HOME/tmp/d-i_firmware
#rm -rf $FWTMP
mkdir  -p $FWTMP
cd $FWTMP

target=firmware.tar.gz

if [ ! -e $target ]
then
    wget http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/lenny/current/firmware.tar.gz
fi

tar -zxf firmware.tar.gz

if [ -z "$(which pax)" ]
then
    echo
    echo "Installing pax..."
    apt-get install pax
fi

for name in *.deb ; do
    ar -p $name data.tar.gz | tar -zxf -
done

pax -x sv4cpio -s '%lib%/lib%' -w lib | gzip -c >firmware.cpio.gz

# cd to the directory where you have your initrd
cd /mnt/pendrive.tmp

echo
echo "Backing up initrg.gz..."
[ -f initrd.gz.orig ] || cp -p initrd.gz initrd.gz.orig
cat $FWTMP/firmware.cpio.gz >> initrd.gz

ls -l initrd.gz*

cd $myPWD

echo
echo "Unmounting device..."

umount /mnt/pendrive.tmp

echo
echo "Done."



Ooops, I found this a little late :-|

No comments:

Post a Comment