It is currently Fri Apr 18, 2014 8:21 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Copy + update FDUBCD floppy image to new clean floppy image
PostPosted: Thu Apr 21, 2011 1:39 pm 
Offline

Joined: Fri Jan 11, 2008 2:52 pm
Posts: 1278
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:
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.
  • Move fdubcd-clean-filesystem.img to fdubcd-clean-filesystem-2880.img
  • Create a 1440 kb floppy with the same name:
    Code:
    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:
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   "

_________________
Download Ultimate Boot CD v5.0: http://www.ultimatebootcd.com/download.html
Use Parted Magic for handling all partitioning task: http://partedmagic.com/


Top
 Profile  
 
 Post subject: Re: Copy + update FDUBCD floppy image to new clean floppy im
PostPosted: Fri May 06, 2011 1:10 am 
Offline

Joined: Sat May 08, 2010 5:26 am
Posts: 737
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.

Quote:
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:
qemu -boot d -cdrom fdbasecd.iso -fda fdubcd-clean-filesystem.img



Use instead:
Code:
qemu -boot d -cdrom ubcd51a2.iso -fda fdubcd-clean-filesystem.img


Quote:
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:
    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:

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



The last step there (poweroff) should close the VM.

Quote:
Now we can close the virtual machine software.


Just to continue with the same names that Icecube used originally:
Code:
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.

Quote:
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



The next steps are completely unnecessary now.
Quote:
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.



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.

Quote:
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 -



Again, the following steps are not necessary now, since the files are already copied into the new floppy image.

Quote:
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/* ::



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 http://www.ultimatebootcd.com/forums/viewtopic.php?p=12188#p12188 with some technical background.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group