1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài giảng Quản trị Linux: Quản trị hệ thống tập tin - Đặng Thanh Bình

43 72 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 43
Dung lượng 1,16 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Bài giảng Quản trị Linux: Quản trị hệ thống tập tin gồm có những nội dung chính sau: Kiến trúc hệ thống tập tin, FHS, hệ thống tập tin nhật ký, Không gian hoán chuyển, quản trị tập tin cơ bản. Mời các bạn cùng tham khảo để biết thêm các nội dung chi tiết.

Trang 1

Đặng Thanh Bình

Quản trị hệ thống tập tin

Trang 2

• Kiến trúc hệ thống tập tin

• FHS

• Hệ thống tập tin nhật ký

• Không gian hoán chuyển

• Quản trị tập tin cơ bản

Trang 3

– Xác định cách thức thông tin được lưu trữ

• Một số FS tạo ra các bản sao của dữ liệu, trongkhi một FS khác có thể giúp tăng tốc truy cập dữliệu

Trang 4

CẤU TRÚC FILE SYSTEM

Trang 5

Phân loại tập tin

• Các hệ thống tập tin chia tập tin thành 2 loại:

– Các tập tin chia sẻ được và không chia sẻ được

– Tập tin biến và tập tin tĩnh

• Variable file, chẳng hạn các file văn bản, có thể được thay đổi nội dung liên tục

• Static file, chẳng hạn các tập tin nhị phân, không thay đổi nội dung trừ khi người quản trị thao tác.

Trang 6

File System Hierarchy Standard (FHS)

– Tương thích với các hệ thống dùng chung chuẩn

– Khả năng mount phân vùng /usr/ dưới dạng chỉ đọc

 có thể mount CD-ROM

Trang 7

– udev demon quản lý việc khởi tạo và remove các thiết

bị quản lý trong /dev/

Trang 8

FHS Organization

• /etc: chứa các file cấu hình

• /lib: chứa các file thư viện để chạy các file nhịphân trong /bin/ và /sbin/

Trang 9

FHS Organization

• /media: chứa các thư mục con được dung làmmount point cho các thiết bị lưu trữ removeablenhư flash USB, DVD, CD-ROM, đĩa Zip

• /mnt: các FS được mount tạm thời, chẳng hạncác điểm mount NFS

• /opt: nơi lưu các gói phần mềm

• /proc: chứa các tập tin đặc biệt giúp lấy thông tin

từ hoặc gửi thông tin đến kernel

Trang 10

FHS Organization

• /sbin: các file thực thi được dùng bởi root user

• /usr: nơi lưu trữ các tập tin có thể dùng để chia

sẻ giữa các máy khác nhau

• /var:

– Variable data file

– Còn được dùng để chứa các file log, file tạm

Trang 11

EXT4 FILE SYSTEM

Trang 12

Journaling File System

• Theo dõi những thay đổi trong tương lai của FS

và ghi nhận trong 1 hệ thống nhật ký (journal)trước khi thực hiện thay đổi thực sự

• Nhật ký thường là 1 hệ thống log vòng (circularlog) được lưu trên 1 vùng dành riêng trên đĩa

• Khi có crash hoặc lỗi nguồn điện, hệ thống có thể

tự khôi phục và ít bị lỗi

Trang 13

Journaling File System

• Phân loại

– Journal vật lý:

• Tạo ra bản sao của mỗi block sẽ được ghi xuống FS.

• Nếu có lỗi, dễ dàng trở lại trạng thái trước đó

• Đòi hỏi dung lượng lưu trữ gấp đôi.

– Journal luận lý:

• Chỉ lưu những thay đổi trên metadata của file vào log

• Chấp nhận kém đi về khả năng chịu lỗi để tăng hiệu năng

Trang 14

Journaling File System

• Quy trình thêm nội dung vào tập tin gồm 3 thaotác ghi như sau:

– Ghi lên inode của tập tin, để ghi nhận rằng kích thước của file tăng lên

– Ghi lên free space map, để định vị 1 dung lượng đĩa cho phần nội dung mới

– Ghi lên phần không gian mới định vị, để cho nội dung mới vào tập tin

• Với FS metadata-only, bước 3 sẽ không được log

• Nếu bước 3 chưa hoàn tất, sau đó bước 1+2

Trang 16

SWAP SPACE

Trang 17

Introduction

• Swap space is used when RAM is full

• If the system needs more memory resources andthe RAM is full, inactive pages in memory aremoved to the swap space

• Swap space is located on hard drives, which have

a slower access time than physical memory

Trang 18

• Swap space can be

– Dedicated swap partition (recommended)

– Swap file

– Combination of swap partitions and swap files

• M = Amount of RAM in GB, and S = Amount ofswap in GB

Trang 19

Adding Swap Space

• You may upgrade the amount of RAM in yoursystem from 128 MB to 256 MB, but there is only

256 MB of swap space

• It might be advantageous to increase the amount

of swap space to 512 MB

• You have three options

– Create a new swap partition

– Create a new swap file

– Extend swap on an existing LVM2 logical volume

Trang 20

Adding Swap Space

• Extending Swap on an LVM2 Logical Volume

Trang 21

Adding Swap Space

• Creating an LVM2 Logical Volume for Swap

Trang 22

Adding Swap Space

• Creating a Swap File

1 Determine the size of the new swap file in

megabytes and multiply by 1024 to determine the number of blocks.

• For example, the block size of a 64 MB swap file is 65536.

2 Type the following command with count being equal

to the desired block size

Trang 23

Adding Swap Space

• Creating a Swap File

3 Setup the swap file with the command

4 To enable the swap file immediately but not

automatically at boot time:

5 To enable it at boot time, edit /etc/fstab to include

the following entry

6 Verify swap file is enabled: cat /proc/swaps or free

Trang 24

Removing Swap Space

• Reducing Swap on an LVM2 Logical Volume

Trang 25

Removing Swap Space

• Removing an LVM2 Logical Volume for Swap

Trang 26

Removing Swap Space

• Removing a Swap File

Trang 27

FILE SYSTEM ADMINISTRATION

Trang 28

The /dev Directory

• Device file: file representing a system device

– Typically found in /dev directory

– Specifies how to transfer data to and from the device

• Character devices: transfer data to and fromsystem character by character

• Block devices: transfer chunks or blocks of datausing physical memory as a buffer

– Fast data transfer

– Floppy disks, CD-ROMs, DVDs, USB flash drives, hard

Trang 29

Filesystem Types

• ext2 - previous Linux standard file system

• vfat – Windows 9x FAT32

• ntfs – Windows NT/2000/XP NTFS

• iso9660 – CD-ROM

• smbfs – shared filesystem using SMB

• nfs – Network File System

• proc – virtual filesystem /proc

• ext3, ext4, reiserfs, xfs, jfs – journal filesystems

Trang 30

Standard Hard Disk Partitioning

Trang 31

Standard Hard Disk Partitioning

• A sample Linux partitioning strategy

Trang 32

Standard Hard Disk Partitioning

• A sample dual-boot Linux partitioning strategy

Trang 33

Working with Hard Disk Partitions

• fdisk command: Create partitions afterinstallation

– Specify hard disk partition as an argument

– Variety of options for fdisk prompt to achieve different tasks

• cfdisk command: Interactive graphical utility forcreating, manipulating and deleting partitions

• Reboot computer after using the fdisk and cfdisk

commands to ensure proper reloading intomemory

Trang 34

Working with Hard Disk Partitions

• Example

– Make partitions

• # fdisk /dev/hda

– Create new filesystem

mkfs -t fstype filesys blocks

– blocks: kích thước của fs (1024-byte blocks)

• # mkfs -t ext3 /dev/hda6

• # mkfs -t vfat /dev/hda7

Trang 35

• Any existing directory can be a mount point

• In order to prevent making files inaccessible,create empty directories used specifically formounting devices

Trang 36

• The directory structure prior to mounting

Trang 37

Mounting

• The directory structure after mounting a floppydevice

Trang 38

• mount command

– When used with no options or arguments, lists currently mounted filesystems

– -a: mount tất cả fs mô tả trong /etc/fstab

– -o: tuỳ chọn mount

• remount: mount lại một fs đã mount

Trang 39

– # mount -t iso9660 /dev/hdd /mnt/cdrom

– -a: unmount filesystems described in /etc/mtab

Trang 40

File /etc/fstab

• Auto mount filesystems when booting

• Example

Trang 41

• auto: the device will be mounted automatically

• noauto: the device will not be mounted automatically

• "automatically" : either at boot or when the command mount -a is issued.

Trang 42

File /etc/fstab

device mounting_directory filesystem_type options 0 0

• options

– ro: Mount the device in read only mode.

– rw: Mount the device in read/write mode.

– sync/async

• sync writes data to the device on the fly (as soon as a

command is issued)

• async writes data later.

– suid: This allos suid and sgid bits to be effective on the mounted file system.

Trang 43

File /etc/fstab

device mounting_directory filesystem_type options 0 0

• The final section is actually the dump/fsck section

– Basically if you set these bits to 0 (off) the mounted devices will not be checked by either dump or fsck

– You will rarely, if ever, need anything but zeros here.

Ngày đăng: 30/01/2020, 05:14

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w