230 likes | 353 Views
CSIT-300 Systems Administration. File Types and File Systems. Regular Files. A simply definition of a regular file would be that it is a one dimensional assortment of bytes that are stored on a disk or other mass storage devices. Stream of bytes. No structure imposed by OS.
E N D
CSIT-300 Systems Administration File Types and File Systems
Regular Files • A simply definition of a regular file would be that it is a one dimensional assortment of bytes that are stored on a disk or other mass storage devices. • Stream of bytes. • No structure imposed by OS. • Programs need to know the structure of file. • EOF is not typed in but size is used as offset.
Types of Regular Files • Text • Binary • Exe etc. • Linux maintain a database for its files. • A regular file is referenced by its Inode number.
Directory Files • A simple definition of a directory is that it is a file that provides a mapping mechanism between the names of files and the files (datablocks) themselves. • Also called a file. • Maintain a good structure. • Holds inode numbers and file names. • Deletion of a file zeros its entry in list. Inode is shadow inode, finally freed.
Device Files • A device file refers to a device driver and these are important to the kernel. • The files in /dev are used to ensure that we can access hardware such as the printer, cdrom, network etc. • Linux can either see or not see a non-standard piece of hardware.
Device Files • Read and write directly to the device. • User issues a system call. • Kernel performs a successful open. • If busy read/write cant operate. • If not busy direct read/write to device.
Types of Device Files • Character device files: Writes to and from a device a character at a time. “c” is indicated in the first field. Request goes directly to the device • Block device files: a block is buffered in kernel. “b” is indicated in the first field. A file system is an example. • Block devices have character device associated with them. Example is formatting or backing up a diskette.
Interprocess Communication Devices • Linux set up some device files to allow interprocess communication. • Important to have an understanding of these as System Administrator. • These are Pipes, Semaphores, and shared memory devices. • These are not purely device files but handled in very much the same manner.
Pipes • Named pipe • In a named pipe situation the processes are being run by the same process group and by the same user. • Un-named pipe. • Used when processes run within different process groups. • Output from one process become input for another process.
Semaphore • A data structure used by processes to control and synchronize operation on one resource. • Request for a record by several processes from a database. Semaphore comes in action.
Shared Memory • This type of file is indicated by an "m" in the first field. • A piece of user-memory is allocated as a work-space, where it is possible for a process to read the data at the same time as another writes it.
Major and Minor Device Numbers • Each device has a reference number. • Kernel uses it when needs to access it. • Numbers are categorized as Major and Minor. • Major numbers refer to device drivers. • Minor numbers are refer to device itself.
Inodes • As a file is created a unique number is ascribed to that file and this is called an inode number. • Holds specific information about file.
Information held by Inode • Permission mode. • Number of links in place for the file. • File owners UID number • Group GID number. • File size in bytes. • Address of data blocks. • Time last modified. • Time last accessed. • Time any part of the Inode was changed.
Inode status • Residing on disk is known as disk inode. • File opened, kernel put it in generic inode table so known as generic inode. • Inodes are stored in generic table • Table has a link to hash queue and this stored in a table referenced by kernel each time it opens a file to make sure file is not opened already.
File System • A filesystem is a logical division within a physical partition. • There can only be one of the physical partitions active at any one time • This will be the partition that you boot up with by default when the machine is switched on.
File System (Linux) • We can divide on the basis of following criteria • Size of hard drive • Security issues • Swap • User requirements
Types of File System • ext2, ext3, Reiserfs and XFS and many more. • ext2 is the only one supported by Debian • ext3 filesystem is the next generation of the Extended Filesystem, and allows for larger filesystems and files, as well as improving performance. • Reiserfs and XFS filesystems allow for improved performance when using large filesystems
Layout of File System • Boot Block • Super Block • Inode Table • Data Blocks.
Super Block • Contains general information about file system like : • File System size. • Condition of the file system • A list of some of the free inodes and blocks available
Inode Table • contains the number of inodes allocated to that filesystem. • elastic in Linux and will expand if you require more inodes • create a new file the kernel will allocate an inode from the free list held in super block.
Data Blocks • Contains: • File data • Fixed in size. • kernel can only access the data blocks via the information held in the inode of that file.
Mount and Unmount File System • All files in one big tree. • File hierarchy is rooted at /. • mount is used to attached a file system to this big tree. • /dev directory • mount /cdrom