340 likes | 367 Views
Learn about different types of Unix file systems, logical volume managers, disk striping, RAID, and more. Practical guidance on basic file system administration included.
E N D
itec 400Unix File Systems George Vaughan Franklin University
Topics • Types of File Systems • Basic File System Administration • Logical Volume Managers • Disk Striping • RAID and Disk Mirroring • Samba • Using MS-DOS floppies with Solaris/Linux
Types of File Systems • Historical Unix File Systems • Unix System V (s5fs) • Used to be predominant Unix Files System • Traded performance for space efficiency (small block size [1 or 2K] • critical structures not replicated • BSD Fast File System (FFS) • Better performance than s5fs • Larger block size [4k or 8k] • block sharing between files. • attempt to locate blocks of file near each other • organize partition in cylinder groups • improved reliability by replication of super block • Complicated disk geometry made fsck very slow.
Types of File Systems • Modern Unix File Systems • Journal-ed File Systems • maintains a log of changes using transaction entries • If system crashes, journal log entries are replayed to reconstruct data. • BSD Soft Updates • similar to journal approach • file system changes are maintained in memory as metadata. • maintains dependency information
Types of File Systems • Default File Systems on Unix/Linux1
Basic File System Administration • Basic File System Administration includes: • Creating Disk Partitions • Formatting Disk Partitions • Creating File Systems • Checking File Systems • Creating Mount Points • Mounting File Systems • Unmounting File Systems • The following slides illustrate basic file system administration using a floppy disk drive and Red Hat Linux
Creating Disk Partitions • fdisk - used for creating, deleting and administering disk partitions 0014: # fdisk /dev/hda 0015: Command (m for help): p 0016: 0017: Disk /dev/hda: 255 heads, 63 sectors, 2434 cylinders 0018: Units = cylinders of 16065 * 512 bytes 0019: 0020: Device Boot Start End Blocks Id System 0021: /dev/hda1 * 1 765 6144831 c Win95 FAT32 (LBA) 0022: /dev/hda2 766 2359 12803805 83 Linux 0023: /dev/hda3 2360 2434 602437+ 82 Linux swap
Formatting Disk Partitions • Line 1: format the floppy using fdformat 0001 # fdformat /dev/fd0 0002 Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB. 0003 Formatting ... done 0004 Verifying ... done
Creating File Systems • Line 7: Make file system using mkfs 0007 # mkfs -t ext2 -m 0 /dev/fd0 1440 0008 mke2fs 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09 0009 Filesystem label= 0010 OS type: Linux 0011 Block size=1024 (log=0) 0012 Fragment size=1024 (log=0) 0013 184 inodes, 1440 blocks 0014 0 blocks (0.00%) reserved for the super user
Creating File Systems 0015 First data block=1 0016 1 block group 0017 8192 blocks per group, 8192 fragments per group 0018 184 inodes per group 0019 0020 Writing inode tables: done 0021 Writing superblocks and filesystem accounting information: done 0022 0023 This filesystem will be automatically checked every 39 mounts or 0024 180 days, whichever comes first. Use tune2fs -c or -i to override.
Checking File Systems • Line 26: Use fsck to check newly created file system 0026 # fsck /dev/fd0 0027 Parallelizing fsck version 1.23 (15-Aug-2001) 0028 e2fsck 1.23, 15-Aug-2001 for EXT2 FS 0.5b, 95/08/09 0029 /dev/fd0: clean, 13/184 files, 44/1440 blocks
Mounting and Unmounting File Systems • Unix has a logical single file directory structure, starting with the root. • Logical directory tree may be composed of many directory trees on many file systems. • The tree can be expanded by adding additional file systems to mount points. • A mount point can be any directory on the existing logical directory tree.
Mounting and Unmounting File Systems • ‘mount’ command used to add the directory system to the existing logical directory tree. • ‘umount’ command used to remove a file system from existing logical tree. • Any files in a directory that serves as a mount point are obscured when a filesystem is mounted at that point. • Any files in a directory that serves as a mount point will re-appear when the filesystem at that mount point is unmounted.
Mounting and Unmounting File Systems • To mount a filesystem you need: • to create a mount point (if one does not exist) • use the mount command • mount device mount_point • device: a disk or disk partition (/dev/hda3, /dev/fd0) • mount_point: an existing directory in the logical tree
Creating Mount Points • Line 31-32: create the mount point 0031 # cd /mnt 0032 # mkdir mySpace
0034 # mount 0035 /dev/hda2 on / type ext3 (rw) 0036 none on /proc type proc (rw) 0037 usbdevfs on /proc/bus/usb type usbdevfs (rw) 0038 none on /dev/pts type devpts (rw,gid=5,mode=620) 0039 none on /dev/shm type tmpfs (rw) 0040 /dev/hdb2 on /home type ext2 (rw) 0041 /dev/hdb1 on /mnt/msdos/d type msdos (rw) 0042 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) Line 34: ‘mount’ with no arguments shows currently mounted filesystems Mounting File Systems
0044 # mount /dev/fd0 /mnt/mySpace 0045 0046 # mount 0047 /dev/hda2 on / type ext3 (rw) 0048 none on /proc type proc (rw) 0049 usbdevfs on /proc/bus/usb type usbdevfs (rw) 0050 none on /dev/pts type devpts (rw,gid=5,mode=620) 0051 none on /dev/shm type tmpfs (rw) 0052 /dev/hdb2 on /home type ext2 (rw) 0053 /dev/hdb1 on /mnt/msdos/d type msdos (rw) 0054 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) 0055 /dev/fd0 on /mnt/mySpace type ext2 (rw) Line 44: Mount the new fs Line 55: mount command shows new fs Mounting File Systems
Using File Systems • Line 61: copy a file into new fs • Line 65: Check out the space on new fs 0061 # cp /etc/inittab /mnt/mySpace/george 0062 # ls 0063 inittab 0064 0065 # df /mnt/mySpace 0066 Filesystem 1k-blocks Used Available Use% Mounted on 0067 /dev/fd0 1412 16 1396 2% /mnt/mySpace
Unmounting File Systems • Line 69: We attempt to unmount the file system /dev/fd0. • Line 70: the filesystem is busy so we can’t unmount. • Line 73: list of processes using /dev/fd0. 0069 # umount /dev/fd0 0070 umount: /mnt/mySpace: device is busy 0071 0072 # fuser -u -m /dev/fd0 0073 /dev/fd0: 13038c(gvaughan) 13192c(gvaughan) 13195c(gvaughan)
Unmounting File Systems • Line 75: use fuser to kill processes using filesystem. • Line 77: unmount filesystem (no complaints this time) 0075 # fuser -k -m /dev/fd0 0076 /dev/fd0: 13038c 13192c 13195c 0077 # umount /dev/fd0
Filesystem Config File • Filesystems can be configured to be mounted at boot. • The config file is: /etc/fstab • Must specify such things as: • device name • mount point • file system type • ‘mount -a’ can be used to mount all fs’s in /etc/fstab.
Disk Drive • A Disk Drive is composed of 1 or more (usually more) stacked platters. • Each platter has 2 surfaces. • Each Surface has a r/w head.
File Systems and Disks (Traditional View) • A partition is a logical subset of a drive • A drive may have 1 or more concentric partitions (cylinders) • A partition is logically 3 dimensional (cylinders: area of ring x platters x 2). • One filesystem per partition • partitions cannot be dynamically resized.
File Systems and Disks (Logical Volume Managers) • A Volume Group is composed of one or more disk drives (or UNIX partitions). • Each disk drive is broken up into LVM partitions of standard size (4MB). • A volume group can be split into logical volumes (which can also be span multiple drives).
File Systems and Disks (Logical Volume Managers) • There is a 1 to 1 mapping between a file system and a logical volume. • Therefore, a file system can span more than 1 disk drive. • Logical volumes can be dynamically resized. • With LVM, we mount logical volumes instead of disk partitions. • Supported by most Unix/Linux distributions including Solaris and Redhat.
Disk Striping • Used in configurations involving multiple physical disk drives into one logical drive • Can be used to improve performance. • Can be used to support very large files. • Files are spread across physical drives so different parts of the file can be read/written to concurrently. • Supported by Solaris, Linux and others…
Disk Mirroring and Raid • A configuration involving multiple physical drives to maintain multiple copies of files. • RAID - Redundant Array of Independent Disks. • Replication of data is at the O.S. or even at the controller level. Application does not worry. • Sometimes 3 sets are maintained to resolve discrepancies. • Supported by Solaris, Linux and others…
RAID • RAID – Redundant Array of Independent (Inexpensive) Disks. • A set of techniques for grouping disks together for performance and/or fault tolerance. • Filesystem is spread across grouped disks • There are many ways to group RAID disks; these groupings are called RAID Levels.
RAID Levels • There are many RAID Levels – some are shown below:
RAID RAID Tutorial • The link below provides a nice interactive tutorial on RAID: • http://www.acnc.com/raid.html
Network File System (NFS) • NFS allows filesystems to be shared across multiple computers. • Computers do not need to be of same manufacturer of version of Unix/Linux. • NFS protocol designed by SUN in mid 1980’s. • Supported by Solaris, Linux and others…
Samba • Samba - an application (server) that runs on Unix/Linux. • Samba allows Unix/Linux filesystems to look like MS drives. • MS machine thinks it is mapping an MS drive. • Great for allowing Unix/Linux machine to act as MS file server.
Using MS-DOS Floppies With Linux • fdformat /dev/fd0 • mkfs -t msdos /dev/fd0 • mount /dev/fd0 /mnt/floppy • do whatever with /mnt/floppy… • umount /mnt/floppy • eject floppy
References • Essential System Administration, Aeleen Frisch, 2002 • Linux Administration Handbook, Evi Nemeth, et. al., 2002 • http://www.csd.uch.gr/~hy345/mirror/class_notes/brown_98/lectures/file1.pdf • http://www.linuxgazette.com/issue55/florido.html • http://www.usenix.org/publications/library/proceedings/usenix2000/general/seltzer.html • http://wlug.westbo.se/faq/Linux-FAQ-4.html • http://www.acnc.com/raid.html • http://www.webopedia.com/TERM/R/RAID.html