1 / 47

Linux File System

Linux File System. 1. Contents. What is File System? Important Directories in Linux Mounting File System Partitions Creating File System Some useful commands and tools. 2. What is File System?.

crwys
Download Presentation

Linux File System

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. Linux File System 1

  2. Contents • What is File System? • Important Directories in Linux • Mounting File System • Partitions • Creating File System • Some useful commands and tools 2

  3. What is File System? • It is responsible for storing information on disk and retrieving and updating this information. • Example : • FAT16, FAT32, NTFS • ext2, ext3 • … • In Linux everything is file. 3

  4. Type of File System • Network File System • NFS • SMB • Disk File System • ext2 • ext3 • FAT32 • NTFS 4

  5. Network File System • Network File System are physically somewhere else, but appear as if they are mounted on one computer. • NFS • It was developed by Sun. • SMB • It was developed by Microsoft. 5

  6. Disk File System • Disk File System are what you will find on a physical device, such as hard drive in a computer. 6

  7. ext2 File System • It has been the standard File System for Linux. • The original Extended File System was named ext. • The ext2 File System can accommodate: • Files as large as 2GB • Directories as large as 2TB • Max. file name length of 255 characters. 7

  8. ext2 Structure • A file in the ext2 File System begins with the inode. • inode • Each file has an inode structure that is identified by an i-number. • The inode contains the information required to access the file. • It doesn’t contain file name. • Inodes store information on files, such as • user and group ownership, • access mode (read, write, execute permissions) • and type of file. 10

  9. ext3 File System • It is as same as ext2. • It is a journaling File System for Linux. • In a journaling system, metadata is written to a journal on the disk before it is actually used to modify the file. 13

  10. Contents • What is File System? • Important Directories in Linux • Mounting File System • Partitions • Creating File System • Some useful commands and tools 14

  11. File System Structure / /bin /etc /dev … /usr /home /root ls ping /A /B data.txt pic.gif 15

  12. The Root Directory • /mnt • /opt • /proc • /root • /sbin • /usr • /srv • /tmp • /var • /bin • /boot • /dev • /etc • /home • /initrd • /lib • /lost+found • /media 16

  13. /bin • Hold the most commonly used essential user programs • login • Shells (bash, ksh, csh) • File manipulation utilities (cp, mv, rm, ln, tar) • Editors (ed, vi) • File system utilities (dd, df, mount, umount, sync) • System utilities (uname, hostname, arch) • GNU utilities like gzip and gunzip 17

  14. /bin detail • cat • chgrp • chmod • chown • cp • date • dd • df • dmesg • echo • false • Utility to concatenate files to standard output • Utility to change file group ownership • Utility to change file access permissions • Utility to change file owner and group • Utility to copy files and directories • Utility to print or set the system data and time • Utility to convert and copy a file • Utility to report filesystem disk space usage • Utility to print or control the kernel message buffer • Utility to display a line of text • Utility to do nothing, unsuccessfully 18

  15. /bin detail (cont) • hostname • kill • ln • login • ls • mkdir • mknod • more • mount • mv • ps • Utility to show or set the system's host name • Utility to send signals to processes • Utility to make links between files • Utility to begin a session on the system • Utility to list directory contents • Utility to make directories • Utility to make block or character special files • Utility to page through text • Utility to mount a filesystem • Utility to move/rename files • Utility to report process status 19

  16. 1. /bin detail (cont) • pwd • rm • rmdir • sed • sh • stty • su • sync • true • umount • uname • Utility to print name of current working directory • Utility to remove files or directories • Utility to remove empty directories • The `sed' stream editor • The Bourne command shell • Utility to change and print terminal line settings • Utility to change user ID • Utility to flush filesystem buffers • Utility to do nothing, successfully • Utility to unmount file systems • Utility to print system information 20

  17. /sbin • Hold essential maintenance or system programs such as the following: • fsck • Fdisk • Mkfs • Shutdown • Lilo • Init • … • The main difference between the programs stored in /bin and /sbin is that the programs in /sbin are executable only by root. 21

  18. /sbin … detail • shutdown • Fastboot • Fasthalt • fdisk • fsck • fsck.* • getty • halt • ifconfig • Command to bring the system down. • Reboot the system without checking the disks (optional) • Stop the system without checking the disks (optional) • Partition table manipulator (optional) • File system check and repair utility (optional) • File system check and repair utility for a specific filesystem (optional) • The getty program (optional) • Command to stop the system (optional) • Configure a network interface (optional) 22

  19. /sbin … detail • init • mkfs • mkfs.* • mkswap • reboot • route • swapon • swapoff • update • Initial process (optional) • Command to build a filesystem (optional) • Command to build a specific filesystem (optional) • Command to set up a swap area (optional) • Command to reboot the system (optional) • IP routing table utility (optional) • Enable paging and swapping (optional) • Disable paging and swapping (optional) • Daemon to periodically flush filesystem buffers (optional) 23

  20. /etc • Store the systemwide configuration files required by many programs. • passwd • shadow • fstab • hosts • lilo.conf • … 24

  21. /etc … detail • /etc/X11/ : contains all the configuration files for the X Window System • /etc/X11/XF86Config, /etc/X11/XF86Config-4 : 'X' configuration file • /etc/ftpchroot : List of ftp users that need to be chrooted • /etc/ftpaccess : Determines who might get ftp-access to your machine. • /etc/gateways : Lists gateways for 'routed' • /etc/group, /etc/passwd. lists the configured user groups and who belongs to them. • /etc/hostname : Contains the hostname of your machine • /etc/host.conf : Determines the search order for look-ups 25

  22. /home and /root • The /home directory is where all the home directories for all the users on a system are stored. • The /root directory is where all the home directories for root user on a system are stored. 27

  23. /dev • The special files representing hardware are kept in it. • /dev/hda1 • /dev/ttyS0 • /dev/mouse • /dev/fd0 • … 28

  24. /dev … detail • /dev/ttyS0 • /dev/psaux • /dev/lp0 • /dev/dsp • /dev/usb • /dev/sda • /dev/scd • /dev/cdrom • /dev/fd0 • /dev/hda • Device connected to Com1 (Modem, mouse,..) • PS/2 mouse connection • First parallel port • Sound card (Digital Signal Processor) • USB device nodes. • First SCSI device • First SCSI CD-ROM device • CD-ROM drive • floppy drive • The partition on primary hdd 29

  25. /tmp and /var • The /tmp and /var directories are used to hold temporary files with constantly varying content. 30

  26. /usr • Most programs and files directly relating to users of the system are stored. • It is in some ways a mini version of the / directory. • /usr/bin • /usr/sbin • /usr/spool • … 31

  27. /proc • It is a virtual File System • A special File System provided by the kernel as a way of providing information about the system to user programs. • The main tasks of proc File System is to provide information about the kernel and processes. • runtime system information (e.g. system memory, devices mounted, hardware configuration, etc). 32

  28. Other directories • /mnt • removable media such as CD-ROM, floppy and … are mounted. • /mnt/floppy • /mnt/cdrom • /boot • Image to boot system • /lost+found 33

  29. /boot … detail • /boot/boot.0300 • /boot/boot.b • /boot/chain.b • /boot/config-kernel-version • /boot/map • /boot/vmlinuz • /boot/vmlinuz-kernel-version • … • Backup master boot record. • The basic boot sector • Used to boot non-Linux operating systems • Installed kernel configuration. A config line such as: CONFIG_FONT_8x8=y • The location of the kernel • Normally the kernel or symbolic link to the kernel 34

  30. /lost+found • Contains the files which were recovered after an unexpected event, such as a proper shutdown. • Try to move each file back to its original location 37

  31. /media • Contains subdirectories which are used as mount points for removeable media • such as floppy disks, cdroms and zip disks 38

  32. /mnt • This is a generic mount point under mounted • (mount is to make a filesystem available to the system) the filesystems or devices. • When a filesystem no longer needs to be mounted, it can be unmounted with umount • mount /dev/hda2 /home • umount /dev/hda2 39

  33. /opt • This directory is reserved for all the software and add-on packages that are not part of the default installation • /opt/'package'  C:\Windows\Progam Files\"Program Name" 40

  34. Contents • What is File System? • Important Directories in Linux • Mounting File System • Partitions • Creating File System • Some useful commands and tools 41

  35. Mounting File System • The Linux File System makes it appear as if all the File System are local and mounted somewhere on the root File System. • File System are mounted with the mount command. • mount –t type source mount_point • To unmount a File System, the umount command is used. • umount /dev/<device name> or mount_point 42

  36. Mounting Automatically with fstab • This file lists all the partitions that need to be mounted at boot time and the directory where they need to be mounted. • Along with that information, you can pass parameters to the mount command. • /etc/fstab • Which devices to be mounted • What kinds of File Systems they contain • At what point in the File System the mount takes place • … 43

  37. fstab Example 44

  38. fstab Structure • Each line has six fields: • 1’st field: indicates the block device or remote File System that will be mounted. • 2’nd field: identifies the mount point the local system where the File System will be mounted. • 3’rd field: File System type • 4’th field: list of mount options • 5’th field: it is used by dump (a backup program) to determine whether the File System should be dumped (1:yes, 0:no). • 6’th field: it is used by fsck (0:never run, 1:run on the drive at predetermined, 2:it is recommended for non root File System so that fsck isn’t run on them as frequently). 45

  39. Contents • What is File System? • Important Directories in Linux • Mounting File System • Partitions • Creating File System • Some useful command and tool 46

  40. Partition Table • MBR (Master Boot Record) • The first sector • 512 bytes (446 bytes:boot loader such as LILO or GRUB, 64bytes:partition table, 2 bytes:special code). • The partition table has enough room for four partitions. • One of the four can be used as an extended partition. 47

  41. Partitions • Primary-Master • /dev/hda • Primary-Slave • /dev/hdb • Secondary-Master • /dev/hdc • Secondary-Slave • /dev/hdd • Swap Partition • Used to implement virtual memory 48

  42. fdisk • The Linux fdisk counterpart in DOS edits the disk structure. • You must be the superuser (root) to run fdisk. • You can run command fdisk -l to display list of partitions • fdisk /dev/had • cfisk • It is the same as fdisk, but it gives a graphical interface at the console. 49

  43. fdisk Command 50

  44. Contents • What is File System? • Important Directories in Linux • Mounting File System • Partitions • Creating File System • Some useful commands and tools 51

  45. Creating File System • Once a disk has been partitioned for a specific File System, it is necessary to create a File System on it. • The first process in the DOS world is known as formatting. • In the UNIX world is known as creating a File System. 52

  46. Create File System Commands • mkfs or mke2fs • Make a new ext2 File System. • mk3fs • Make a new ext3 File System. • mkdosfs • Make DOS File System without owning any Microsoft software. 53

  47. Formatting Linux Filesystem • Step #1 Create the new filesystem with following command (first login in as a root user) • mkfs.ext3 /dev/sda5 • Step # 2: Create mount point directory for the file system • # mkdir /datadisk1 • Step # 3: Mount the new file system • # mount /dev/sda5 /datadisk1 • Step # 4: Finally make sure file system /dev/hda5 automatically mounted at /datadisk1 mount point after system reboots. • vi /etc/fstab • Add/append following entry to file: • /dev/sda5 /datadisk1 ext3 defaults 0 2 54

More Related