Initial Bootloader > Floppy Disk Warning If Not Used Carefully This Process Can Be Dangerous Running the Script Used in This
Total Page:16
File Type:pdf, Size:1020Kb
initial bootloader > floppy disk Initial Bootloader > Floppy Disk Warning If not used carefully this process can be dangerous Running the script used in this article with an incorrect argument can cause loss of data and potentially damage the computer. The script with this article makes sector-to-sector copies to the target media which cannot be undone. To ensure that the computer is not compromised, follow the instructions in this article with care and ensure that the argument passed to the script is not in doubt. It is recommended to make backups of valuable data on the computer before performing operations that cannot be undone. Introduction This article explains how to populate a floppy disk (the target media) with a bootloader. The bootloader used in this article is GRUB (GRand Unified Bootloader). GRUB is self-propagating and once it exists on media in one device it can be used to install itself onto another target. However, it is not possible to install GRUB using a Windows executable, so the script in this article populates the target with an initial image using dd to perform a sector-to- sector copy of a GRUB image. revision 1 initial bootloader > floppy disk Prerequisites The following hardware is required: ● a floppy drive connected to the computer ● one floppy disk The following Windows programs must be installed: ● Tar ● gzip ● dd It is also essential that the computer can boot from a floppy disk. Most computers will do this by default if a floppy disk is in the drive when the computer is switched on. After the computer completes its power on self test, it searches for bootable storage devices and boots from the first one it finds. The order in which the computer searches for devices is controlled in the ROM BIOS and the BIOS settings need to be configured to instruct the computer to search for bootable floppy disks before searching for bootable hard disks. Computers vary widely in how this is done. Many display a message shortly after the computer is turned on indicating which key to press to enter BIOS configuration (typically the esc or F10 key). Others require a configuration floppy disk or CD to configure the BIOS. Download Download initial_floppy from helpcentreonline.com. This will save a file named initial_floppy.tar.gz. Note the directory initial_floppy.tar.gz is downloaded to: this will be referred to as the download directory ([download]). Installation 1. Label recording medium. 1. Write “boot” on a label and attach it to the floppy disk. revision 1 initial bootloader > floppy disk 2. Collect information. 1. Note the target device ([target device]). In Windows, floppy drives are represented by drive letters, usually a or b. Note the drive letter used to represent the drive that will contain the target floppy disk. The drive letter is referred to later in this article as the target device. If the floppy drive is not permanently connected to the computer (for example, if it is connected via USB), the drive letter may be different the next time the computer is switched on. For this reason it is important to note the target device each time the process in this article is followed. 3. Backup target. 1. Operations performed in this article irrevocably overwrite all data on the target floppy disk. If the target currently contains valuable data, it is possible to backup the data using the following command at the command prompt: > dd if=\\.\[target device]: of=temp.img bs=1440k When typing the command replace [target device] with the target device value noted earlier. For example, if the target floppy disk is in drive a:, type the following: > dd if=\\.\a: of=temp.img bs=1440k Before typing the above command it will be necessary to start a command prompt and navigate to the directory the backup image is to be stored in. Do not type the > character - it is the command prompt. The data can later be restored to the floppy disk using the following command: > dd if=temp.img of=\\.\[target device]: bs=1440k 4. Create sources directory ([sources]). 1. Create a directory from which the installation will be performed. For example, a suitable directory could be c:\Unix\source. This directory will be referred to as the sources directory. revision 1 initial bootloader > floppy disk 5. Unpack sources. Start a command prompt and type the following commands. (Do not type the > character - it is the command prompt.) 1. > copy [download]\initial_floppy.tar.gz [sources] Copy the sources from the download directory to the sources directory. When typing the command replace [download] with the path name of the download directory including the drive letter and replace [sources] with the path name of the sources directory including the drive letter. For example, if initial_floppy.tar.gz was downloaded to d:\download and the sources directory is c:\Unix\source, type: > copy d:\download\initial_floppy.tar.gz c:\Unix\source 2. > [sources drive]: Change to the drive containing the sources directory. When typing the command replace [sources drive] with the drive letter of the drive containing the sources directory. For example if the sources directory is c:\Unix\source, type: > c: 3. > cd [sources] Change to the sources directory. When typing the command replace [sources] with the path name of the sources directory excluding the drive letter. For example if the sources directory is c:\Unix\source, type: > cd \Unix\source 4. > gzip -d initial_floppy.tar.gz Decompress the compressed file. 5. > tar -xf initial_floppy.tar Extract the archive. revision 1 initial bootloader > floppy disk 6. > cd initial_floppy 6. Install. 1. Insert the target media (the floppy disk on which GRUB is to be installed) into the drive represented by the target device value. 2. > install [target device] Install the GRUB image. When typing the command replace [target device] with the target device value. For example, if the target floppy disk is in drive a:, type the following: > install a 7. Clean sources directory. 1. > cd .. 2. > del initial_floppy.tar 3. > rd initial_floppy /S revision 1 initial bootloader > floppy disk 8. Test installation. 1. Reboot the computer with the floppy disk still in its drive. If the installation has been successful the computer reboots with the following screen: GRUB version 0.93 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> As indicated in the prerequisites section, the BIOS must be configured so that floppy disks have priority over hard disks in the search order. 2. Remove the floppy disk from its drive and reboot the computer. Remove the floppy disk and then at the grub> prompt type: grub> reboot Script The following script is used: install.bat is run from the command prompt to perform the installation. revision 1 initial bootloader > floppy disk install.bat The install.bat script is run from the command prompt to perform the installation. It accepts the target device drive letter as an argument and copies the GRUB image to the floppy disk in the target device. Further Comments Script To understand the process followed in this article, it is worth examining the script. The installation is performed by the following command in the install.bat script: dd if=grub.img of=\\.\%1: bs=1440k This command uses dd to copy the contents of file grub.img to the target floppy disk in blocks of 1440 kilobytes. dd is not the same as the DOS copy command which copies one file to another. dd streams a specified quantity of data from a defined point in a source to a defined point in a target without regard to any content that may already be in the target. The source and target may be files or devices. In the above example all data is streamed from the beginning of file grub.img to the beginning of a floppy disk. The dd command enables an entire image to be created on the target, which may contain data in a variety of forms, including: ● a single file ● the entire contents of a device ● an operating system ● a copy of a master boot record. revision 1 initial bootloader > floppy disk Floppy Disk Contents The image copied to the floppy disk is in DOS FAT format, so it can be viewed from Windows Explorer. The disk contains the following files in directory \BOOT\GRUB: ● STAGE1 ● STAGE2 In addition, STAGE1 is also embedded in the disk's boot sector as the initial bootstrap program. When the computer starts, STAGE1 is loaded from the boot sector and it loads STAGE2, which contains the user interface and functionality in GRUB. revision 1.