Tải bản đầy đủ (.pptx) (48 trang)

Bài giảng Nhập môn Hệ điều hành: Disk management - Nguyễn Xuân Vinh

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (853.96 KB, 48 trang )

GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH

DISK MANAGEMENT

1

/XX

5/8/21

NHẬP MÔN HỆ ĐIỀU HÀNH
INTRODUCTION TO OPERATING SYSTEMS
[214242]

Nguyễn Xuân Vinh



GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
2

Giới thiệu
 Ngày nay thiết bị lưu trữ sử dụng nhiều loại ổ cứng với mục đích
khác nhau
 SSD
 HDD (3.5 inches, 2.5 inches)
5400 rpm


7200 rpm


3

/XX

5/8/21
NHẬP MÔN HỆ ĐIỀU HÀNH

GV: NGUYỄN XUÂN VINH

Giới thiệu

512G = 670 USD
1TB = 150 USD


4

/XX

5/8/21
NHẬP MÔN HỆ ĐIỀU HÀNH

GV: NGUYỄN XUÂN VINH

SSD



GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
5

Giới thiệu
 1 sector = 512byte
 1 block = 4K,8K,16K,32K = nhiều sector
 1 track = 63 sector
 15 tracks = 1 cylinder


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
6

Chuẩn giao tiếp
Các chuẩn giao tiếp của ổ đĩa cứng
Giao tiếp
(viết tắt)
SCSI

Tên tiếng Anh đầy đủ
Small Computer
System Interface

Ultra160 SCSI

Ultra320 SCSI
ATA
SATA
SATA II
SATA 3
SAS

Advanced
Technology Attachment
Serial ATA 150
Serial ATA 300
Serial ATA 600
Serial Attached SCSI

Tốc độ
truyền dữ liệu
Nhiều loại, 
xem thêm
160 MBps
320 MBps
Max = 133 MBps
150 MBps
300 MBps
600 MBps
12 Gbps


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21

/XX
7

Quản lý đĩa
 Tất cả các ổ đĩa đều là file trong thư mục /dev với ký hiệu
 hd*: đĩa IDE (VD: hda, hdb, hdc, …)
 sd*: đĩa SCSI (VD: sda, sdb, sdc, …)
 Tối đa 8 ổ IDE và 16 ổ SCSI
 Tối đa 16 partition cho ổ IDE và 15 partition cho ổ SCSI


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
8

Chia đĩa
fdisk /dev/sda: lệnh dùng để chia phân khu ổ đĩa
Option:
 m : menu
 n : tạo 1 phân khu đĩa mới
 p : hiện các phân khu đã chia
 w: lưu lại


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX

9

Format đĩa
mkfs –t ext4 /dev/sda1: Format partition sda1 với filesystem là ext4
mount /dev/sda1 /data: ánh xạ partition sda1 vào thư mục data
df –T: kiểm tra lại định dạng file system và các mount point
Các mount point sẽ tự động mất khi khởi động lại máy


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
10

/etc/fstab
 Chứa danh sách các mount point khi khởi động: hệ thống sẽ thực
thi file này để xem danh sách các moun point và mout tự động


GV: NGUYỄN XN VINH
NHẬP MƠN HỆ ĐIỀU HÀNH
5/8/21
/XX
11

Mass Storage
• Many systems today need to store many terabytes of data
• Don’t want to use single, large disk
– too expensive

– failures could be catastrophic
• Would prefer to use many smaller disks


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
12

RAID
 Redundant Array of Inexpensive Disks
 Basic idea is to connect multiple disks together to provide
 large storage capacity
 faster access to reading data
 redundant data
 Many different levels of RAID systems
 differing levels of redundancy, error checking, capacity, and cost
 RAID implementations
 Hardware-based RAID
 Software-based RAID


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
13

Hardware-based RAID

 On a desktop system, a hardware RAID controller may be an
expansion card connected to a bus (e.g. PCI or PCIe), a
component integrated into the motherboard; there are controllers
for supporting most types of drive technology, such as IDE/ATA,
SATA, SCSI, SSA, Fibre Channel, and sometimes even a
combination. The controller and drives may be in a stand-alone
enclosure, rather than inside a computer, and the enclosure may be
directly attached to a computer, or connected via a SAN

Hot swap


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
14

Software-based RAID
 RAID 0: Block-level striping without parity or mirroring
 RAID 1: Mirroring without parity or striping
 RAID 2: Bit-level striping with dedicated Hamming-code parity
 RAID 3: Byte-level striping with dedicated parity
 RAID 4: Block-level striping with dedicated parity
 RAID 5: Block-level striping with distributed parity
 RAID 6: Block-level striping with double distributed parity
 RAID 10: Mirroring without parity, and block-level striping


GV: NGUYỄN XUÂN VINH

NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
15

RAID levels comparision
Level

# Drive

Space
Efficiency

Fault
Tolerance

RAID 0
RAID 1
RAID 2

2
2
3

1
1/n
1 – 1/n –
log2(n-1)

0 (none)

n-1
*

Read
Performan
ce
nX
nX****
Variable

Write
Performan
ce
nX
1X
Variable

Figure


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
16

Striping
 Take file data and map it to different disks
 Allows for reading data in parallel


file data

block 0

Disk 0

block 1

Disk 1

block 2

Disk 2

block 3

Disk 3


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
17

Parity
 Way to do error checking and correction
 Add up all the bits that are 1
 if even number, set parity bit to 0
 if odd number, set parity bit to 1


 To actually implement this, do an exclusive OR of all the
bits being considered
 Consider the following 2 bytes
byte
parity
10110011
1
01101010
0

 If a single bit is bad, it is possible to correct it


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
18

Mirroring
 Keep to copies of data on two separate disks
 Gives good error recovery
 if some data is lost, get it from the other source
 Expensive
 requires twice as many disks
 Write performance can be slow
 have to write data to two different spots
 Read performance is enhanced
 can read data from file in parallel



GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
19

Parity
Là bit cho biết tổng số bit 1 là chẵn hay lẻ
Dùng để phát hiện lỗi khi truyền dữ liệu và
không thể sửa lỗi
7 bits of data
(count of 1 bits)

8 bits including parity
even

odd

0000000 (0)

00000000 (0)

10000000 (1)

1010001 (3)

11010001 (4)


01010001 (3)

1101001 (4)

01101001 (4)

11101001 (5)

1111111 (7)

11111111 (8)

01111111 (7)


GV: NGUYỄN XUÂN VINH

EVEN PARITY BIT

20

/XX

5/8/21

NHẬP MÔN HỆ ĐIỀU HÀNH

A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 0
A adds parity bit and sends: 10010

B receives: 10010
B computes parity: 1^0^0^1 = 0
B reports correct transmission after observing expected even
result.


GV: NGUYỄN XUÂN VINH

EVEN PARITY BIT

21

/XX

5/8/21

NHẬP MÔN HỆ ĐIỀU HÀNH

A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 0
A adds parity bit and sends: 10010 *** TRANSMISSION
ERROR ***
B receives: 11010
B computes overall parity: 1^1^0^1 = 1
B reports incorrect transmission after observing unexpected
odd result.


GV: NGUYỄN XUÂN VINH


ODD PARITY BIT

22

/XX

5/8/21

NHẬP MÔN HỆ ĐIỀU HÀNH

A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 1
A adds parity bit and sends: 10011
B receives: 10011
B computes overall parity: 1^0^0^1 = 1
B reports correct transmission after observing expected odd
result.


GV: NGUYỄN XUÂN VINH

ODD PARITY BIT

23

/XX

5/8/21

NHẬP MÔN HỆ ĐIỀU HÀNH


A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 1
A adds parity bit and sends: 10011
TRANSMISSION ERROR ***
B receives: 11011
B computes overall parity: 1^1^0^1 = 0
B reports correct transmission after observing expected odd
result.


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
24

Cách lưu dữ liệu
Ổ đĩa 1
01101101

Ổ đĩa 1
01101101

XOR

Ổ đĩa 2
11010100

=


XOR

Ổ đĩa 3
10111001

=

Ổ đĩa 3
10111001

11010100

DỮ LIỆU BỊ MẤT


GV: NGUYỄN XUÂN VINH
NHẬP MÔN HỆ ĐIỀU HÀNH
5/8/21
/XX
25

RAID Level-0
 Often called striping
 Break a file into blocks of data
 Stripe the blocks across disks in the system
 Simple to implement
 disk = file block % number of disks
 sector = file block / number of disks
 provides no redundancy or error detection

 important to consider because lots of disks means low Mean
Time To Failure (MTTF)


×