This tutorial is currently specific for linux, but for Windows, you only need to change some small things.
I will try to add the Windows parts too, when I have the time.
Download
mtools compiled for
Windows:
http://ubcdcreator.stopspazzing.com/mto ... 7-win32.7zmtools manual page:
http://www.gnu.org/software/mtools/manual/mtools.htmlExtract /ubcd/images/fdubcd.iso.gz.
Extract
fdubcd.img out of the
fdubcd.iso.
Make a copy of the existing floppy (just in case you mess up):
Code:
cp fdubcd.img fdubcd-original.img
Create and format a 2880 kb floppy image and edit the "FDUBCD141" value to the current release version of the FDUBCD image:
Code:
mformat -C -f 2880 -v FDUBCD141 -i fdubcd-clean-filesystem.img ::
If you want a bit more space in your image, you can tweak some FAT parameters:
Code:
mformat -C -f 2880 -v FDUBCD141 -d 1 -r 6 -L 9 -i fdubcd-clean-filesystem.img ::
Code:
-C : Create a the image file (use it when you don't have an existing image file)
-f 2880 : Specifies the size of the DOS filesystem to format.
2880 kb, double-sided, 36 sectors per track, 80 cylinders (for 3 1/2 ED)
-v FDUBCD141 : Set volume label of floppy image to "FDUBCD141".
-d 1 : Sets the number of FAT copies. Default is 2.
Setting this to 1, gives use a bit more space ( = number of sectors set as length of FAT)
-r 6 : Sets the size of the root directory (in sectors) (default value = 15 for 3 1/2 ED floppy)
A value of 6 will give us a limit of 96 ROOT files and/or directories.
(512 bytes per sector) / (32 bytes per entry) = (16 entries per sector)
In the subdirectories, there is no limit in the number of subdirectories or files, except that the
total number of files and directories can't be more than the total number of data clusters available.
-L 9 : Sets the length of the FAT (in sectors)
Each entry in the FAT12 table is 1.5 bytes long.
512 bytes per sector / 1.5 bytes per entry * 9 sectors = 3072 entries
In FAT12, the first 2 entries are reserved, so a value of 9 will give use 3070 allocatable clusters.
One cluster in a 3 1/2 ED FAT12 floppy is 2 sectors long by default ==> 1 cluster is 1 KB.
A 2880KB floppy has more than enough with a FAT table with 3070 entries.
-i fdubcd-clean-filesystem.img : Filename of our new floppy image
Download the FreeDOS base iso (fdbasecd.iso) from:
http://www.freedos.org/freedos/files/Open your virtual machine software (qemu, VirtualBox, ..) and attach:
- fdubcd-clean-filesystem.img as floppy image
- fdbasecd.iso as CD image
and boot from CD (FreeDOS):
Qemu:
Code:
qemu -boot d -cdrom fdbasecd.iso -fda fdubcd-clean-filesystem.img
VirtualBox:
VirtualBox doesn't seem to like to attach 2880 kb floppies, but there is a workaround.
In FreeDOS, select "Continue to boot FreeDOS from CD-ROM" (press [ENTER] or type "1" [ENTER])
Then select:
Quote:
2. FreeDOS Safe Mode (don't load any drivers)
Code:
���������������������������������������������������������������������
� FreeDOS 1.0 Final (2006-July-30) INSTALLATION/LIVE CD �
���������������������������������������������������������������������
� 1. Install to harddisk using FreeDOS SETUP (default) �
� �
� 2. FreeDOS Safe Mode (don't load any drivers) �
� �
� FreeDOS is a trademark of Jim Hall 1994-2006 �
���������������������������������������������������������������������
Select from Menu [12], or press [ENTER] (Selection=2) 9
Singlestepping (F8) is: OFF
Now we can install the FreeDOS bootsector to our new created floppy image.
Because the FreeDOS CD boots a floppy image with MEMDISK, our attached floppy image is now B: instead of the normal A: drive.
- We install the FreeDOS boot sector code (/OEM:FD)
- And we don't copy the FreeDOS files like KERNEL.SYS at this time (/BOOTONLY)
Code:
sys B: /BOOTONLY /OEM:FD
Code:
FreeCom version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]
Welcome to the command prompt. No drivers were loaded.
A:\>sys B: /BOOTONLY /OEM:FD
FreeDOS System Installer v3.6, Aug 04 2005
Processing boot sector...
Reading old bootsector from drive B:
FAT type: FAT12
Root dir entries = 96
FAT starts at sector (0 + 1)
Root directory starts at sector (PREVIOUS + 9 * 1)
Boot sector kernel name set to KERNEL SYS
Boot sector kernel load segment set to 60:0h
writing new bootsector to drive B:
System transferred.
A:\>
Now we can close the virtual machine software.
You only need to create the fdubcd-clean-filesystem.img file once. The next time you want to make a modified FDUBCD floppy image, you can start from that image file, copy the needed files inside the image and get a nice fresh floppy image with all files defragmented and with all unused sectors zeroed out (will give a smaller compressed size).Copy the clean 2880k floppy image with the FreeDOS boot sector installed
fdubcd-clean-filesystem.img to a new file on which we can work further (
fdubcd-fresh-files.img)
Code:
cp fdubcd-clean-filesystem.img fdubcd-fresh-files.img
If you started from the
fdubcd-clean-filesystem.img file and the FDUBCD version number is updated, you can update the Volume Label with
mlabel.
Code:
mlabel -i fdubcd-fresh-files.img ::FDUBCD141
Make a temporary directory (remove the previous one, if it already exists):
Code:
rm -rf /tmp/fdubcd
mkdir /tmp/fdubcd
Copy the files of the original image (
fdubcd-original.img) to the temporary directory:
Code:
mcopy -s -m -p -v -i fdubcd-original.img :: /tmp/fdubcd
Code:
- s Recursive copy. Also copies directories and their contents
- p Preserves the attributes of the copied files
- m Preserve the file modification time.
- v Verbose. Displays the name of each file as it is copied.
Change the files you want to change inside the floppy image, by editing the files in the temporary directory.
Sometimes the files in the temporary directory aren't all uppercase, so lets fix this.
FreeDOS can work with them, but it looks nicer if all the filenames look similar.
Convert all lowercase filenames to uppercase:
Code:
cd /tmp/fdubcd/
find . -exec bash -c 'file={}; mv -v "${file}" "${file^^}"' \;
cd -
Copy the files in the temporary directory to our new image (
fdubcd-fresh-files.img):
Code:
mcopy -s -m -p -v -i fdubcd-fresh-files.img /tmp/fdubcd/* ::
Test your new floppy image in a virtual machine to see if it works:
The FDUBCD image in UBCD is always loaded with MEMDISK, so no changes are written to the fdubcd.img file. Therefore, we load our new image with MEMDISK too, so to test it in a Virtual Machine. Only qemu supports direct booting of MEMDISK (linux kernel format).
Code:
qemu -kernel memdisk -initrd fdubcd-fresh-files.img -append 'raw'
Copy your fdubcd-fresh-files.img to fdubcd.img and rebuild the fdubcd.iso.gz image.
With this method, I have now
9 kb more space than in the original FDUBCD141 floppy image (due the parameters given to mformat).
FAT info for the new floppy image created with mformat (custom values):
Code:
$ minfo -i fdubcd-fresh-files.img ::
filename="fdubcd-fresh-files.img"
sectors per track: 36
heads: 2
cylinders: 80
mformat command line: mformat -t 80 -h 2 -s 36 ::
bootsector information
======================
banner:"FRDOS4.1"
sector size: 512 bytes
cluster size: 2 sectors
reserved (boot) sectors: 1
fats: 1
max available root directory slots: 96
small size: 5760 sectors
media descriptor byte: 0xf0
sectors per fat: 9
sectors per track: 36
heads: 2
hidden sectors: 0
big size: 0 sectors
physical drive id: 0x0
reserved=0x0
dos4=0x29
serial number: 34D977A2
disk label="FDUBCD141 "
disk type="FAT12 "
FAT info for the original floppy image:
Code:
$ minfo -i fdubcd-original.img ::
device information:
===================
filename="fdubcd-original.img"
sectors per track: 36
heads: 2
cylinders: 80
mformat command line: mformat -t 80 -h 2 -s 36 ::
bootsector information
======================
banner:" "
sector size: 512 bytes
cluster size: 2 sectors
reserved (boot) sectors: 1
fats: 2
max available root directory slots: 240
small size: 5760 sectors
media descriptor byte: 0xf0
sectors per fat: 9
sectors per track: 36
heads: 2
hidden sectors: 0
big size: 0 sectors
physical drive id: 0x0
reserved=0x0
dos4=0x29
serial number: 00000000
disk label=" "
disk type="FAT12 "
FAT info for the new floppy image created with mformat (default values):
Code:
$ minfo -i fdubcd-fresh-files.img ::
filename="fdubcd-fresh-files.img"
sectors per track: 36
heads: 2
cylinders: 80
mformat command line: mformat -t 80 -h 2 -s 36 ::
bootsector information
======================
banner:"FRDOS4.1"
sector size: 512 bytes
cluster size: 2 sectors
reserved (boot) sectors: 1
fats: 2
max available root directory slots: 240
small size: 5760 sectors
media descriptor byte: 0xf0
sectors per fat: 9
sectors per track: 36
heads: 2
hidden sectors: 0
big size: 0 sectors
physical drive id: 0x0
reserved=0x0
dos4=0x29
serial number: 06A479B7
disk label="FDUBCD141 "
disk type="FAT12 "