Copy + update FDUBCD floppy image to new clean floppy image

If you have a tutorial or tip related to the UBCD, why not share it with other users here?

Moderators: Icecube, StopSpazzing

Post Reply
Message
Author
Icecube
Posts: 1278
Joined: Fri Jan 11, 2008 2:52 pm
Contact:

Copy + update FDUBCD floppy image to new clean floppy image

#1 Post by Icecube » Thu Apr 21, 2011 1:39 pm

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.7z

mtools manual page:
http://www.gnu.org/software/mtools/manual/mtools.html

Extract /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: Select all

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: Select all

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: Select all

mformat -C -f 2880 -v FDUBCD141 -d 1 -r 6 -L 9 -i fdubcd-clean-filesystem.img ::

Code: Select all

-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: Select all

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.
  • Move fdubcd-clean-filesystem.img to fdubcd-clean-filesystem-2880.img
  • Create a 1440 kb floppy with the same name:

    Code: Select all

    mformat -C -f 1440 -v FDUBCD141 -i fdubcd-clean-filesystem.img ::
  • Attach this floppy image to VirtualBox
  • Close VirtualBox
  • Remove the 1440 kb fdubcd-clean-filesystem.img
  • Move fdubcd-clean-filesystem-2880.img to fdubcd-clean-filesystem.img
  • Start VirtualBOX and see your 2880 kb floppy image attached
  • Attach the FreeDOS base ISO (fdbasecd.iso)
In FreeDOS, select "Continue to boot FreeDOS from CD-ROM" (press [ENTER] or type "1" [ENTER])

Then select:
2. FreeDOS Safe Mode (don't load any drivers)

Code: Select all

     ���������������������������������������������������������������������
     �       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: Select all

sys B: /BOOTONLY /OEM:FD

Code: Select all

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: Select all

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: Select all

mlabel -i fdubcd-fresh-files.img ::FDUBCD141
Make a temporary directory (remove the previous one, if it already exists):

Code: Select all

rm -rf /tmp/fdubcd
mkdir /tmp/fdubcd
Copy the files of the original image (fdubcd-original.img) to the temporary directory:

Code: Select all

mcopy -s -m -p -v -i fdubcd-original.img :: /tmp/fdubcd

Code: Select all

- 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: Select all

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: Select all

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: Select all

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: Select all

$ 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: Select all

$ 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: Select all

$ 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   "
Download Ultimate Boot CD v5.0: http://www.ultimatebootcd.com/download.html
Use Parted Magic for handling all partitioning task: http://partedmagic.com/

ady
Posts: 832
Joined: Sat May 08, 2010 5:26 am

Re: Copy + update FDUBCD floppy image to new clean floppy im

#2 Post by ady » Fri May 06, 2011 1:10 am

There is no need to use the FreeDOS ISO. There is no need to use a temporal folder "/tmp/fdubcd/", and there is no need to "mcopy" twice, using that tmp folder.

Here are my suggestions to change/simplify the procedure.
Icecube wrote: Download the FreeDOS base iso (fdbasecd.iso) from: http://www.freedos.org/freedos/files/
Not needed. We can use UBCDxxx.ISO instead. I'll use UBCD51a2.ISO in the following procedures.
Open your virtual machine software (qemu, VirtualBox, ..) and attach:
  • fdubcd-clean-filesystem.img as floppy image
  • fdbasecd.isoUBCD51a2.ISO as CD image
and boot from CD (FreeDOSUBCD):

Qemu:

Code: Select all

qemu -boot d -cdrom fdbasecd.iso -fda fdubcd-clean-filesystem.img
[/s]
Use instead:

Code: Select all

qemu -boot d -cdrom ubcd51a2.iso -fda fdubcd-clean-filesystem.img
VirtualBox:
VirtualBox doesn't seem to like to attach 2880 kb floppies, but there is a workaround.
  • Move fdubcd-clean-filesystem.img to fdubcd-clean-filesystem-2880.img
  • Create a 1440 kb floppy with the same name:

    Code: Select all

    mformat -C -f 1440 -v FDUBCD141 -i fdubcd-clean-filesystem.img ::
  • Attach this floppy image to VirtualBox
  • Close VirtualBox
  • Remove the 1440 kb fdubcd-clean-filesystem.img
  • Move fdubcd-clean-filesystem-2880.img to fdubcd-clean-filesystem.img
  • Start VirtualBOX and see your 2880 kb floppy image attached
The last, next step after that one, *was*:
  • Attach the FreeDOS base ISO (fdbasecd.iso)
But now I use instead:
  • Attach the UBCD ISO (UBCD51a2.iso)
(and use it to boot the VM).

So now you can skip all the FreeDOS instructions. Instead, in UBCD51a2:
  • From the Syslinux menu, select FDUBCD DOS and boot into the default booting mode (1).
  • Once the boot process finishes, select "EXIT" so to go to the DOS prompt.
Then type the following commands:

Code: Select all


a:
sys b:
xcopy a: b: /e /h /i /n /q /w
poweroff

The last step there (poweroff) should close the VM.
Now we can close the virtual machine software.
Just to continue with the same names that Icecube used originally:

Code: Select all

cp fdubcd-clean-filesystem.img fdubcd-fresh-files.img
But now that step is not really necessary. It is only "convenient", so to follow the next steps easily, as Icecube wrote them. I also delete here the rest of the comments around that last copy command.
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: Select all

mlabel -i fdubcd-fresh-files.img ::FDUBCD141
The next steps are completely unnecessary now.
Make a temporary directory (remove the previous one, if it already exists):

Code: Select all

rm -rf /tmp/fdubcd
mkdir /tmp/fdubcd
Copy the files of the original image (fdubcd-original.img) to the temporary directory:

Code: Select all

mcopy -s -m -p -v -i fdubcd-original.img :: /tmp/fdubcd

Code: Select all

- 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.[/s]
The next following step is optional, as it was before. It seems this step also changes the "modification date" of the files involved, which IMO is not a desirable change. So I repeat it here to respect the original tutorial, but I do NOT recommend it.
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: Select all

cd /tmp/fdubcd/

find . -exec bash -c 'file={}; mv -v "${file}" "${file^^}"' \;

cd -
[/s]
Again, the following steps are not necessary now, since the files are already copied into the new floppy image.

Copy the files in the temporary directory to our new image (fdubcd-fresh-files.img):

Code: Select all

mcopy -s -m -p -v -i fdubcd-fresh-files.img /tmp/fdubcd/* ::
[/s]

The rest are additional steps for building the new fdubcd.ISO and the new modified UBCDxxx.ISO, and for testing it. The new FDUBCD.IMG floppy image was already finished and complete when we ran the "xcopy" command above, so I won't repeat here the same procedures and info.

This simple changes reduces the necessary steps, avoids building a temporary directory and 2 "mcopy" commands. It also avoids downloading and using the "extra" FreeDOS ISO image.

In addition, those steps work under both Linux and Windows, while the original "mcopy" steps have some problems under Windows.

For Windows users, there is an additional/alternative tutorial in the UBCD forum, but using GUI tools. For those interested, it is located at viewtopic.php?p=12188#p12188 with some technical background.

davidm71
Posts: 2
Joined: Sat Mar 10, 2018 1:29 pm

Re: Copy + update FDUBCD floppy image to new clean floppy im

#3 Post by davidm71 » Sat Mar 10, 2018 1:35 pm

Hi,

About to give up google searching for the Mtools compiled for Windows port! Guess the link is too old to be valid anymore but really need it for an EDK2 mod I'm working on if anyone can look in their archives and dig it up I would much appreciate it,

Thank you..

Dave.

cb66
Posts: 2
Joined: Mon Mar 28, 2016 3:47 am

Re: Copy + update FDUBCD floppy image to new clean floppy im

#4 Post by cb66 » Thu Mar 15, 2018 1:29 pm

Dave,

Have you tried these:

http://www.fysnet.net/mtools.htm

They're specifically compiled for use with Bochs, but also are claimed to work with DOS and/or Win32. Last updated in May 2016.

CB

davidm71
Posts: 2
Joined: Sat Mar 10, 2018 1:29 pm

Re: Copy + update FDUBCD floppy image to new clean floppy im

#5 Post by davidm71 » Thu Mar 15, 2018 1:57 pm

Yes someone pointed me in the right direction. Working great. Thanjs.

ady
Posts: 832
Joined: Sat May 08, 2010 5:26 am

Re: Copy + update FDUBCD floppy image to new clean floppy im

#6 Post by ady » Thu Mar 15, 2018 3:04 pm

cb66 wrote:Dave,

Have you tried these:

http://www.fysnet.net/mtools.htm

They're specifically compiled for use with Bochs, but also are claimed to work with DOS and/or Win32. Last updated in May 2016.

CB
davidm71 wrote:Yes someone pointed me in the right direction. Working great. Thanjs.
Why are you mixing things / ports / versions, when you already know where to find the relevant mtools port that is mentioned in this forum topic?

A reply to this post is really not needed. I don't really need nor want an answer; I just want to avoid completely-unnecessary misunderstandings.

FWIW, ATM the relevant download (mtools version 4.0.18 ported to Windows) can be found at:

http://reboot.pro/files/file/267-mtools/

Post Reply