I was frustrated by other methods I found when researching. One needed my whole USB stick, which was undesirable and another using a pre-built image with no control over the config.sys, etc. left me in a pseudo floppy mode (A:\ drive) and also crashed on a regular basis. There had to be a better way. I wanted the whole nine yards - one USB stick for system rescue, BIOS/firmware upgrades, and file transfer between Windows and 'nix systems. A veritable digital swiss army knife! This way you get full control over the config.sys and autoexec.bat files. New embedded systems without floppy and CD/DVD drives really helped make the case for solving this issue without purchasing new hardware to drag around.
This post will have less hand-holding than the previous one. Hopefully the detail provided previously will get you through this post without problems.
For enhanced flexibility we'll use a separate "/boot" partition. This will allow for easily updating the SystemRescueCD and other partitions with new/updated data without disturbing the installed GRUB files.
We'll need two more products: FreeDOS (download the fdfullcd.iso) and install makebootfat (your distro most likely has this packaged).
Create a working directory for the necessary FreeDOS files and loop mount the FreeDOS iso.
Example:
- mkdir fdwrk
- mkdir fdboot
- mount -o loop /path/to/fdfullcd.iso /mnt/loop
Copy (as a minimum) the files:
- kernel.sys
- himem.exe
- command.com
- more.exe
Create or copy a config.sys file (necessary to load the command interpreter) to your fdwrk directory:
Example config.sys file:
===============================================
DEVICE=HIMEM.EXE
LASTDRIVE=Z
BUFFERS=20
FILES=40
DOS=HIGH,UMB
DOSDATA=UMB
SHELLHIGH=command.com /P
===============================================
Create or copy an autoexec.bat file (the simple one below will avoid the date/time prompt) to your fdwrk directory:
Create or copy an autoexec.bat file (the simple one below will avoid the date/time prompt) to your fdwrk directory:
Example autoexec.bat file:
===============================================
CLS
===============================================
Make sure your config.sys and batch files use DOS/Windows line termination - CR+LF and not just LF as is standard with 'nix systems.
- /source/ukernel/boot/fat16.bin
Instead of just two partitions as in the previous post we will make 4. Basically the same instructions but partitions 2 & 3 can be pretty small. I made them both 128M which really is overkill but I don't need the space that bad. I used:
- 6500M type "c" FAT32LBA (for file sharing - must be first partition, sde1/hd4,0)
- 128M type "e" FAT16 (the DOS partition, sde2/hd4,1)
- 128M type "83" Linux (the /boot partition - where grub resides, sde3/hd4,2)
- 800M (or remaining space) type "83" Linux (the SystemRescueCd partition, sde4/hd4,3)
- mkfs.vfat -F16 /dev/sde2
- mount -t ext4 /dev/sde3 /media/usbstickgrub
- mount -t ext4 /dev/sde4 /media/usbsticksysrescue
- cp -a /where.your.System.RescueCD.files.are/* /media/usbsticksysrescue/*
Prepare /media/usbstickgrub:
- mkdir -p /media/usbstickgrub/boot/grub
- cp -a /lib/grub/<distro-specific>/* /media/usbstickgrub/boot/grub
===============================================
timeout 10
title SystemRescueCD 32bit
kernel (hd0,3)/isolinux/rescuecd
initrd (hd0,3)/isolinux/initram.igz
title SystemRescueCD 64bit
kernel (hd0,3)/isolinux/rescue64
initrd (hd0,3)/isolinux/initram.igz
title FreeDOS
rootnoverify (hd0,1)
makeactive
chainloader +1
===============================================
Install grub:
- grub
- grub> find /boot/grub/menu.lst (will help identify the root partition)
- grub> root (hd4,2) (specify our new /boot partition)
- grub> setup (hd4) (install GRUB in the USB stick's MBR)
- grub> quit
- makebootfat -P -o /dev/sde2 -b /path/to/fdboot/fat16.bin /path/to/fdwrk
The nice thing about this method is that when booting into DOS the partition is seen as the C: drive, however, many BIOS/firmware upgrade batch (and config.sys) files may assume you're booting from a floppy and have some hardcoded A:\ paths. Simply edit these files as needed and remove the A:\.
The FreeDOS partition may have to exist under some limit (8GB, 16GB ?). As my USB stick is only 8GB I didn't run into any issues. If you have a larger USB stick you may not have success if your FreeDOS (2nd) partition is beyond such limit.
Please comment on whether you find this information useful or what might be done to improve it. Thank you!
Chris,
ReplyDeleteAfter giving your first tutorial a go, I tried this one and it was great.
I even took it a bit further put the System Rescue CD in an extended partition and created another partition on the end for an encrypted section.
Here is my partition table now:
sdc1 25GB - FAT32
sdc2 128M - FreeDOS (FAT32)
sdc3 128M - Grub2 (ext4)
sdc4 - extended
sdc5 800M - System Rescue CD (ext4)
sdc6 5GB - Encrypted partition (ext4)
BTW FreeDOS does boot after the 25GB partition.
Thanks map7, good to know that FreeDOS boots from a partition beyond 25GB.
ReplyDeleteI had to use the -X option to make the makebootfat command work on Fedora 12. Otherwise, it assumed a FAT32 partition and failed with error:
ReplyDeleteInvalid code start 3E in the boot sector (for fat32 it must be at least 5A).
OK I install as you explain above. When I boot to DOS it fails like this (after the heading info):
ReplyDeleteC: HD1, Pri[ 1], CHS= 0-1-1, start= 0 MB, size= 2505 MB
Bad or missing Command Interpreter: command.com /P /E:256
Enter the full shell command line:
(Sysrescue CD works fine so I am sure Grub etc is working correctly. I copied all the files you list.) I have been searching the web for the fix without any result. Any ideas? Thanks.
@leek
ReplyDeletecommand.com was one of the files that needed to be copied to your fdwrk directory - makebootfat should have installed them (although it looks like I typo'd fdwrk as fdwork later on which I will correct now).
BTW, not all BIOSes are capable of booting FreeDOS like this. With some older system you may have to resort to old school techniques.
Thank you for your reply!
ReplyDeleteI did spot that typo and correct it, and I can see that command.com is on the stick, so I have no idea what the problem is.
The machine is a relatively new one (about a year) and does support boot from USB.
There is one other small typo on this page where you copy the System Rescue CD files, the destination should not have a * at the end.
This comment has been removed by a blog administrator.
ReplyDeleteThis detailed information and this tutorial was great while i trying that. Thanks for sharing
ReplyDelete