{"id":430,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:17","modified_gmt":"2020-08-22T20:26:17","slug":"this-is-the-page-title-toplevel-263","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=430","title":{"rendered":"Mounting a File System"},"content":{"rendered":"\n<title>Mounting a File System<\/title>\n<p>\nWhen the superuser attempts to mount a file system, the Linux kernel must\nfirst validate the arguments passed in the system call.\nAlthough <command>mount<\/command> does some basic checking, it does not know which file systems\nthis kernel has been built to support or that the proposed mount point actually\nexists.\nConsider the following <command>mount<\/command> command:\n<commandexample>\n$ mount -t iso9660 -o ro \/dev\/cdrom \/mnt\/cdrom\n<\/commandexample>\n<p>\nThis <command>mount<\/command> command will pass the kernel three pieces of information; the name of\nthe file system, the physical block device that contains the file system and, thirdly,\nwhere in the existing file system topology the new file system is to be mounted.\n<p>\nThe first thing that the Virtual File System must do is to find the file system.\n<p>\nTo do this it searches through the list of known file systems by looking at each\n<tt>file_system_type<\/tt> data structure in the list pointed at by <tt>file_systems<\/tt>.\n<p>\nIf it finds  a matching name it now knows that this file system type is supported\nby this kernel and it has the address of the file system specific routine for\nreading this file system&#8217;s superblock.\nIf it cannot find a matching file system name then all is not lost if the kernel\nis built to demand load kernel modules (see the <site id=\"298\">section on modules<\/site>).\nIn this case the kernel will request that the kernel daemon loads the appropriate\nfile system module before continuing as before.\n<p>\nNext if the physical device passed by <command>mount<\/command> is not already mounted,\nit must find the VFS inode of the directory that is to be the new file system&#8217;s\nmount point.\nThis VFS inode may be in the inode cache or it might have to be read from the\nblock device supporting the file system of the mount point.\nOnce the inode has been found it is checked to see that it is a directory\nand that there is not already some other file system mounted there.\nThe same directory cannot be used as a mount point for more than one file system.\n<p>\nAt this point the VFS mount code must allocate a VFS superblock and\npass it the mount information to the superblock read routine for this\nfile system.\nAll of the system&#8217;s VFS superblocks are kept in the <tt>super_blocks<\/tt> vector\nof <tt>super_block<\/tt> data structures and one must be allocated for this mount.\nThe superblock read routine must fill out the VFS superblock fields based on\ninformation that it reads from the physical device.\nFor the EXT2 file system this mapping or translation of information is quite\neasy, it simply reads the EXT2 superblock and fills out the VFS superblock from there.\nFor other file systems, such as the MS DOS file system, it is not quite such\nan easy task.\nWhatever the file system, filling out the VFS superblock means that the file system\nmust read whatever describes it from the block device that supports it.\nIf the  block device cannot be read from or if it does not contain this type of\nfile system then the <command>mount<\/command> command will fail.\n<p>\n<img decoding=\"async\" src=\"mounted.gif\">\n<p>\nFigure 9.6: A Mounted File System\n<p>Each mounted file system is described by a <tt>vfsmount<\/tt>  data structure;\nsee the figure above.\nThese are queued on a list pointed at by <tt>vfsmntlist<\/tt>.\n<p>\nAnother pointer, <tt>vfsmnttail<\/tt> points at the last entry in the list and\nthe <tt>mru_vfsmnt<\/tt> pointer points at the most recently used file system.\nEach <tt>vfsmount<\/tt> structure contains the device number of the block device\nholding the file system, the directory where this file system is mounted and a\npointer to the VFS superblock allocated when this file system was mounted.\nIn turn the VFS superblock points at the <tt>file_system_type<\/tt> data structure\nfor this sort of file system and to the root inode for this file system.\nThis inode is kept resident in the VFS inode cache all of the time that\nthis file system is loaded.\n<p>\n","protected":false},"excerpt":{"rendered":"<p>Mounting a File System When the superuser attempts to mount a file system, the Linux kernel must first validate the arguments passed in the system call. Although mount does some basic checking, it does not know which file systems this &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=430\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-430","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=430"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/430\/revisions"}],"predecessor-version":[{"id":633,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/430\/revisions\/633"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}