Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10645453
  • 博文数量: 2905
  • 博客积分: 20098
  • 博客等级: 上将
  • 技术积分: 36298
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-23 05:00
文章存档

2012年(1)

2011年(3)

2009年(2901)

分类: LINUX

2009-04-22 01:32:45

Ojectives
Upon completion of this unit, you should be able to:
  • Describe how filesystem information is organized
  • Describe the function of dentries and inodes
  • Describe how cp, mv and rm work at the inode level
  • Create symbolic links and hard links
  • Access removable media
  • Create archives using tar and gzip
Partitions and Filesystems
1) Disk drives are divided into partitions
2) Partitions are formatted with filesystems, allowing users to store data
  • Default filesystems: ext3, the Third Extended Linux Filesystem
  • Other common filesystems:
    • ext2 and msdos (typically used for floppies)
    • iso9660 (typically used for CDs)
    • GFS and GFS2 (typically used for SANs)
Inodes
1) An inode table contains a list of all files in an ext2 or ext3 filesystem
2) An inode (index node) is an entry in the table, containing information of a file (the metadata), including:
  • file type, permissions, UID, GID
  • the link count (count of path names pointing to this file)
  • the file’s size and various stamps
  • pointers to the file’s data blocks on disk
  • other data about the file
Directories
1) The computer’s reference for a file is the inode number
2) The human way to reference a file is by file name
3) A directory is a mapping between the human name for the file and the computer’s inode number
cp and inodes
The cp command:
  • Allocate a free inode number, placing a new entry in the inode table
  • Creates a dentry in the directory, associating a name with the inode number
  • Copies data into the new file
mv and inodes
1) If the destination of the mv command is on the same file system as the source, the mv command:
  • Creates a new directory entry with the new file name
  • Deletes the old directory entry with the old file name
2) Has no imact on the inode table (except for a time stamp) or the location of data on the disk: no data is moved!
3) If the destination is a different filesystem, mv acts as a copy and remove
rm and inodes
1) The rm command:
  • Decrements the link count, thus freeing the inode number to be reused
  • Places data blocks on the free list
  • Removes the directory entry
2) Date is not actually removed, but will be overwritten when the data blocks are used by another file
Hard Links
1) A hard link adds an additional pathname to reference a single file
  • One physical file on the filesystem
  • Each directory references the same inode number
  • Increments the link count
    • The rm command decrements the link count
    • File exists as long as at least one link remains
    • When the link account is zero, the file is removed
  • Cannot span drives or partitions
2) Syntax: ln filename [linkname]
Symbolic (or Soft) Links
1) A symbolic link points to another file
  • ls –l displays the link name and the referenced file
  • File type: l for symbolic link
  • The content of a symbolic link is the name of the file that is references
2) Syntax: ln –s filename linkname
The Seven Fundamental Filetypes
ls –l symbol File Type
- regular file
d directory
l symbolic link
b block special file
c character special file
p named pipe
s socket
   
Checking Free Space
1) df – Reports disk space usage
  • Reports total kilobytes, kilobytes used, kilobytes free per file system
  • -h and –H display sizes in easier to read unit
2) du – Reports disk space usage
  • Reports kilobytes used per directory
  • Includes subtotals for each subdirectory (-s option only reports single directory summary)
  • Also takes –h and –H options
3) Applications –> System Tools –> Disk Usage Analyzer or baobab – Reports disk space usage graphically
Removable Media
1) Mounting means making a foreign filesystem look like part of the main tree
2) Before accessing, media must be mounted
3) Before removing, media must be unmouted
4) By default, non-root users may only mount certain devices (cd, dvd, floppy, usb, etc)
5) Mountpoints are usually under /media
Mounting CDs and DVDs
1) Automatically mounted in Gnome/KDE
2) Otherwise, must be manually mouted
  • CD/DVD Reader – mount /media/cdrom
  • CD/DVD Writer – mount /media/cdrecorder
3) eject command unmounts and ejects the disk
Mounting USB Media
1) Detected by the kernel as SCSI devices
  • /dev/sdaX or /dev/sdbX or similar
2) Automatically mounted in Gnome/KDE
  • Icon created in computer window
  • Mounted under /media/Device ID – Device ID is built into device by vendor
Mounting Floppy Disks
1) Must be manually mounted and unmounted
  • mount /media/floppy
  • umount /media/floppy
2) DOS floppies can be accessed with mtools
  • Mounts and unmounts device transparently
  • uses DOS naming conventions
    • mdir a:
    • mcopy /home/file.txt a:
Archiving Files and Compressing Archives
1) Archiving places many files into on target file
  • Easier to backup, store, and transfer
  • tar – standard Linux archiving command
2) Archives are commonly compressed
  • Algorithm applied that compressed file
  • Umcompressing retores the original file
  • tar natively supports compression using gzip and gunzip, or bzip2 and bunzip2
Creating, Listing, and Extracting File Archives
1) Action arguments (one is required)
  • -c create an archive
  • -t list an archive
  • -x extracts files from an archive
2) Typically requried:
  • -f archviename name of file archive
3) Optional arguments:
  • -z use gzip compression
  • -j use bzip2 compression
  • -v be verbose
Creating File Archives: Other Tools
1) zip and unzip
  • Supports pkzip-compatible archives
2) file-roller
  • Graphical, multi-format archiving tool
End of Unit16
1) Questions and Answers
2) Summary
  • Linux filesystem structure
  • Using removable media
  • Using unformatted floppies
  • Archiving and compression
阅读(679) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~