This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Subject: Re: How to copy floppy disks. From: rpjday <rpjday@mindspring.com> Date: Wed, 19 Apr 2000 12:40:56 -0400 (EDT) On Tue, 18 Apr 2000, Manuel A. Camacho Q. wrote: > Hi! > > I know this must be a simple one, but got no idea. How can I copy floppy > disks on a single disk drive unit? (from the shell prompt) $ dd if=/dev/fd0 of=/tmp/whatever bs=72k (the 72k is arbitrary) (swap floppies) $ dd if=/tmp/whatever of=/dev/fd0 bs=72k === Subject: Re: How to copy floppy disks. From: Rick Forrister <rickf@crow.jpl.nasa.gov> Date: Wed, 19 Apr 2000 09:15:13 -0700 mcamacho@habitat.co.cr said: > I know this must be a simple one, but got no idea. How can I copy > floppy disks on a single disk drive unit? (from the shell prompt) dd is probably the best choice. For a first try, just dd if=/dev/fd0 of=floppy.img <replace diskette> dd if=floppy.img of=/dev/fd0 === Subject: Re: How to copy floppy disks. From: Robert Fausey <fausey@Princeton.EDU> Date: Wed, 19 Apr 2000 12:16:52 -0400 (EDT) On Tue, 18 Apr 2000, Manuel A. Camacho Q. wrote: Make an image of the disk and then write the image to the destination floppy. Use dd if=/dev/fd0 of=floppy.img bs=144k to make the image an then dd if=floppy.img of=/dev/fd0 bs=144k to write the image. > > I know this must be a simple one, but got no idea. How can I copy floppy > disks on a single disk drive unit? (from the shell prompt) > === Subject: Re: How to copy floppy disks. From: Dave Reed <dreed@capital.edu> Date: Wed, 19 Apr 2000 12:22:22 -0400 (EDT) > "Manuel A. Camacho Q." <mcamacho@habitat.co.cr> wrote: > I know this must be a simple one, but got no idea. How can I copy floppy > disks on a single disk drive unit? (from the shell prompt) If the disk just contains files, cp the files to a hard disk insert other floppy cp files from hard disk to floppy If the disk is bootable, something like (not tested): dd if=/dev/fd0 of=/tmp/file insert other floppy dd if=/tmp/file of=/dev/fd0 You may also need to add bs=1440k to the dd lines. === Subject: Re: How to copy floppy disks. From: "Mikkel L. Ellertson" <mikkel@execpc.com> Date: Wed, 19 Apr 2000 12:28:00 -0500 At 02:15 PM 4/18/00 -0500, you wrote: >I know this must be a simple one, but got no idea. How can I copy floppy >disks on a single disk drive unit? (from the shell prompt) Here is a shell script I can accross a while ago... #!/bin/sh #*********************************** # Single drive disk copy program. * #*********************************** # if [ "$1"="" ] then echo Usage: $0 /dev/[floppy drive] else echo "Insert sorce diskette in $1, then press ENTER..." read kb dd if=$1 of=/tmp/dd.$$ bs=18432 # copy to temp file echo "Insert destination diskette in $1, then press ENTER..." read kb dd if=/tmp/dd.$$ of=$1 bs=18432 # copy the tmp file to diskette rm -f /tmp/dd.$$ 2>&1 > /dev/null # delete the tmp file fi === Subject: Re: How to copy floppy disks. From: Joe Brenner <doom@kzsu.Stanford.EDU> Date: Wed, 19 Apr 2000 10:58:04 -0700 "Manuel A. Camacho Q." <mcamacho@habitat.co.cr> wrote: > I know this must be a simple one, but got no idea. How can I copy floppy > disks on a single disk drive unit? (from the shell prompt) There are many ways of doing this, and some of them are probably easier than what I'm going to tell you here, but this is the way that I do it: mount /mnt/floppy mkdir /tmp/floppystuff cp /mnt/floppy/* /tmp/floppystuff cp /tmp/floppystuff /mnt/floppy/* rm /tmp/floppystuff/* You might need to be root to do that mount command (i.e. do a "su" first, and give it the root password). In fact, the form of the mount command I've specified here depends on what's in your /etc/fstab file. Mine has a line like the following (which I suspect is pretty ordinary for a RedHat box): /dev/fd0 /mnt/floppy vfat owner,noauto 0 0 So if I say "mount /mnt/floppy" that tells the system to connect the device /dev/fd0 (which is usually your floppy drive) to the filesystem, putting it in the standard location /mnt/floppy. (And I believe you'll get an error if that location doesn't exist already.) By the way, once you've mounted the floppy, it should stay mounted until you unmount it ("umount /mnt/floppy", yes that's "umount", with only one "n"). Caveat: This method copies all of the files, but I can't swear to it that this will really produce a bit-for-bit copy of the floppy (for example, I've never tried to make a copy of a boot disk this way). Maybe there's an obscure trick using 'dd' instead of 'cp' that would work better for some purposes. This is the traditional unixy approach to doing these things... And if you want to read too much about it, you can check things like "man fstab" or "info fstab", "man cp" or "info cp", "man dd" or "info dd", and so on. In general, if you want to read up on these things, I recommend trying: info fileutils Note there doesn't seem to be a "man fileutils". If you've never used info before, you might want to try an "info info" first. ((There are a bunch of "file managers" popping up. Do any of them have any facilities for copying disks?)) === Subject: Re: How to copy floppy disks. From: "Anthony E. Greene" <agreene@pobox.com> Date: Wed, 19 Apr 2000 20:08:53 +0200 "Manuel A. Camacho Q." wrote: > I know this must be a simple one, but got no idea. How can I copy floppy > disks on a single disk drive unit? (from the shell prompt) There may be something like DOS's diskcopy, but this will work too: (insert source disk) mount /dev/fd0 dd if=/dev/fd0 of=somefile bs=1440k umount /dev/fd0 (insert destination disk) mount /dev/fd0 dd if=somefile of=/dev/fd0 bs=1440k === Subject: Re: easiest way to copy a disk or filesystem From: Urs Thuermann <urs@isnogud.escape.de> Date: 01 May 2000 08:31:53 +0200 Chris Maresca <ckm@crust.net> writes: > Right. You can also dd an unmounted device. Usefull for corrupted > drives/diskettes that won't mount. In fact, it's better to not mount the device. 1. Writing to a mounted file system with dd while the file system is being read can result wrong and incosistent data being read and depending on the FS error behavior in a panic. 2. Writing to a mounted file system with dd while the file system is being written can result in a incosistent file system (and later possibly to a panic). 3. Reading a mounted file system with dd while the file system is being written to can result in a incosistent file system image being read by dd. If you copy that to another partition/floppy disk this may cause a panic. === Subject: Re: How to copy floppy disks. From: fred smith <fredex@fcshome.stoneham.ma.us> Date: Thu, 20 Apr 2000 21:41:08 -0400 On Thu, Apr 20, 2000 at 04:19:59PM -0400, rpjday wrote: > > On Thu, 20 Apr 2000, Juan Martinez wrote: > > > I've read every message in this thread and have one question. > > > > Does it matter what block size is used with the dd command? I > > know you should use the same size when writing the floppy that > > you used when creating the image. > > nope, not necessary. generally, the larger the block size, the > more efficient, but i recall doing some benchmark testing a while > back and once you go above a few K for a blocksize, it doesn't > really matter. just don't leave it at the default blocksize of > 512 bytes -- really slows things down. > > > > I'd probably use 1440k because it's the size of the floppy but > > I'd still like to know if it matters. I haven't tried this on Linux, but I have done testing on other systems (more than 1) a few years ago, and in those tests I found that the best throughput was with a blocksize equal to two tracks for both sides of the diskette. I.e., for a high density 3.5" floppy, a blocksize of 36 sectors was good, 72 was somewhat better. Larger than that didn't make any real difference. 18 wasn't bad. The default of many programs of 20 is, OTOH, **horrid**. I don't know how to test this, but my guess has been that it has to do with disk rotation latency. === Subject: RE: How to copy floppy disks. From: Ward William E PHDN <wardwe@nswcphdn.navy.mil> Date: Thu, 20 Apr 2000 13:54:46 -0400 Manuel A. Camacho Q. [mailto:mcamacho@habitat.co.cr] wrote: > > I believe you might be typing about tansferring files to the Windows OS. > > Maybe not!!! anyway if you are typing about transfering floppies with > > Microsoft OS check out this tool called "mtool" from > > Nop. Duplicating a diskette using the Linux shell (bash). Seems by the > replies I have that there is not a way of avoiding doing a temporal file > on a hdd, except installing a /dev/fd1... Shoot! Cracked open my old Unix System programming book, and the very first example has (almost) everything you would need, other that a Perl Wrapper or such..... but it's not quite what I would use... I've appended both. Comments, debugging (I haven't even tested the code to see it compiles...) etc., welcome. This snippet of code can be modified easily. It's from "Advanced Programming in the Unix Environment" copyright 1992 by W. Richard Stevens. p7 ----------------------------------- #include "ourhdr.h" #define BUFFSIZE 8192 int main(void) ( int n; char buf[BUFFSIZE]; while ( (n = read(STDIN_FILENO,buf,BUFFSIZE)) > 0) if (write(STDOUT_FILENO,buf,n) !=n) err_sys("Write error"); if (n<0) err_sys("read error"); exit(0); } ------------------------------------------------------------ Ok, that's my base. Here's my code (NOT TESTED): /* Diskcopy v0.1 */ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> /* I'm not currently doing much error handling... that needs to be fixed */ /* By William Ward 4/20/2000. Please leave me in the list of contributors */ #define BUFFSIZE 1572864 /* Is this right? Should be close... */ int main(int argc, char *argv[]) { int n,m,err; char buf[BUFFSIZE]; char keypress[16]; /* doesn't need to be this big, though... */ if (argc<1) { fprintf(stderr,"Usage: %s /dev/fd<diskno>\n",argv[0]); exit(0); } n=open(argv[1],O_RDONLY); if (n<>0) { fprintf(stderr,"Error opening diskette. Do you have a disk inserted?\n"); exit(-1); } err=read(n,buf,BUFFSIZE); if (err<0) { err_sys("read error"); exit(-2); } err=close(n); fprintf(stdout,"%s read. Change diskettes and press any key\n",argv[1]); while (err=read(STDIN_FILENO,keybress,16))>0 { } m=open(argv[1],O_WONLY); if (m<>0) { fprintf(stderr,"Error opening diskette. Did you have a diskette inserted?\n"); exit(-3); } err=write(m,buf,BUFFSIZE); if (err<0) { err_sys("write error"); exit(-4); } err=close(m); exit(err); } --------------------------------------------------------------- ===