Usenet comp.os.linux.announce (1993-2013)
 help / color / mirror / Atom feed
From: Craig Metz <cmetz@thor.tjhsst.edu>
Subject: Script for formatting msdos disks under Linux
Date: Sun, 3 Jan 1993 03:37:00 GMT	[thread overview]
Message-ID: <1993Jan3.033700.858@klaava.Helsinki.FI> (raw)

	I'm not exactly sure when, but mformat got broken somewhere along
the lines for me, and probably for many others. Here's a quick little
script that will format a floppy disk and do the necessary things to make
it a msdos filesystem, all without having to resort to using a certain
defunct operating system to do it. The general premise of operation is
extremely naive, after all, it's just a hack. It may be/probably is 
possible to get this script to naively create other filesystems.

	Before using this script, one must do the following things:

	mkdir /etc/msdos
	chmod 700 /etc/msdos
	
	For each disk type in (360 1200 720 1440 or nonstandard) that you
wish to support, pop in a formatted DOS disk of that size and run:

	dd if=(disk device) of=/etc/msdos/(disk size).b bs=512 count=1

	i.e., to grab the boot sector off a 720k disk, pop one in and run:

	dd if=/dev/fd0D720 of=/etc/msdos/720.b bs=512 count=1

	The script simply does three things:

	1. fdformats the device
	2. Zeroes out the first 10k of the disk to make sure the FAT and
	   root directory contain all zeros 
	3. Copies a DOS boot sector image to the disk's boot sector

	It works for me, your mileage may vary.

							-Craig
----- mkdosfs -----

#!/bin/sh
if [ $# = 0 ];
then
	echo "usage: $0 <device> [bootsector]"
	exit 1
fi
DEVICE=$1
fdformat $DEVICE | tee /tmp/mkdosfs.tmp
SIZE=`head -1 /tmp/mkdosfs.tmp | cut -f8 -d' '`
if [ "X$2" = "X" ];
then 
	BOOT="/etc/msdos/$SIZE.b"
#	BOOT=`echo $DEVICE | sed 's/\/dev\/fd//g | cut -c3-'
else
	BOOT=$2
fi
rm -f /tmp/mkdosfs.tmp
echo -n "Zeroing ... "
dd if=/dev/zero of=$DEVICE bs=512 count=20 &> /dev/null
echo "done"
echo -n "Writing $BOOT ... "
dd if=$BOOT of=$DEVICE bs=512 &> /dev/null
echo "done"
exit 0


                 reply	other threads:[~1993-01-03  3:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox