1. UNIX OS
Lecture VI
Simonas Kareiva
Vilnius University
Faculty of Mathematics
and Informatics
Preparation of the material was supported by the project „Increasing Internationality in Study
Programs of the Department of Computer Science II“, project number VP1–2.2–ŠMM-07-K-
02-070, funded by The European Social Fund Agency and the Government of Lithuania.
3. Part I : file systems and disks
disk's structure and terminology
file system types
Linux file systems
indexing
3
4. a very typical hard disk
terms:
A) Track
B) Geometrical sector
C) Sector
D) Cluster
4
5. Clusters and sectors
Sectors make clusters
Size of a sector – 512 bytes, 2048 bytes
Sectors are grouped into clusters in order to save
addressing and number of disk requests.
Cluster is the smallest logical disk’s element which can
store information, so:
5KB file in disk uses 8KB when cluster size is 4KB
5
6. FAT…
FAT… bits tell the cluster address table size:
FAT12 – maximum partition Size– 32MB
Max number of clusters – 2^12-12, clusters up to 8K
FAT16 – max partition size – ??? GB (exercise)
Clusters up to 64K
FAT32 - (many nice features) – max partition still 2TB
6
10. Disk devices (Solaris)
/dev/dsk/
/dev/dsk/c1
/dev/dsk/c1t0
/dev/dsk/c1t0d0
/dev/dsk/c1t0d0p0
/dev/dsk/c1t0d0s1
c – controller (control device)
t – SCSI target
d – LUN-id (mostly 0)
s – Solaris slice or p – primary partition
10
11. Working with disks (Linux)
# fdisk -l /dev/hdc
Disk /dev/hdc: 64 heads, 63 sectors, 787 cylinders
Units = cylinders of 4032 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 610 1229728+ 83 Linux
/dev/hdc2 611 787 356832 5 Extended
/dev/hdc5 611 787 356800+ c Win95 FAT32 (LBA)
11
12. Creating a new disk
Create a partition with fdisk (RTM)
Linux:
mkfs -t ext2 /dev/hdc1
or
mkfs.reiserfs /dev/hdc1
FreeBSD:
newfs /dev/da0s1a
12
15. NFS protocol
Like Windows File Sharing, but not exactly...
Designed for intensive data exchange between servers
Easily configurable
From an OS point of view, its just another file system
(partition)
15
16. What you’ll need:
FreeBSD:
nfsd – daemon, processing user requests
mountd – daemon, responsible for FS mounting
rpcbind – additional service used for chatting within the
network
/etc/exports:
Format:
/folder/which/shared –paremeters client1 client2…
16
18. Or use:
# showmount -e server
Exports list on server:
/usr 10.10.10.0
/a 10.10.10.0
# mkdand /mnt/a
# mount server:/a /mnt/a
# df -F nfs
Filesystem Type blocks use avail %use Mounted on
server:/a nfs 68510 55804 12706 81% /mnt/a
18
19. Practical uses
Most OS’s support installation through NFS, its enough to
have 1 DVD which is shared via NFS on LAN.
By using NFS you can create a couple of HTTP servers
with the same content and distribute traffic between
them by using the round-robin load balancing algorithm.
In large networks, it is useful to keep /home folders on
NFS, so that user’s files are saved centrally.
Exercise: think of more practical NFS uses!
19
20. RAID
terms:
RAID – Redundant array of Inexpensive Disks
JBOD – Just a bunch of … ?
Hot spare – reserve player
Stripe – data distribution in multiple devices
Mirror – data backup in multiple devices
Parity – protection from errors system (XOR):
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
Dedicated parity – data in separate disk
20
23. RAID0
Size = n * min ( 200GB, 300GB ) = 800GB
Advantages:
Fast reading
Fast writing
Lots of space
Disadvantages:
Totally unreliable (if one of the disks
breaks down, the entire RAID stops)
23
24. RAID1
Size= min ( 200GB, 300GB ) = 200GB
Advantages:
Fast reading
Reliability and security
Disadvantages:
Expensive writing (to both disks)
24
25. RAID5
Size= n-1 * min ( 200GB, 300GB ) = 200GB
Advantages:
Fast reading
Fast writing
Reliability and security (parity)
Disadvantages:
Requires at least 3 disks, often requires +1 additional
Slow, when at least stripe size is being written
25
26. Parity
disk #1: -------- (Data)
disk #2: -------- (Data)
disk #3: -------- (Data)
disk #4: -------- (Data)
disk #5: -------- (Hot Spare)
disk #6: -------- (Parity)
26
27. Parity
disk #1: 00101010 (Data)
disk #2: 10001110 (Data)
disk #3: 11110111 (Data)
disk #4: 10110101 (Data)
disk #5: -------- (Hot Spare)
disk #6: -------- (Parity)
00101010 XOR 10001110 XOR 11110111 XOR 10110101 = 11100110
D1 XOR D2 XOR D3 XOR D4 = ( (D1 XOR D2) XOR D3) XOR D4
27
28. Parity
disk #1: 00101010 (Data)
disk #2: 10001110 (Data)
disk #3: 11110111 (Data)
disk #4: 10110101 (Data)
disk #5: -------- (Hot Spare)
disk #6: 11100110 (Parity)
28
29. Parity
disk #1: 00101010 (Data)
disk #2: 10001110 (Data)
disk #3: --Dead-- (Data)
disk #4: 10110101 (Data)
disk #5: 11110111 (Hot Spare)
disk #6: 11100110 (Parity)
00101010 XOR 10001110 XOR 11100110 XOR 10110101 = 11110111
29