![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 2
Rep Power: 0
![]() |
fedora USB create boot image script
I'm sure I'm going to get an rtfm but what the heck. First of all I'm a total noob.
I don't have a dedicated machine to test fedora betas so I run it on my USB drive. after getting tired of typing everything in to create a kernel image i decided to create a script. my script works but I want it to be even easier than it is now. Here's what I'm using. #!/bin/sh # writen by Kevin dePfyffer - kdepfyffer@depfyffer.com # because I was tired of typing it all in :-) ls /lib/modules echo "enter the kernel version you would like to use" read kernel /sbin/mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod /boot/initrd.''$kernel''.usb.img ''$kernel'' echo "please update your /boot/grub/grub.conf before you reboot" Is there any way for me to create a menu (1. 2. 3. etc) from the ls command then use read and an if statement to get $kernel. bonus question, how can I pipe something like this to the end of grub.conf (without overwriting of course) title Fedora Core ("$kenel"-usb) root (hd0,0) kernel /vmlinuz-"$kernel" ro root=LABEL=/ rhgb quiet initrd /initrd.''$kernel''.usb.img |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2005
Posts: 2
Rep Power: 0
![]() |
[solved]
I was able to solve the first part by reading about 5 different how-to's and lifting a few portions of other scripts. I can tell I'll never be a programmer but thats ok, I get by :-)
I would still like some help on piping some text to grub.conf if anyone can help me out with that. Here's the final code that is working. #!/bin/bash
# easy way to create a initrd image to boot a USB drive in Fedora Core 3 or 4
# has not been tested on any other OS
# Written by kevin dePfyffer - kdepfyffer@depfyffer.com
ls -1 /lib/modules > /tmp/kernel.lst # populate the kernel list
kernel_list="/tmp/kernel.lst" # set Kernel list
n=0 # make sure the counter doesn't contain randome values.
while read; do
Kernel[$n]=$REPLY # Put the directories in an array
echo "$n) ${Kernel[$n]}" # create the menu
n=$(( n + 1 )) # increment the menu
done < $kernel_list # input the read statement
echo "Enter the number of the kernel you would like to use"
read
if [ ! -z $REPLY ]; then
Choice="${Kernel[$REPLY]}"
echo "you chose to use $Choice"
fi
/sbin/mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod /boot/initrd-''$Choice''.usb.img ''$Choice''
rm /tmp/kernel.lst
echo "please update your /boot/grub/grub.conf before you reboot"If you see any problems with the script/format please let me know. |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
echo $DATA >> /boot/grub/grub.conf
cat $DATA >> /boot/grub/grub.conf The >> is used to append to the end of a file.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|