Deployment Solution

 View Only

Install Grub Through Automation Environment 

Feb 19, 2010 01:10 PM

PURPOSE: I was looking to write a script to install grub from bar metal to grub. This was I can replace the vmlinuz and initrd for any type of linux scripted OS install. In theory make a linux flavor indepented scripted os job.

I have a script that wipes the drive with DD, setup the partition with mke2fs and then a grub script to install grub.

REQUIREMENTS: Linux automation , grub install files, and mke2fs.

the grub files have to be inserted into the automation environment and so does the mke2fs to partition the drive to ext2


roo#!/bin/sh
##Setup Grub Partition##
###############USER SECTION#################
DRIVE=/dev/sda
PART=$DRIVE1

###########################################
#DO NOT EDIT BELOW THIS SECTION############
###########################################
##wipes the MBR and not the whole drive.
echo "deleting the existing drive, this will loose all data"
dd if=/dev/zero of=$DRIVE bs=446 count=10

sleep 10
fdisk $DRIVE << _EOF
n
p
1
25
+100M
w
_EOF
sleep 20
##formats drive to ext2 and copies the grub files to production drive.

mke2fs $DRIVE1
mkdir /mnt/setup
mount -t ext2 $PART /mnt/setup
cp -R /boot/* /mnt/setup/

/sbin/grub --batch <<EOT 1>/dev/null 2>/dev/null
root (hd0,0)
setup (hd0)
kernel  /vmlinuz initrd=/initrd.img
quit
EOT

sleep 50

 

#sleep 200

#cat > /mnt/setup/boot/menu.lst <<EOF1
#kernel /vmlinuz vmkopts=debugLogToSerial:1 mem=512M ksdevice=vmnic0 ks=http://%#*"select tcp_addr from dbo.aclient_prop where computer_id=0"%/ESX4/Kickstarts/%ID%.cfg
# initrd /initrd.img
#EOF1
 

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Oct 01, 2015 11:13 AM

Just a note for anyone finding this, like I did, and having issues with GRUB using the configured menu. The latest version of the Linux PXE platform provided by Altiris/Symantec will not use menu.lst which is apparently an older default. So the script needs to be altered to write to grub.conf intead of menu.lst.

Aug 10, 2011 08:59 AM

Thanks for the great idea.

I was looking for a way to avoid using DOS to launch the GRUB boot loader. I got GRUB4DOS to launch through WinPE too but so much simplier using the Linux Automation environment.

Only thing I had to do though was to modify the script to create the menu.lst before GRUB is setup, otherwise grub does not know what to launch.

Feb 19, 2010 02:50 PM

Nice concept and script

Related Entries and Links

No Related Resource entered.