Hệ điều hành - Quản trị hệ thống tập tin

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 from system character by character • Block devices: transfer chunks or blocks of data using physical memory as a buffer – Fast data transfer – Floppy disks, CD-ROMs, DVDs, USB flash drives, hard disk drives

pdf43 trang | Chia sẻ: huyhoang44 | Lượt xem: 578 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Hệ điều hành - Quản trị hệ thống tập tin, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Đặng Thanh Bình Quản trị hệ thống tập tin 2Contents • 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 3Introduction • File system đề cập đến các tập tin và thư mục được lưu trên máy tính. • Một file system có thể có một grong các định dạng khác nhau, gọi là file system type – 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, trong khi một FS khác có thể giúp tăng tốc truy cập dữ liệu. CẤU TRÚC FILE SYSTEM 5Phâ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. 6File System Hierarchy Standard (FHS) • Linux sử dụng Filesystem Hierarchy Standard (FHS) • Chuẩn này quy định về tên, vị trí và phân quyenf cho nhiều loại tập tin và thư mục • Tương thích với chuẩn đồng nghĩa với nhiều điều, nhưng dưới đây là 2 điều quan trọng nhất – 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 7Tổ chức của FHS • /boot: chứa các static file để boot hệ thống, chẳn hạn Linux kernel • /dev: chứa các device node thể hiện các thiết bị gắn vào máy tính hoặc thiết bị ảo được cung cấp bởi kernel – udev demon quản lý việc khởi tạo và remove các thiết bị quản lý trong /dev/ 8FHS 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/ 9FHS Organization • /media: chứa các thư mục con được dung làm mount point cho các thiết bị lưu trữ removeable như flash USB, DVD, CD-ROM, đĩa Zip • /mnt: các FS được mount tạm thời, chẳng hạn cá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 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 EXT4 FILE SYSTEM 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 (circular log) đượ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 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 14 Journaling File System • Quy trình thêm nội dung vào tập tin gồm 3 thao tá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 được lặp lại trong quá trình recovery, file sẽ được thêm dữ liệu rác 15 Tạo ext4 File System • Quy trình: – Định dạng phân vùng bằng lệnh mkfs. – Đặt nhãn cho phân vùng bằng lệnh e2label. SWAP SPACE 17 Introduction • Swap space is used when RAM is full • If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space • Swap space is located on hard drives, which have a slower access time than physical memory. 18 Introduction • 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 of swap in GB 19 Adding Swap Space • You may upgrade the amount of RAM in your system 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 20 Adding Swap Space • Extending Swap on an LVM2 Logical Volume 21 Adding Swap Space • Creating an LVM2 Logical Volume for Swap 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 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 24 Removing Swap Space • Reducing Swap on an LVM2 Logical Volume 25 Removing Swap Space • Removing an LVM2 Logical Volume for Swap 26 Removing Swap Space • Removing a Swap File FILE SYSTEM ADMINISTRATION 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 from system character by character • Block devices: transfer chunks or blocks of data using physical memory as a buffer – Fast data transfer – Floppy disks, CD-ROMs, DVDs, USB flash drives, hard disk drives 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 30 Standard Hard Disk Partitioning 31 Standard Hard Disk Partitioning • A sample Linux partitioning strategy 32 Standard Hard Disk Partitioning • A sample dual-boot Linux partitioning strategy 33 Working with Hard Disk Partitions • fdisk command: Create partitions after installation – Specify hard disk partition as an argument – Variety of options for fdisk prompt to achieve different tasks • cfdisk command: Interactive graphical utility for creating, manipulating and deleting partitions • Reboot computer after using the fdisk and cfdisk commands to ensure proper reloading into memory 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 35 Mounting • Mounting: making a device accessible to users via the logical directory tree • Mount point: directory to which a device is attached • The mounted device temporarily covers up the contents of the mount point • Any existing directory can be a mount point • In order to prevent making files inaccessible, create empty directories used specifically for mounting devices 36 Mounting • The directory structure prior to mounting 37 Mounting • The directory structure after mounting a floppy device 38 Mounting • 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 • ro: read-only 39 Mounting • umount command umount directory | device – # umount /mnt/backup – # umount /dev/hda1 – # mount -t iso9660 /dev/hdd /mnt/cdrom – -a: unmount filesystems described in /etc/mtab 40 File /etc/fstab • Auto mount filesystems when booting • Example 41 File /etc/fstab device mounting_directory filesystem_type options 0 0 • options – auto/noauto • 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. – user/nouser • user allows all standard (and root) users to mount the device • nouser only allows the root user to mount the device 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. – defaults: Use all default options (rw, suid, dev, exec, auto, nouser, and async) 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.

Các file đính kèm theo tài liệu này:

  • pdf03_file_system_2999.pdf