NEXT
$V1$
$V1$
PAGEFLOP
FORWARD
SELECTOR
SELAGAIN
WRONGSEL
YOUR SELECTION IS NOT IN THE 0 - #SELIMIT RANGE Please try again
AANVANG
Copyright CourseWare Technologies Inc., 1985-88
Lesson - 6
FILE SYSTEMS
MENU
File Systems|Topics to Learn|6-0|9,35
# Topic
--- -------
1 - Logical File Systems
2 - File System Structure
3 - Making File Systems
4 - Mounting File Systems
5 - Unmounting File Systems
6 - Lesson Review
0 - Return to the Main Menu
P1
File Systems|Logical File Systems|6-1.1|7,49
A file system is the organizing structure for
data. It is a structure which includes the root and
all of its subdirectories.
A device is some medium on which you place a
file system, usually some form of magnetic disk.
Each type of disk is a called a physical device.
P2
File Systems|Logical File Systems|6-1.2|8,49
One or more file systems can reside on a
single physical device.
Small disks (under 5000 blocks) can be devoted
exclusively to a single file system. Large disks
can hold several file systems and are usually split
into several logical disks.
P3
File Systems|Logical File Systems|6-1.3|6,48
Each logical disk has a name that the file
system associates with that area on the disk.
This name is actually the name of a special file
located in the directory /dev. For example, on a
UNIX system, the high density disk drive might be
called /dev/rfd196ds15.
UNIX system, the high density disk drive might be
called /dev/rsave
BSD system, an Eagle disk drive on a Xylogics
controller might be called /dev/xy0a.
P4
File Systems|Logical File Systems|6-1.4|9,58
You can display the structure of the file systems
on your terminal screen with the df command.
For example:
1366 blocks 1909 i-nodes
/u3 (/dev/d1150): 11790 blocks 2758 i-nodes
/usr/CTI (/dev/CTI ): 482 blocks 548 i-nodes
/usr/lib/font (/dev/fonts): 3006 blocks 964 i-nodes
/u2 (/dev/u2 ): 7844 blocks 998 i-nodes
/u (/dev/u ): 1176 blocks 617 i-nodes ...
Filesystem kbytes used avail capacity Mounted on
/dev/xy0a 7445 5676 1024 85% /
/dev/xy1a 7437 5494 1199 82% /pub
/dev/xy0g 38369 34230 311 99% /usr
/dev/xy1d 72935 57439 8202 88% /local2
/dev/xy1e 163751 122691 24684 88% /usr2 ...
P5
File Systems|File System Structure|6-2.1|7,54
Every file system has the same basic layout with
four fundamental parts:
* the boot block,
* the super block,
* inodes, and
* data blocks.
P6
File Systems|File System Structure|6-2.2|13,54
The 0th block of every file system is called the
boot block and is reserved for the bootstrap program
which loads the operating system into the memory.
The 1st block is the file system header - the
super block which contains the information on:
* the name of the file system,
* the size of the file system,
* the number of inodes in the file system, and
* information about the free list
(the list of free inodes).
P7
File Systems|File System Structure|6-2.3|13,54
Every file has a single inode which contains
the file description and its physical address. An
inode contains information about the following:
* file location,
* file length,
* access mode (file protection),
* relevant dates, and
* owner of the file.
The inodes are stored in the file system
starting at block 2.
P8
File Systems|File System Structure|6-2.4|8,54
File systems of different sizes contain different
numbers of inodes; the exact count is stored in the
super block.
Since inodes are fixed in size and are numbered
consecutively from 0 it is possible to locate any file
given its inode number.
P9
File Systems|File System Structure|6-2.5|10,54
The data blocks of a file may be physically
scattered throughout the disk, but logically the
blocks form a long chain which contains the
information in the file.
In addition to the information on the file
length, file owner, access mode and the relevant
dates, the inode also has a list of 13 disk block
numbers stored in the inode.
P10
File Systems|Making File Systems|6-3.1|7,54
Your system is initially supplied with logical
disks like /dev/root and /dev/fd1. However, you
can make new file systems.
/etc/mkfs is the command to make a new file
system.
/etc/newfs is the command to make a new file
system.
P11
File Systems|Making File Systems|6-3.2|3,54
You should understand mkfs very well before
You should understand newfs very well before
you try to use it. Incorrect procedure may erase
another file system, including the root file system!
P12
File Systems|Mounting File Systems|6-4.1|9,54
When a file system is first put on-line, it must
be "mounted" on a device name so the kernel knows its
address or location. Each file system on a disk must
be mounted separately.
A practical feature of UNIX is that logical file
systems can be mounted on any directory in the file
system.
P13
File Systems|Mounting File Systems|6-4.2|11,54
Mountable file systems have several advantages:
* They help make the system more robust because only
necessary file systems are mounted.
* It is easier to backup and recover files when you don't
have to keep everything on one partition.
* You can allocate an entire file system to a project
to create a logical separation for various projects.
The command to mount a file system is /etc/mount.
P14
File Systems|Mounting File Systems|6-4.3|7,54
The syntax of the mount command is:
/etc/mount device dirname
where the device is the name of the device you want to
mount the file system on and dirname is the name of the
directory under which the file system will be placed.
Note that the directory must exist before you execute the
/etc/mount command. If it doesn't, use mkdir to create it.
P15
File Systems|Mounting File Systems|6-4.4|11,45
To mount the file system /dev/ud24 on the
directory /a1 you would first
mkdir /a1
if it didn't already exist, then enter:
/etc/mount /dev/ud24 /a1
Be sure to check permissions!
P16
File Systems|Mounting File Systems|6-4.5|9,54
By typing /etc/mount with no arguments, you
will get information about the file systems
currently mounted.
The file that holds the catalogue of all mounted
file systems is:
/etc/mnttab
/etc/mnttab
/etc/mtab
P17
File Systems|Unmounting File Systems|6-5.1|7,46
The process of unmounting a file system is
the reverse of mounting a file system.
The /etc/umount command will unmount a file
system. Physically, /etc/umount removes a file
system from the directory structure.
P18
File Systems|Unmounting File Systems|6-5.2|9,54
Note that you unmount the device containing
the file system, not the directory associated with
that file system.
Unmounting file systems should be done in
single-user mode after executing the /etc/shutdown
command. Note that /etc/shutdown often unmounts
non-root file systems.
P19
File Systems|Unmounting File Systems|6-5.3|11,54
Some precautions you should take before unmounting
a file system are:
1. Execute the sync command, which will assure
that all pending I/O is completed on the
system, that is, that all buffers are empty.
2. /etc/umount will not work if someone is using
a file from a file system you are trying to
unmount. You will get a message like
"umount:device busy".
3. The root file system cannot be unmounted.