1N/A# MaKe a Bootable IMAGE --- 1.44, 2.88 and El Torito no-emulation mode 1N/A# C) 2001,2002,2003 Thierry Laronde <tlaronde@polynum.org> 1N/A# C) 2001,2002,2003 Robert Millan <robertmh@gnu.org> 1N/A# This program is free software; you can redistribute it and/or modify 1N/A# it under the terms of the GNU General Public License as published by 1N/A# the Free Software Foundation; either version 2, or (at your option) 1N/A# This program is distributed in the hope that it will be useful, 1N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 1N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1N/A# GNU General Public License for more details. 1N/A# You should have received a copy of the GNU General Public License 1N/A# along with this program; if not, you can either send email to this 1N/A# program's maintainer or write to: The Free Software Foundation, 1N/A# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. 1N/A# $Id: mkbimage,v 1.19 2004/07/21 14:43:04 robertmh Exp $ 1N/A# You can set GRUB_PATH if you need to use a specially located GRUB. 1N/A# This MUST end by a '/'! 1N/A#----------------------------DON'T CHANGE: INTERNALS 1N/A# Name by which this script was invoked. 1N/AUsage: $program [-hVF] [-t TYPE] [-d DIRECTORY] [-s FS_TYPE] -f TAR_FILE 1N/AMake a Bootable IMAGE using GRUB as a bootloader 1N/A -d DIRECTORY [default CWD] 1N/A Name of the tar file containing the filesystem to install. Can 1N/A be a pure tar file [.tar] or a compressed tar file 1N/A Type of the file system to create on the virtual disk. Choices 1N/A ext2 on GNU [default is ext2] 1N/A Type of the image to create. Choices are '1.20', '1.44', '1.60', 1N/A '1.68', '1.74', '2.88' or 'hd' [default is hd] 1N/A Force to set the set_dpt flag (unnecessary 99% of the time! Be 1N/A turn Debugging on [xtrace] 1N/A display this Help and exit 1N/A display Version information and exit 1N/ACopyright (c) 2001,2002,2003 Thierry Laronde <tlaronde@polynum.org>. 1N/ACopyright (c) 2001,2002 Robert Millan <zeratul2@wanadoo.es>. 1N/AWritten by Thierry Laronde and Robert Millan. 1N/ACopyright (c) 2001,2002,2003 Thierry Laronde <tlaronde@polynum.org>. 1N/ACopyright (c) 2001,2002,2003 Robert Millan <zeratul2@wanadoo.es>. 1N/AThis is free software under the GPL version 2 or later; see the source for 1N/Acopying conditions. There is NO warranty, not even for MERCHANTABILITY or 1N/AFITNESS FOR A PARTICULAR PURPOSE." 1N/A then echo "The GNU/Linux supported fs are: ext2, minix or msdos!"; 1N/A then echo "The GNU supported fs is ext2!"; 1N/A wont_fit) echo "The files won't fit on the selected type of media!";; 1N/A# create a filesystem of type $fs in $image with offset $offset 1N/A elif [ `id -u` = "0" ] ; then 1N/A# copy ${image}1/* to ${image}:/, assuming ${image} contains a filesystem 1N/A# of type $fs in offset $offset 1N/A elif [ "`id -u`" = "0" ] ; then 1N/A#********************************************************************** 1N/A#********************************************************************** 1N/A#---------------------- Getting the options 1N/A#---------------------- Sanity checks 1N/A# Carlo Contavalli reported that I [TL] have forgotten to specify the 1N/A# partition ID for sfdisk to correctly fill the partition table (ext2 is the 1N/A# default on Linux, so this worked in this case...). This is fixed below. 1N/A# ufs) if [ $uname = Linux ]; 1N/A# then error unknown_fs; 1N/A# What type of tar file has been given ? 1N/A#---------------------- Initializations 1N/A# First, find the size of the tar file in block_size. 1N/A# Increase in order to be sure that with a fs there will be enough 1N/A # Create the minimum number of cylinders. At the moment, we leave 1N/A # some space by rounding everything up by adding 1 cylinder, plus 1N/A # another one for MBR + reserved track. 1N/A# We start by creating a virtual disk which size is the number of 1N/A# cylinders of $cyl_size mandatory to put the files stocked in the $tarfile 1N/A# Create the empty virtual disk 1N/A# We then format the virtual disk 1N/A# NOTE: the El Torito specification wants only one partition. So we 1N/A# create the first, and the remaining 3 entries are empty. 1N/A# It's time now to create the filesystem on the first partition. 1N/A# then untar the files 1N/A[ ! -e ${
image}
1 ] ||
{ echo "${image}1 exists, please remove it first"; exit 1;} 1N/A# copy the untarred files into the filesystem image 1N/A#We verify that the stage2 exists and we search the name 1N/A#------------------------- GRUB stuff 1N/Ageometry $device $cylinders $heads $sectors 1N/Ageometry $geo_option -w $type_option $device $cylinders $heads $sectors 1N/Aecho "-------------------WHAT'S NEXT?-------------------------------------" 1N/AIf you have created an image aimed to a floppy, then something like: 1N/Add if=<type>.image of=/dev/fd0[u<size>] bs=512 1N/Awill be more than enough... if you have formated the floppy correctly 1N/Ausing \`superformat' to be found in \`fdutils' package. 1N/AFor El Torito floppy emulation : 1N/Amkisofs -b <image> -c boot.catalog -o raw.iso <dir> 1N/AAnd for El Torito Hard Disk emulation: 1N/Amkisofs -b <image> -hard-disk-boot -c boot.catalog -o raw.iso <dir>