home *** CD-ROM | disk | FTP | other *** search
/ Login Magazine 68 / LoginMagazineNo68.bin / kernels / makedisk < prev    next >
Text File  |  1999-11-07  |  4KB  |  131 lines

  1. #!/bin/sh
  2. #define Q+D
  3. #
  4. # This makes a bootkernel disk in /dev/fd0 from a kernel image.
  5. #
  6. # Run this in a directory containing the kernels you're gonna use, and a
  7. # subdirectory with a master image of the bootkernel disk.
  8. #
  9. # This is the command to use:
  10. #
  11. # makedisk kernel_image disk_size
  12. #          ^^           ^^^^^^^^^ This is 1440 or 1200
  13. #          ^^^^^ This is the name (and maybe path to) the kernel you're going
  14. #                to use, such as scsinet/scsinet.
  15. #
  16. #
  17. KERNEL=$1
  18. DISKSIZE=$2
  19. FSSIZE=`filesize $1`
  20. FSSIZE=`expr $FSSIZE + 180112`
  21. FSSIZE=`expr $FSSIZE / 1024`
  22. TARGET=/dev/fd0
  23. MASTER_DIR=/tmp/master-$$
  24. CWD=`pwd`
  25. MOUNT=/tmp/mnt-$$
  26. if [ ! -d $MASTER_DIR ]; then
  27.   mkdir -p $MASTER_DIR
  28.   ( cd $MASTER_DIR ; tar xzvf $CWD/master.tar.gz )
  29.   DELETE_MASTER=true
  30. fi
  31. if [ ! -d $MOUNT ]; then
  32.   mkdir -p $MOUNT
  33.   DELETE_MOUNT=true
  34. fi
  35. if [ $DISKSIZE = 1200 ]; then
  36.  cp lilo.conf.1200 $MASTER_DIR/etc/lilo.conf
  37.  RAMSIZE=1200
  38. elif [ $DISKSIZE = 1440 ]; then
  39.  cp lilo.conf.1440 $MASTER_DIR/etc/lilo.conf
  40.  RAMSIZE=1440
  41. else
  42.  echo
  43.  echo "Usage: makedisk kernel_image disk_size"
  44.  echo
  45.  echo "Disk is made in /dev/fd0. Target disk must be formatted."
  46.  echo "Legal disk sizes are 1200 and 1440."
  47.  echo
  48.  exit
  49. fi
  50. if [ -r $1 ]; then
  51.  echo "Making a bootkernel disk from kernel image $1..."
  52. else
  53.  echo "Image $1 not readable."
  54.  exit
  55. fi
  56. cp $1 $MASTER_DIR/vmlinuz 
  57. cat `dirname $1`/config | gzip -9c > $MASTER_DIR/config.gz
  58. cat `dirname $1`/System.map | gzip -9c > $MASTER_DIR/System.map.gz
  59. RESULT=$?
  60. if [ ! $RESULT = 0 ]; then
  61.   echo "Fatal error on $MASTER_DIR..."
  62.   read junk_input;
  63. fi
  64. LABEL=`dirname $1`
  65. cat << EOF > $MASTER_DIR/boot/message
  66.  
  67. Welcome to the Slackware Linux (v. 7.0.0) $LABEL bootdisk!
  68.  
  69. If you need to pass extra parameters to the kernel, enter them at the prompt
  70. below after one of the valid configuration names:  ramdisk (to load a rootdisk
  71. into memory and boot it), and mount (to boot an existing Linux partition).
  72. NOTE:  Most hardware is auto-detected without parameters.  So, before assuming
  73.        your system requires parameters, try a few different bootdisks. :^)
  74.  
  75. Here are some examples (and more can be found in the BOOTING file):
  76.    ramdisk hdx=cyls,heads,sects,wpcom,irq  (needed only if probing fails)
  77.    ramdisk hdx=cdrom (force detection of an IDE/ATAPI CD-ROM drive)
  78.    where hdx can be any of hda through hdh. Examples: hdc=1050,32,64  hdd=cdrom
  79.  
  80. If you would rather load the root/install disk from your second floppy drive:
  81.    ramdisk root=/dev/fd1
  82.  
  83. In a pinch, you can boot your Linux system with a command like:
  84.    mount root=/dev/hda1
  85.  
  86. DON'T SWITCH ANY DISKS YET! This prompt is just for entering extra parameters.
  87. If you don't need to enter any parameters, hit ENTER to continue.
  88.  
  89. EOF
  90. echo "Rdeving -R $MASTER_DIR/vmlinuz 0"
  91. rdev -R $MASTER_DIR/vmlinuz 0
  92. #echo "Rdeving -r $MASTER_DIR/vmlinuz $RAMSIZE"
  93. #rdev -r $MASTER_DIR/vmlinuz $RAMSIZE
  94. echo "Rdeving rdev -r $MASTER_DIR/vmlinuz 49152"
  95. rdev -r $MASTER_DIR/vmlinuz 49152
  96. echo "Rdeving -v $MASTER_DIR/vmlinuz -v"
  97. rdev -v $MASTER_DIR/vmlinuz -1
  98. # It's possible some people might want to use /dev/fd0h1200 or /dev/fd0H1440
  99. # on the line below...
  100. echo "Rdeving $MASTER_DIR/vmlinuz /dev/fd0"
  101. rdev $MASTER_DIR/vmlinuz /dev/fd0
  102. #echo "Formatting the target disk..."
  103. #fdformat /dev/fd0H1200
  104. echo "Blanking the target disk..."
  105. dd if=/dev/zero of=$TARGET bs=1024 count=$FSSIZE
  106. echo "Making the MINIX/Linux filesystem..."
  107. # Let's use a 600K size, since that's good enough for the kernel + utilities
  108. # needed to boot... then we can reduce the size of the uncompressed disks.
  109. mkfs.minix -i 400 $TARGET $FSSIZE
  110. echo "Mounting the disk on $MOUNT..."
  111. mount $TARGET $MOUNT
  112. cd $MASTER_DIR
  113. echo "Copying the files over..."
  114. cp -a * $MOUNT
  115. sync
  116. echo "Installing LILO..."
  117. lilo -r $MOUNT
  118. sync
  119. umount $MOUNT
  120. echo "Bootkernel disk created."
  121. if [ "$DELETE_MASTER" = "true" ]; then
  122.   rm -rf $MASTER_DIR
  123. fi
  124. if [ "$DELETE_MOUNT" = "true" ]; then
  125.   rm -rf $MOUNT
  126. fi
  127. NAME=`dirname $1`
  128. NAME=`basename $NAME`
  129. dd if=/dev/fd0 of=/tmp/$NAME bs=1024 count=$FSSIZE
  130.