Freedos usb from linux

How to install FreeDos onto a USB stick?

The FreeDos project offers a number of downloads, but all of these contain an installer that tries to install FreeDos from an installation media onto the harddisk. Selecting the mobile stick as installation target is not supported. Since USB sticks are usually large enough to contain the OS plus applications, writing onto the harddisk is often not intented. Some pages point to tools like Rufus, which can create a bootable FreeDos installation from a template, but this disk is then missing the typical FreeDos components. So how can a complete FreeDos be installed onto a bootable USB stick to create a live USB version with FreeDos?

6 Answers 6

Unfortunately the current information on the FreeDOS Wiki is not up to date, but with the help from FreeDos Developer Jim Hall I could find the solution:

  1. Download the USB “Full” installer from the FreeDOS page.
  2. Unpack the downloaded zip
  3. Use a USB formatting tool (for example rufus) to write the image to USB (take care to write over the right drive)
  4. Move the directory D:\FDSETUP\BIN to D:\BIN
  5. Edit first and last two lines in D:\FDCONFIG.SYS as follows
!COUNTRY=001,858:\BIN\COUNTRY.SYS !LASTDRIVE=Z !BUFFERS=20 !FILES=40 DOS=HIGH DOS=UMB DOSDATA=UMB DEVICE=\BIN\HIMEMX.EXE SHELLHIGH=COMMAND.COM \BIN /E:2048 /P=\AUTOEXEC.BAT 
@echo off SET DOSDIR= SET LANG= SET PATH=%dosdir%\BIN SET DIRCMD=/P /OGN /Y rem SET TEMP=%dosdir%\TEMP rem SET TMP=%TEMP% rem SET NLSPATH=%dosdir%\NLS rem SET HELPPATH=%dosdir%\HELP rem SET BLASTER=A220 I5 D1 H5 P330 rem SET COPYCMD=/-Y DEVLOAD /H /Q %dosdir%\BIN\UDVD2.SYS /D:FDCD0001 SHSUCDX /QQ /D3 rem SHSUCDHD /QQ /F:FDBOOTCD.ISO FDAPM APMDOS rem SHARE rem NLSFUNC %dosdir%\BIN\COUNTRY.SYS rem DISPLAY CON=(EGA),858,2) rem MODE CON CP PREP=((858) %dosdir%\CPI\EGA.CPX) rem KEYB US,858,%dosdir%\bin\keyboard.sys rem CHCP 858 rem PCNTPK INT=0x60 rem DHCP rem MOUSE rem DEVLOAD /H /Q %dosdir%\BIN\UIDE.SYS /H /D:FDCD0001 /S5 SHSUCDX /QQ /~ /D:?SHSU-CDR,D /D:?SHSU-CDH,D /D:?FDCD0001,D /D:?FDCD0002,D /D:?FDCD0003,D rem MEM /C /N SHSUCDX /D rem DOSLFN rem LBACACHE.COM buf 20 flop SET AUTOFILE=%0 SET CFGFILE=\FDCONFIG.SYS alias reboot=fdapm warmboot alias reset=fdisk /reboot alias halt=fdapm poweroff alias shutdown=fdapm poweroff rem alias cfg=edit %cfgfile% rem alias auto=edit %0 vecho /p Done processing startup files /fCyan FDCONFIG.SYS /a7 and /fCyan AUTOEXEC.BAT /a7/p 

Boot and test

The USB key now boots directly into FreeDOS and loads into high memory, leaving roughly 600KB of common memory for programs.

Источник

Building a FreeDOS bootable USB stick under Linux

This is for my own reference more than anything else; periodically I find myself needing to boot DOS. Usually because I want to upgrade a BIOS and the upgrade tool only works with Windows or DOS. Yes, I’m aware of flashrom, but the scary messages about toasting laptops means I’m much happier going the DOS route there. So I need a writable medium with a DOS boot image. The easy way to do it is to find a DOS floppy image and write that to a USB stick with dd, but it’s basically a one off and means you can’t fit a whole lot on the image. I wanted to do a native USB boot. The following did the trick for me.

Firstly, this is all on a Debian testing box, in particular with dosfstools (3.0.9-1), mbr (1.1.11-4) and syslinux (2:4.04+dfsg-2). I don’t think I’m using anything particularly new from these tools, so I suspect Debian stable will work just fine.

In the below my USB stick is on /dev/sdb , I’ve got a copy of FreeDOS in ~/FreeDOS/ (I extracted the files from a balder10.img floppy image that’s easy enough to find, but all you need is kernel.sys and command.com ), and I wanted things neatly in their own subdirectories so I could try and keep the key for repeated use and know which bits I wanted to keep and which were transient. I also added a copy of the Debian Installer for convenience; it would need a copy of the netinst ISO dropped into the root to actually be useful, as there’s not enough to do a full netboot from the wider Internet using just the HD initrd.

 # Create a single bootable LBA VFAT partition spanning entire stick. echo 0,,C,* | sfdisk /dev/sdb # Format as VFAT and give it a disk label. mkfs.vfat -n 'DOS BOOT' /dev/sdb1 # Install an MBR install-mbr /dev/sdb # Mount it and create some directories for our files. mount /dev/sdb1 /media/DOS\ BOOT/ cd /media/DOS\ BOOT/ mkdir boot mkdir boot/syslinux/ mkdir FreeDOS # Copy the chain.c32 syslinux tool over. cp /usr/lib/syslinux/chain.c32 boot/syslinux/ # Copy FreeDOS over and move the important bits to / cp ~/FreeDOS/* FreeDOS/ mv FreeDOS/command.com . mv FreeDOS/autoexec.bat . mv FreeDOS/fdconfig.sys . # Add the Debian Installer mkdir boot/d-i/ cd boot/d-i/ wget http://cdn.debian.net/debian/dists/squeeze/main/installer-amd64/current/images/hd-media/initrd.gz wget http://cdn.debian.net/debian/dists/squeeze/main/installer-amd64/current/images/hd-media/vmlinuz # Install syslinux syslinux -d boot /dev/sdb1 

I made a boot/syslinux.help file containing:

 Available boot options are: FreeDOS d-i 

and a boot/syslinux.cfg with:

 prompt 1 display syslinux.help default FreeDOS label FreeDOS COM32 /boot/syslinux/chain.c32 APPEND freedos=/FreeDOS/kernel.sys label d-i KERNEL /boot/d-i/vmlinuz INITRD /boot/d-i/initrd.gz 

Initial testing was done using kvm which was a lot easier than constantly rebooting my laptop.

Hopefully this is of help to someone. The only neat bit that I didn’t see elsewhere when I was looking was the use of chain.c32 to load kernel.sys rather than having to use a FreeDOS provided boot sector image.

Noodles’ Emptiness

Источник

Bootable USB in linux with freeDOS

Bootable USB stick is very handy and it seems to easy to create using dedicated applications both under Linus or M$ but let’s set the challenge and try to make it manually from the bare Linux command like. This knowledge may become very helpful in Data Centrer scenarios where servers BIOS need to be updated but no Windows environment is available for the M$ executable to run.

At the end of this tutorial you will see that USB creators tools are quite sophisticated peace of software allowing to create many different systems with a speed of blink of an eye not necessary telling to the user all magic happening under a hood. Let’s start…

Set bootable flag on USB drive

First you need to create the correct partition on your USB drive using fdisk or modern cfdisk then set a bootable flag:

$ sudo fdisk /dev/sdb #/dev device needs to be a hard drive(sdb) not a partition(sdb1) Command (m for help): a Partition number (1-4): 1 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. $ sudo fdisk -l Disk /dev/sdb: 2002 MB, 2002747392 bytes 255 heads, 63 sectors/track, 243 cylinders, total 3911616 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 63 3911615 1955776+ c W95 FAT32 (LBA)

Create filesystem on USB stick

You should mark a partition in fdisk as FAT16 (type 0E) if the size is up to 2GB or FAT32 (type 0C) if bigger or needs long filenames support.

df -h #find your usb device lsblk #another way to find your device umount /dev/sdb1 mkfs.vfat /dev/sdb1 #create fat32 mkfs.ext3 /dev/sdb1 #create ext3 mkfs.msdos -F 32 -n FREEDOS /dev/sdb1 #format device to fat16, use -F 16 for fat16 mkdosfs -F 32 -n FREEDOS -I /dev/sdb1 #format device to fat32, use -F 16 for fat16, -n partition label

Make bootable USB from .iso image

Copy image to USB

DD can copy a whole image to the desired device but only a hybrid ISOs image will boot.

sudo umount /dev/sdb sudo dd if=image.iso of=/dev/sdb #output file of= needs pointing to USB drive not a partition (eg .sdb1) sync #forces changed blocks to disk, updates the super block and flushes file system buffers

Convert .iso to hybrid image

Starting in version 3.72, ISOLINUX supports a “hybrid mode” which can be booted from either CD-ROM or from a device which BIOS considers a hard disk or ZIP disk, e.g. a USB key or similar. Hybrid images are special as in addition to the normal CD-based ISO9660 filesystem, they also contain a valid-looking DOS-style partition table. The isohybrid contains MBR code which has to match the version of the ISOLINUX file isolinux.bin. Therefore always use the program from the same SYSLINUX installation which .iso has been created by mkisofs, genisoimage, or xorriso and then treat it by:

apt-cache pkgnames syslinux | grep -A 1 Version #check isolinux version isohybrid isolinuximage.iso #convert to hybrid image

The above operation will append necessary information to the image file thus the file check-sum will change.

Mount .iso

If you have .iso image and want to access its file system you can simply mount it. This is equivalent Windows virtual CD.

sudo mkdir /mnt/isoimage #create mounting point sudo mount -o loop,ro -t iso9660 image.iso /mnt/isoimage/ #-o options, loop -loop,ro device /dev/loop in read-only mode, -t type eg. ntfs, vfat

Create FreeDOS bootable USB from Linux

This is often required for a server BIOS updates when the patch comes in DOS/Windows format. The following tutorial in essence brings all the above together therefore it will be valuable for you to read a whole article. Let’s start.

Understanding MBR size is 446 + 64 + 2 = 512 bytes, where

### Step 1. Partition USB drive using parted. The fdisk, cfdisk will not work as they are known for creating a not valid MBR record.

parted /dev/sdb mklabel msdos parted /dev/sdb mkpart primary fat32 0 2000MB parted /dev/sdb set 1 boot on parted /dev/sdb print #show partitions

### Step 2. Create_filesystem_on_USB_stick – you may need to re plug in your USB flash to a laptop

sudo umount /dev/sdb1 sudo mkfs.msdos -F 32 -n FREEDOS /dev/sdb1 #creates fat32 filesystem where USB stick partition is /dev/sda1

### Step 3. Install syslinux bootloader and make USB flash bootable

sudo syslinux -i /dev/sdb1 #overwrites previous bootloader GRUB like
wget http://www.freedos.org/download/download/fd11src.iso #FreeDOS 1.1 Base CD+several useful utilities, 40MB

### Step 5. Mount FreeDOS image and copy boot files to USB stick

sudo mount /dev/sdb1 /mnt/usbdrive #mount USB stick sudo mkdir /mnt/usbdrive/ #create fdos (FreeDOS binaries) and img (other images eg. memtest) directory on USB sudo mkdir /mnt/isoimage #create create isoimage mount point directory in /mnt sudo mount -i loop ~/Downloads/fd11src.iso /mnt/isoimage #mount FreeDOS ISO
df -Th | grep dev/ #show mounted FreeDOS iso (loop0) and USB stick (sdb1) /dev/sda1 ext4 290G 18G 258G 7% / /dev/loop0 iso9660 39M 39M 0 100% /mnt/isoimage /dev/sdb1 vfat 1.9G 36K 1.9G 1% /mnt/usbdrive
sudo unzip /mnt/isoimage/freedos/packages/boot/syslnxx.zip -d /mnt/usbdrive/fdos #extract boot files from .iso to USB sudo find /mnt/isoimage/freedos/packages/base/*.zip | sudo xargs -l unzip -d /mnt/usbdrive/fdos #extract FreeDOS base utilities to USB cd /mnt/usbdrive #change current directory to root USB directory (where USB is mounted) sudo cp fdos/autoexec.txt ./autoexec.bat #create autoexec.bat using preconfigured autoexec.txt sudo cp fdos/config.txt ./config.sys #create config.sys using preconfigured config.txt

### Step 6. Place syslinux.cfg to root USB directory. Paste the below to your favourite text editor and save as syslinux.cfg

sudo vi /mnt/usbdrive/syslinux.cfg default fdos prompt 1 timeout 200 say Press ENTER to boot FreeDOS, or choose from these alternatives: say --------------------------------------------------------------- say : fdos :: FreeDOS 1.1 say : memtest :: Run Memtest86+ 4.20 ..you need to upload the image say --------------------------------------------------------------- say Example: To boot Memtest86+, type "memtest" and hit Enter label fdos menu label fdos - Load FreeDOS 1.1 from USB flash drive com32 /fdos/bin/chain.c32 append freedos=/fdos/bin/kernel.sys label memtest menu label memtest - Load Memtest86+ 4.20 linux /img/memtest.bin

### Step 7. Unmount USB drive. Your bootable USB FreeDOS flash drive is ready.

cd ~ sudo umount /mnt/usbdrive

umount /mnt/usbdrive device is busy

fuser -u /mnt/usbdrive/ #displays who is currently using /mnt/usbdrive, useful when drive is busy to unmount /mnt/usbdrive: 16029c(piotr)

This entry was posted in linux, tutorial and tagged bootable usb, hybrid iso, syslinux. Bookmark the permalink.

Recently posted

Источник

Читайте также:  Grep pid in linux
Оцените статью
Adblock
detector