Unix 6 en
-
Upload
simonas-kareiva -
Category
Documents
-
view
64 -
download
1
Transcript of Unix 6 en
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.
Lecture VI outline
File systems
Disks
NFS protocol
RAID arrays
2
Part I : file systems and disks
disk's structure and terminology
file system types
Linux file systems
indexing
3
a very typical hard disk
terms:
A) Track
B) Geometrical sector
C) Sector
D) Cluster
4
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
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
More file systems:
NTFS
UFS
EXT2
EXT3
ReiserFS
HFS
7
Disk devices (Linux):
/dev/ /dev/hda
/dev/hda1 /dev/hda2
/dev/hdb /dev/hdc /dev/sda
/dev/sda1 …
8
Disk devices (FreeBSD)
/dev/ /dev/ad0
/dev/ad0s1 /dev/ad0s1a /dev/ad0s1b /dev/ad0s1c
/dev/ad1 /dev/ad1s1
/dev/ad1s1a /dev/da0
/dev/da0s1 /dev/da0s1a
…
9
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
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
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
Mounting
mkdir /mnt/new
mount /dev/hdc1 /mnt/new
13
/etc/fstab
# FreeBSD fstab:# Device Mountpoint FStype Options Dump Pass#/dev/da0s1b none swap sw 0 0/dev/da0s1a / ufs rw 1 1/dev/da0s1e /tmp ufs rw 2 2/dev/da0s1f /usr ufs rw 2 2/dev/da0s1d /var ufs rw 2 2/dev/da1s1a /squid ufs rw 2 2/dev/acd0 /cdrom cd9660 ro,noauto 0 0
# Linux fstab:/dev/rootvg/lv00 / ext3 defaults 1 1/dev/rootvg/lv02 /vz ext3 defaults 1 2/dev/md0 /boot ext3 defaults 1 2tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/rootvg/lv01 swap swap defaults 0 0
14
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
What you’ll need:
FreeBSD:nfsd – daemon, processing user requestsmountd – daemon, responsible for FS mounting rpcbind – additional service used for chatting within
the network
/etc/exports:Format:
/folder/which/shared –paremeters client1 client2…
16
/etc/exports:
/cdrom -ro host1 host2 host3/home -alldands 10.0.0.2 10.0.0.3 10.0.0.4/a -maproot=root host.example.com box.example.org/usr/src /usr/ports host4
Then we execute:
# rpcbind # nfsd -u -t -n 4 # mountd -r
17
Or use:# showmount -e serverExports 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
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
RAID
terms:RAID – Redundant array of Inexpensive Disks JBOD – Just a bunch of … ?Hot spare – reserve playerStripe – data distribution in multiple devicesMirror – 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
RAID types
RAID0, RAID1, RAID2, RAID3, RAID4, RAID5, RAID6
RAID0+1, RAID1+0, RAID0+3, RAID51, …
21
Say,
We have four disks:Three 200GB disksOne 300GB disk
22
RAID0
Size = n * min ( 200GB, 300GB ) = 800GB
Advantages:Fast readingFast writingLots of space
Disadvantages:Totally unreliable (if one of the disks
breaks down, the entire RAID stops)
23
RAID1
Size= min ( 200GB, 300GB ) = 200GB
Advantages:Fast readingReliability and security
Disadvantages:Expensive writing (to both disks)
24
RAID5
Size= n-1 * min ( 200GB, 300GB ) = 200GB
Advantages:Fast readingFast writingReliability and security (parity)
Disadvantages:Requires at least 3 disks, often requires +1
additionalSlow, when at least stripe size is being written
25
Parity
disk #1: -------- (Data)disk #2: -------- (Data)disk #3: -------- (Data)disk #4: -------- (Data)disk #5: -------- (Hot Spare)disk #6: -------- (Parity)
26
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
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
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
RAID2, RAID3
30
31
RAID derivatives32
Yo, dawg, I heard you like RAID…
… so we put more RAID into your RAID so that you can have more RAID!
33
34
Cheat-sheet of RAID configurations
35