1 / 25

Cosc 4750

Cosc 4750. File Systems. Which would you expect to find in a “filesystem”? Processes serial ports inter-process communication channels Shared memory segments applications and files. All of them are in a UNIX filesystem UNIX unifies all objects of the O/S into the filesystem

libba
Download Presentation

Cosc 4750

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cosc 4750 File Systems

  2. Which would you expect to find in a “filesystem”? • Processes • serial ports • inter-process communication channels • Shared memory segments • applications and files

  3. All of them are in a UNIX filesystem • UNIX unifies all objects of the O/S into the filesystem • consistent programming interface, easy access from the shell

  4. File system components • There are 4 main components • A namespace • Way of naming things and arranging them in a hierarchy • an API • A set of system calls for navigation and manipulating nodes • Security Model • a scheme for protecting, hiding, and sharing things

  5. File system components (2) • An implementation • Code that ties the logical model to an actual disk • Pathnames • the directory structure can be as deep as needed, but no name can be longer and 255 characters • But a full pathname can not be accessed properly when it is longer than 4,095 characters

  6. File system components (3) • Special characters such as the space, *, ?, and others must either be backslashed or the path must be in double quotes • cat My\ File.txt • cat “My File.txt” • NEVER put a dash as the first character. The – is taken as parameter to the program, not as the filename.

  7. Mount/unmouting file systems • You can use the mount command and umount command • mount the zip drive into the filesystem • mount /dev/hdc4 /media/zip • Assuming /dev/hdc4 is the device for the zip drive. • mount /media/zip • This assumes zip drive is listed in the /etc/fstab file. • umount /media/zip • unmounts the zip drive from the filesystem

  8. Problems unmounting • Unix will not allow you umount a file system that is in use. • umount /home • umount: /home: device is busy • A file is open or a user’s current working directory is on the file system • To find them, you can use the fuser –mv <file system> command • fuser –mv /home • Show all processes user the /home file system • You can also use lsof command on RedHat/Fedora and SuSE installations.

  9. File Structure • Most UNIX system follow this convention: • /home (/people) where the user dir. are at • /usr system info and applications • /usr/local local software (that you install) • /usr/bin /bin standard utilities (like ls, grep) • /usr/etc where SA utilities are located. • /etc system configurations • /dev system devices • /var system logs and other system info • /proc kernel and system info, also images of running processes • /boot (linux only), where the kernel and other files are located for booting.

  10. File Types • regular files -rwx------ • directories drwx------ • character device files crwx------ • block device files brwx------ • UNIX domain sockets srwx------ • Named pipes (FIFOs) prwx------ • Symbolic links lrwx------

  11. Setting permissions • Use chmod • Can be used in 2 ways • chmod u+x <file> • chmod 700 <file> • Chmod ugo + rx <file> or chmod a + rx <file> u = user, g=group o= world • and chmod ugo – w <file> or chmod a – w <file> • numeric 0 ---, 1 --x , 2 -w-, 3 -wx, 4 r--, 5 r-x, 6 rw-, 7 rwx • so, chmod 744 <file> is -rwxr--r--

  12. Extra bits • There is 1 more field for setuid, setgid, and the “sticky bit” • chmod 4755 <file>, enable setuid • The file runs as the owner, instead of who is actually running it. • chmod 2755 <file>, enable setgid • The file runs as the group • chmod 1755 <file>, enable stick bit • It used leave the program in memory, but is historical and linux silently ignores it.

  13. Directory Permissions • For directories, the permission are • r: view the contents of the directory, ls • x: you can enter the directory, cd • w: you can create a file in the directory • without it, in linux you can not modify a file either. • SUN, sgi, etc… implement permissions slightly differently. • you don't need write permissions on the directory to modify a file in the directory.

  14. Links • Soft links • the “file” is a redirect to where the “real” file is • All file and directory permissions apply. • Can be used across physical hard drives • deleting the link doesn’t delete the file. The “real” file can be deleted and the link will not work anymore. • Hard links • the “file” is a connected directly to the other file. Only the file permissions of the linked file apply. • Can not be used across physical hard drives. • If you deleted the “real” file, the contents still exist for the linked file or vise versa

  15. Links (2) • directories can only be soft linked • Using hard links, file locking does not work • ln –s <target file> <linked filename> • creates a soft link • ln <target file> <linked filename> • creates a hard link

  16. Note on ext3 size limits • The size of a file and filesystem are dependent on block size • Block is the smallest allocation that can be made in a file.

  17. Extra attributes • For the ext2 and ext3 fs • Use lsattr to view, chattr to set/unset • Anyone can set • A, Never update access time • d, no backup (dump will ignore the file) • S, write with no buffering (sort of works) • Causes more problems then is worth. • Only root can set • a, only allow write in append mode • i, make file immutable and undeletable • listed, but don’t work • c, keep contents compressed (transparently) • s, physically erase (write over) when deleted • u, save contents on deletion to permit recovery

  18. Default permissions • use the umask command • the system default is to create all files with -rw-r--r-- • directories default to drwxr-xr-x • umask lists the default permissions in reverse • so chmod 755 (rwxr-xr-x), umask 022 • For better security you may want to use a • umask 137 (-rw-r----) • umask 177 (-rw-------) • command: set umask 137

  19. Ext4 file system • Ext4 (fourth extended filesystem) • Journaling file system like ext3 • Adopted into the kernel 2.6.28 released Dec 2008 • Support volumes up 1 exabyte and files up to 16 Terabytes • Sub directory limit now 64,000 (32,000 limit in ext3)

  20. Ext4 file system (2) • Performance improvements • Delayed allocation, improves performance and reduces fragmentation • Block allocation decisions based on actual file size. • Disadvantage • Delay allocation may lead to data lost in a crash, because old file is already removed, but new data is not written yet. • Ext3 either the old file or new file exists.

  21. Quotas • Linux only (others implement differently) • NOTE: quotas and NFS don't work well together. Locally it will tell the user they have exceeded quota, via NFS it may silently discard the file. • add command usrguota and grpquota to /etc/fstab file for each partition using quotas # quotacheck –c /home • creates /home/aquota.user # quotacheck –vug /home • builds a table of disk usage • See chapter 11 for startup scripts.

  22. Quotas (2) • Creating quota rules • command edquota –u <user> • NOTE: by default invokes the vi editor • uses blocks instead of kilobytes • a block equals 1K • 512000 blocks is 500MB • 7168000 blocks is 700 MB. • See chapter 11 for more information

  23. Quotas (3) • Checking quotas # repquota –a • display a listing of all users, with used space, quota limit, over quota, etc. • using du #du – h –c –s /home/ugrad/* • lists each undergrad's directory with amount of space used (-h show K, M, or GB -c show total at end)

  24. Logical Volumes • Technique to deploy large logical volumes, instead of several smaller physical volumes • Can span multiple physical hard drives. • Example: • (3) 9.1 GB drives, use 100 for /boot on one drive • 9.1GB x 3 – 100MB gives about 27GB of space to use, say 20 GB /home and 7Gb for / partation. • Later another 9.1 GB added to extend the volume and then (with ext3) used to expand the /home partition (giving about 29GB). • Note: LVM supports up to 2TB with LVM 2 and 8 Exabytes with 64bit.

  25. Q A &

More Related