File: floppies.html

package info (click to toggle)
lg-issue13 3-7
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,056 kB
  • ctags: 114
  • sloc: makefile: 36; sh: 4
file content (409 lines) | stat: -rw-r--r-- 14,408 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
 <TITLE>Floppy Disk Tips Issue 14</TITLE>

 <!-- Author:  Bill Duncan
      Email:   bduncan@beachnet.org
      Web:     http://www.beachnet.org/bduncan/
 -->

</HEAD>

<BODY BGCOLOR="#cccccc" TEXT="#000000">

<H4>
&quot;Linux Gazette...<I>making Linux just a little more fun!</I>
&quot;</H4>

<!--===================================================================-->

<P><HR NOSHADE><P>


<H1 ALIGN=CENTER>Floppy Disk Tips</H1>
<H4 ALIGN=CENTER>
 By <A HREF="http://www.beachnet.org/bduncan/">
    Bill Duncan</A>, <FONT SIZE=-1><I>VE3IED</I></FONT>,
 <A HREF="mailto:bduncan@beachnet.org"><TT>bduncan@beachnet.org</TT></A></H4>
<P><HR NOSHADE><P>

<P>Although more computers are becoming network connected every day,
there are many instances where you need to transfer files by the ol'
<I>sneaker-net</I> method.  Here are some hints, tips and short-cuts for doing
this, aimed at users who are new to Linux or Unix.  (There may even be
some information useful to old-timers...)

<UL>
 <LI><A HREF="#FORMAT">Formatting, Filesystems and Mounting</A>
 <LI><A HREF="#BACKUP">Backups, Cpio and Gzip</A>
 <LI><A HREF="#LARGE">Floppy as a Raw Device for Large Files or Directories</A>
 <LI><A HREF="#MISC">Miscellaneous</A>
</UL>

<P>What do I use floppies for?  As a consultant, I frequently do contract
work for companies which, because of security policies, do not connect
to the 'Net.   So, FTP'ing files which I need from my network at home is out of
the question.

<P>My current contract as an example, I am using Linux as an X-Windows terminal
for developing software on their DEC Alphas running OSF.  (I blew away the
Windoze '95 which they had loaded on the computer they gave me.)  I often need to bring
files with me from my office at home, or backup my work to take back home
for work in the evening.  (Consultants sometimes work <I>flex-hours</I>, which generally
means more hours...)<P>

<P>Why use <B>cpio</B>(1) or <B>tar</B>(1) when copying files?  Because it is a
<I>portable</I> method of transferring files from a group of subdirectories
with the file dates left intact.  The <B>cp</B>(1) command may or may not do the
job depending on Operating Systems and versions you are dealing with.
In addition, specifying certain options will only copy files which are new or
have changed.
<P>

<A NAME="FORMAT">
<P><HR NOSHADE><P>
<H2>Formatting, Filesystems and Mounting</H2></A>
<P><HR NOSHADE><P>

The first thing you need to do to make the floppies useful is to format them,
and usually lay down a filesystem.  There are also some preliminary steps
which make using floppy disks much easier, which is the point of this article.

<P>I find it useful to make my username part of the <B>floppy</B> group in the
<B>/etc/group</B> file.  This saves you from needing to su to root much of
the time.  (You will need to log out and log back in again for this to take
effect.)
I also use the same username both on the client's machine and
my home office which saves time. The line should now look like this:<BR>

<BLOCKQUOTE>
<PRE>
floppy::11:root,<EM>username</EM>
</PRE>
</BLOCKQUOTE>

<P>The following setup is assumed for the examples I present here.
The root user must have the system directories in the <STRONG>PATH</STRONG>
environment variable.
Add the following to the <B>.profile</B> file in /root if not already there by
su'ing to root.<BR>

<BLOCKQUOTE>
<PRE>
su -   # this should ask for the <EM>root</EM> password.
cat >> <B>.</B>profile
PATH=/sbin<B>:</B>/usr/sbin<B>:</B>$PATH
&lt;ctrl&gt;-D
</PRE></BLOCKQUOTE>

<!-- TIP TAG -->
You can also use your favorite editor to do this...  I prefer <B>vim</B>(1) and
have this <I>symlink</I>ed to <B>/usr/bin/vi</B> instead of <B>elvis</B>(1) which is
usually the default on many distributions.  VIM has online help, and multiple
window support which is very useful!  (A <I>symlink</I> is created with a
<B>-s</B> option to <B>ln</B>(1), and is actually called a
<I>sym</I>bolic&nbsp;<I>link</I>.)

<P>Next, add the following lines to the <B>/etc/fstab</B> file:
(I have all the user mountable partitions in one place under <B>/mnt</B>.
You may want a different convention, but this is useful.  I also have
/mnt/cdrom symlinked to /cd for convenience.)<BR>

<BLOCKQUOTE>
<PRE>
/dev/fd0    /mnt/fd0  ext2    noauto,user 1 2
</PRE>
</BLOCKQUOTE>

<P>Still logged in as root, make the following symlink:
(If you have more than one floppy drive, then add the floppy number
as well.)<BR>
<BLOCKQUOTE>
<PRE>
ln  -s  /mnt/fd0  /fd

    -or-

ln  -s  /mnt/fd0  /fd0
</PRE>
</BLOCKQUOTE>
These two things make mounting and unmounting floppies a cinch.  The
<B>mount</B>(8) command follows the symlink and
accesses the <B>/etc/fstab</B> file for any
missing parameters, making it a useful shortcut.


<P>To make the floppy usable as an ext2fs Linux filesystem, do the following
as root:
(The <I>username</I> is whatever username you use on regularly on the
system.  You, of course, should not use the <I>root</I> user for normal
use!)
<BR>


<BLOCKQUOTE>
<PRE>
export PATH=/sbin:/usr/sbin:$PATH   # not needed if you set environment
fdformat /dev/fd0
mke2fs /dev/fd0
mount /dev/fd0 /mnt/fd0
chown username /mnt/fd0
</PRE>
</BLOCKQUOTE>


You may need to specify the geometry of the floppy you are using.
If it is the standard 3.5 inch double sided disk, you may need to
substitute <B>/dev/fd0H1440</B> for the device name (in 1.2.x kernels).
If you have a newer 2.xx kernel and <B>superformat</B>(1), you may want
to substitute this for <B>fdformat</B>.  See the notes in the
<A HREF="#MISC">Miscellaneous</A> section below, or look at the man page.
You may now exit out of <B>su</B>(1) by typing:
<BLOCKQUOTE>
<PRE>
exit
</PRE>
</BLOCKQUOTE>

<P>From this point on, you may use the <B>mount</B>(8) and <B>umount</B>(8) 
commands logged in as your normal username by typing the following:<BR>
<BLOCKQUOTE>
<PRE>
mount /fd
umount /fd
</PRE>
</BLOCKQUOTE>

<A NAME="BACKUP">
<P><HR NOSHADE><P>
<H2>Backups, Cpio and Gzip</H2></A>
<P><HR NOSHADE><P>

<P>For backing up my work to take home or to take back to the office I use
<B>cpio</B>(1) instead of <B>tar</B>(1) as it is far more flexible, and
better at handling errors etc.  To use this on a regular basis, first create
all the files you need by specifying the command below <EM>without</EM>
the <B>-mtime -1</B> switch.  Then you can make daily backups from the base
directory of your work using the following commands:<BR>

<BLOCKQUOTE>
<PRE>
cd <EM>directory</EM>
mount /fd
find <B>.</B> -mtime -1 -print | cpio -pmdv /fd
sync
umount /fd
</PRE>
</BLOCKQUOTE>

<P>
When the floppy stops spinning, and the light goes out, you have your
work backed up.  The <B>-mtime</B> option to <B>find</B>(1) specifies
files which have been modified (or created) within one day (the <B>-1</B>
parameter).  The options for <B>cpio</B>(1) specify <EM>copy-pass</EM> mode,
which retain previous file modification times, create directories where needed,
and do so verbosely.  Without a <B>-u</B> (<I>unconditional</I>) flag, it will
not overwrite files which are the same age or newer.

<P>
This operation may also be done over a network, either from NFS mounted filesystems,
or by using a remote shell as the next example shows.

<BLOCKQUOTE>
<PRE>
mount /fd
cd /fd
rsh  remotesystem '(cd <I>directory</I>; find <B>.</B> -mtime -1 -print | cpio -oc)' |
     cpio -imdcv
sync
cd
umount /fd
</PRE>
</BLOCKQUOTE>
This example uses <B>cpio</B>(1) to send files from the remote system, and
update the files on the floppy disk mounted on the local system.  Note the
<I>pipe</I> (or veritical bar) symbol at the end of the remote shell line.
The arguments which are enclosed in quotes are executed remotely, with
everything enclosed in braces happening in a subshell.  The <I>archive</I>
is sent as a stream across the network, and used as input to the <B>cpio</B>(1)
command executing on the local machine.  (If both systems are using a recent
version of GNU cpio, then specify <B>-Hcrc</B> instead of <B>c</B> for the
archive type.  This will do error checking, and won't truncate inode numbers.)<BR>
The remote system would have:  <I>cpio -oHcrc</I><BR>
and the local side would have:  <I>cpio -imdvHcrc</I><P>

<P>To restore the newer files to the other computer, change directories to
the <I>base directory of your work</I>, and type the following:<BR>

<BLOCKQUOTE>
<PRE>
cd <EM>directory</EM>
mount -r /fd
cd /fd
find <B>.</B> -mtime -1 -print | cpio -pmdv ~-
cd -
umount /fd
</PRE>
</BLOCKQUOTE>

<P>
If you needed to restore the files completely, you would of course leave out
the <B>-mtime</B> parameter to <B>find</B>(1).
<P>

<!-- TIP TAG -->
<P>The previous examples assume that you are using the <B>bash</B>(1) shell,
and uses a few quick tricks for specifying directories.  The &quot;<B>~-</B>&quot;
parameter to cpio is translated to the <I>previous default directory</I>.
In other words, where you were before cd'ing to the /fd directory.
(Try typing: <TT>echo ~-</TT> to see the effect, after you have changed
directories at least once.)
The <B>cd ~-</B> or just <B>cd -</B> command is another shortcut to switch
directories to the previous default.  These shortcuts often save a lot of time
and typing, as you frequently need to work with two directories, using this
command to alternate between them or reference files from where you were.



<P>If the directory which you are tranferring or backing up is larger than
a single floppy disk, you may need to resort to using a compressed archive.
I still prefer using <B>cpio</B>(1) for this, although <B>tar</B>(1) will
work too.  Change directories to your work directory, and issue the following
commands:

<BLOCKQUOTE>
<PRE>
cd <EM>directory</EM>
mount /fd
find <B>.</B> -mtime -1 -print | cpio -ovHcrc | gzip -v > /fd/backup.cpio.gz
sync
umount /fd
</PRE>
</BLOCKQUOTE>

The <B>-Hcrc</B> option to cpio(1) is a new type of archive which older
versions of cpio might not understand.  This allows error checking, and
inode numbers with more than 16 bits.

<P>Of course, your original archive should be created using <B>find</B>(1)
without the <I>-mtime -1</I> options.

<A NAME="LARGE">
<P><HR NOSHADE><P>
<H2>Floppy as a Raw Device for Large Files or Directories</H2></A>
<P><HR NOSHADE><P>

Sometimes it is necessary to backup or transfer a file or directories which
are larger than a floppy disk, even when compressed.  For this, we finally
need to resort to using tar.

<P>Prepare as many floppies as you think you'll need by using the <B>fdformat</B>(8)
command.  You do not need to make filesystems on them however, as you will be
using them in <I>raw</I> mode.

<P>If you are backing up a large set of subdirectories, switch to the base
subdirectory and issue the following command:
<BLOCKQUOTE>
<PRE>
cd <EM>directory</EM>
tar  -cv -L 1440 -M -f /dev/fd0  <B>.</B>
</PRE>
</BLOCKQUOTE>

This command will prompt you when to change floppies.  <STRONG><EM>Wait for the
floppy drive light to go out of course!</EM></STRONG>

<P>If you need to backup or transfer multiple files or directories, or just a single
large file, then specify them instead of the period at the end of the tar command
above.
<!-- I made the period bold, as it didn't show up very well otherwise -->

<P>Unpacking the archive is similar to the above command:<BR>
<BLOCKQUOTE>
<PRE>
cd <EM>directory</EM>
tar  -xv -L 1440 -M -f /dev/fd0
</PRE>
</BLOCKQUOTE>

<A NAME="MISC">
<P><HR NOSHADE><P>
<H2>Miscellaneous</H2></A>
<P><HR NOSHADE><P>

Finally, here are some assorted tips for using floppies.

<P>The <B>mtools</B>(1) package is great for dealing with MS-DOG
floppies, as we sometimes must.  You can also <B>mount</B>(8) them as a Linux
filesystem with either msdos or umsdos filesystem types.  Add another
entry to the <B>/etc/fstab</B> entry you made before, so that the two
lines will look like this:<BR>
<BLOCKQUOTE>
<PRE>
/dev/fd0    /mnt/fd0  ext2    noauto,user 1 2
/dev/fd0    /mnt/dos  msdos   noauto,user 1 2
</PRE>
</BLOCKQUOTE>
You can now mount an MS-DOS floppy using the command:<BR>
<BLOCKQUOTE>
<PRE>
mount /mnt/dos
</PRE>
</BLOCKQUOTE>
You can also symlink this to another name as a further shortcut.
<BLOCKQUOTE>
<PRE>
ln -s /mnt/dos /dos
mount /dos
</PRE>
</BLOCKQUOTE>

<!-- TIP TAG -->
<P>The danger of using the <B>mount</B>(8) commands rather than <B>mtools</B>(1)
for users who are more familiar with MSDOS, is that <B><I>you need to explicitly
unmount floppies</I></B> before taking them out of the drive using
<B>umount</B>(8).
Forgetting this
step can make the floppy unusable!  If you are in the habit of forgetting, a simple
low-tech yellow Post-it note in a strategic place beside your floppy drive might
save you a few headaches.  If your version of Post-it notes has the &lt;BLINK&gt;
tag, use it!&nbsp;&nbsp;&nbsp;<TT>;-)</TT><BR>


<BLOCKQUOTE>
<TABLE BORDER=0 CELLPADDING=9><TR><TD BGCOLOR="#ffffcc">&quot;<B><I><BLINK>umount
me first!</BLINK></I></B>&quot;</TD></TR></TABLE>
</BLOCKQUOTE>
<!-- sorry for that blink tag... ;-)  -->


<P>Newer systems based on the 2.xx kernel are probably shipped with <B>fdutils</B>.
Check to see if you have a <B>/usr/doc/fdutils-xxx</B> directory,
where xxx is a version number.  (Mine is 4.3).
Also check for the <B>superformat</B>(1) man page.  This supersedes
<B>fdformat</B>(1) and gives you options for packing much more
data on floppies.  If you have an older system, check the
<A HREF="ftp://ftp.imag.fr/pub/Linux/ZLIBC/fdutils/">ftp://ftp.imag.fr/pub/Linux/ZLIBC/fdutils/</A>
ftp site for more information.

<P>The naming convention for floppies in newer 2.xx kernels has also changed,
although the <B>fd</B>(4) man page has not been updated in my distribution.
If you do not have a <B>/dev/fd0H1440</B> device, then you probably have the newer
system.

<P> <hr> <P> 
<center><H5>Copyright &copy; 1997, Bill Duncan <BR> 
Published in Issue 13 of the Linux Gazette</H5></center>

<!--===================================================================-->
<P> <hr> <P> 
<A HREF="./lg_toc13.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif" 
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../lg_frontpage.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./filter.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./gm.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P> 
</BODY>
</HTML>