home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / linux / 22507 < prev    next >
Encoding:
Text File  |  1993-01-02  |  2.1 KB  |  71 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!think.com!enterpoop.mit.edu!bloom-picayune.mit.edu!daemon
  3. From: Craig Metz <cmetz@thor.tjhsst.edu>
  4. Subject: Script for formatting msdos disks under Linux
  5. Message-ID: <1993Jan3.030827.29331@athena.mit.edu>
  6. Sender: daemon@athena.mit.edu (Mr Background)
  7. Reply-To: cmetz@thor.tjhsst.edu
  8. Organization: The Internet
  9. Date: Sun, 3 Jan 1993 03:08:27 GMT
  10. Lines: 59
  11.  
  12.  
  13.     I'm not exactly sure when, but mformat got broken somewhere along
  14. the lines for me, and probably for many others. Here's a quick little
  15. script that will format a floppy disk and do the necessary things to make
  16. it a msdos filesystem, all without having to resort to using a certain
  17. defunct operating system to do it. The general premise of operation is
  18. extremely naive, after all, it's just a hack. It may be/probably is 
  19. possible to get this script to naively create other filesystems.
  20.  
  21.     Before using this script, one must do the following things:
  22.  
  23.     mkdir /etc/msdos
  24.     chmod 700 /etc/msdos
  25.     
  26.     For each disk type in (360 1200 720 1440 or nonstandard) that you
  27. wish to support, pop in a formatted DOS disk of that size and run:
  28.  
  29.     dd if=(disk device) of=/etc/msdos/(disk size).b bs=512 count=1
  30.  
  31.     i.e., to grab the boot sector off a 720k disk, pop one in and run:
  32.  
  33.     dd if=/dev/fd0D720 of=/etc/msdos/720.b bs=512 count=1
  34.  
  35.     The script simply does three things:
  36.  
  37.     1. fdformats the device
  38.     2. Zeroes out the first 10k of the disk to make sure the FAT and
  39.        root directory contain all zeros 
  40.     3. Copies a DOS boot sector image to the disk's boot sector
  41.  
  42.     It works for me, your mileage may vary.
  43.  
  44.                             -Craig
  45. ----- mkdosfs -----
  46.  
  47. #!/bin/sh
  48. if [ $# = 0 ];
  49. then
  50.     echo "usage: $0 <device> [bootsector]"
  51.     exit 1
  52. fi
  53. DEVICE=$1
  54. fdformat $DEVICE | tee /tmp/mkdosfs.tmp
  55. SIZE=`head -1 /tmp/mkdosfs.tmp | cut -f8 -d' '`
  56. if [ "X$2" = "X" ];
  57. then 
  58.     BOOT="/etc/msdos/$SIZE.b"
  59. #    BOOT=`echo $DEVICE | sed 's/\/dev\/fd//g | cut -c3-'
  60. else
  61.     BOOT=$2
  62. fi
  63. rm -f /tmp/mkdosfs.tmp
  64. echo -n "Zeroing ... "
  65. dd if=/dev/zero of=$DEVICE bs=512 count=20 &> /dev/null
  66. echo "done"
  67. echo -n "Writing $BOOT ... "
  68. dd if=$BOOT of=$DEVICE bs=512 &> /dev/null
  69. echo "done"
  70. exit 0
  71.