A free Basic UNIX-training with muLinux
Access to Floppies
When muLinux is started from a boot-disk, all our
settings and changes from our previous session are lost.
A virgin copy of muLinux is loaded into memory (RAM) each time you boot muLinux.
That's a good learning exercise but normally you want to save the results
of our work. The safest way is to save the work on a floppy disk.
Under UNIX there are no drive letters as in DOS.
The system used to access floppies and hard disks originated at a time when
personal computers had only one or two floppy-drives (A:, B:).
Later hard disks where added (C:, D:, ...).
This raises some questions:
- i.e., How can I manage more disks than the alphabet has letters?
- I want to save my data, where shall I put it, on which drive and in what directory? In Windows, drives are simply specified with letters instead of the descriptive terms common to Linux such as hda1, hda5, hdb1, etc.
- How can I add hard disks without changing the structure of my data?
Floppies have a secondary role in the Unix world. The Superuser can even deny access to floppies for the normal user. Unix was meant to work with multiple hard disks. Therefore the structure of the data needs to be independent of the drive space. Directories in Unix can be put on hard disks, floppies,
and in RAM, while keeping the user's data unchanged. For example, the user data is always in the directory /home no matter what drive is used.
Mounting the floppy-drive
Adding drives to directories is to mount the drive.
The directory in which you place the contents of the drive, is
called the mountpoint The command for this is mount.
Most of the time there are already mountpoints for changing drives.
Unfortunately the different Unix versions don't use a standardized
mountpoint.
Sometimes they are located in the directory /mnt
In other versions the directory is /floppy.
Under muLinux the directory is /a.
You can make any directory as mountpoint and use the command mount plus an option such as /fd0 to access it.
The option for the mount command is the device name of the floppy drive.
While looking at the directory structure, you find the directory
/dev as place for device files. There, the devices are files.
The first floppy drive, under DOS the A: drive, is written as
the file /dev/fd0.
Remove the muLinux boot disk and insert a DOS floppy.
To mount the floppy drive into the directory /a, you enter the
following:
/# mount /dev/fd0 /a
muLinux automatically recognizes if this is a DOS or a Linux disk.
Then you can display the contents of the disk:
/# ls /a
Before you can remove the disk from the drive, you must unmount it.
For this you need the command umount with the name of the
device and the mountpoint.
/# umount /a
To see what is mounted, just enter the command
mount without options:
/# mount
/dev/ram0 on / type ext2 (rw)
/proc on /proc type proc (rw)
/dev/ram1 on /usr type ext2 (rw)
/dev/ram2 on /tmp type ext2 (rw)
/dev/fd0 on /a type umdos (rw)
/#
You see RAM-disks (/dev/ram*) with the mountpoints /,
/usr and /tmp.
And the special directory /proc. you also see the type.
The standard file system under Linux is ext2.
The bold line appears only because you have mounted a DOS disk.
Using the command history (cursor up arrow) you can quickly select the
needed command. You can then mount the floppy drive and try a few things.
/# mount /dev/fd0 /a
/# cd /a
/a#
Now you are in the mounted floppy drive.
Try creating a file with a very long name:
/a# mkdir abcdefghijklmnopqrstuvwxyz
/a# ls
abcdefgh
/a#
Unix allows long file names unlike DOS with its 8 character limit.
And another experiment:
/a# mkdir ABC
/a# ls
abc abcdefgh
/a#
DOS does not differentiate between Upper and Lower case as Unix does.
The DOS floppy format is good for exchanging data with the DOS and
Windows, but as storage space for Linux it isn't very useful.
To unmount the floppy again:
/a# umount /a
umount: /dev/fd0: device is busy
/a#
Why is the device busy?
Of course! The mount point /a is the parent directory. You change to the root directory and unmount:
/a# cd /
/# umount /a
/#
Everything is fine again.
But we are curious to see what /a contains now.
/# ls /a
total 0
/#
Now /a is empty.
Formatting floppies
You have seen that DOS disks are only useful for data exchange with DOS-
and Windows. The Linux-format is called ext2.
Formatting in Linux requires two steps:
- Low-Level-formatting with the command fdformat
(floppy disk format).
- Making the ext2 file system with the command mkfs.ext2.
In other Unix versions this command is mkfs
(make file system).
With the format command you need to specify the device.
In this case it can't be the general device /dev/fd0.
For formatting you need to specify the device for the 1.44
MByte format thus: /dev/fd0H1440.
The device must not be mounted in this case.
First format the floppy:
/# fdformat /dev/fd0H1440
Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.
Formatting ... done
Verifying ... done
Then make the file system:
/# mkfs.ext2 /dev/fd0H1440
...
...
Writing inode tables: done
Writing superblocks and file system accounting information: done
/#
Remove the floppy from the drive and label it"muLinux-workdisk",
then put it back into the drive again.
Now you can mount the disk and look at the contents.
It should be empty except for a directory called lost+found.
Files which where lost in the file system are saved in this directory.
Other floppy-formats
If you have a second floppy drive you can access it with /dev/fd1 and list its contents if desired.
The star * is a so called wildcard and represents any letter.
/# ls /dev/fd0*
0 /dev/fd0 0 /dev/fd0H1440
0 /dev/fd0h17220 0 /dev/fd0h1440
/#
There is also a floppy format of 1,722 MByte permitting us to format our floppies with a greater storage capacity. Be aware that these disks are not always readable under other Linux versions.
Checking the drive space
How can you check how much space you have on your disks?
The command df (disk free)
shows the free diskspace on all mounted drives.
First you must mount the floppy and then:
/# df
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/ram0 1428 1284 144 90% /
/dev/ram1 1884 1542 342 82% /usr
/dev/ram2 987 368 568 39% /tmp
/dev/fd0 1390 13 1305 1% /a
You may also look at one specific drive thus:
/# df /dev/fd0
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/fd0 1390 13 1305 1% /a
Configuration of file systems and their Mountpoints
Earlier I mentioned that access to floppies can be
denied for the normal user. This and other configurations can be found in the file
fstab.
This file, as a configuration file is placed in /etc.
Let's have a look at this file:
/# less /etc/fstab
...
/dev/fd0 /a auto defaults,noauto,rw 1 1
...
There is a line for each mounted file system.
Here CDROM, floppy, and hard disk drives, are mounted automatically and
and the permissions set for the normal user.
The line above means that the floppy drive /dev/fd0 is mounted
standard on the directory /a.
This means that with the command mount /dev/fd0 /a you can skip
the /dev/fd0.
The auto makes an automatic recognition of the file system.
DOS or ext2 floppies are recognized automatically.
The parameter defaults sets the following parameters on standard
(as far as I understand).
With a "normal" Linux (SuSE) the following line is used:
...
/dev/fd0 /a auto noauto,user,exec,sync 0 0
...
The floppy isn't mounted automatically (noauto) but can be
mounted by normal users (user) and is synchronized after unmounting
(sync).
Programs and scripts can be executed from floppies (exec).
This allows the installation program to be started from a floppy.
Robert.Warnke@giso.de (copyleft) Robert Warnke, Berlin (Germany) - You can write me in English. | http://rowa.giso.de | translated by mek, corrected by Bob Goodwin
|