Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Introduce mounting, fstab, autofs #122

Merged
merged 1 commit into from

3 participants

@nibalizer

Introduces the mount command and some of its options. Takes apart
an /etc/fstab file. Briefly introduces autofs and an
/etc/auto.master file. Autofs has a bit too many prerequisites to
be meaningfully covered here, but it is at least introduced with
an example, and discusses the chain of events during an automount.

@miketheman miketheman was assigned
filesystems_101.rst
@@ -144,7 +144,76 @@ man mkfs
Mounting a filesystem
=====================
-.. todo:: explain different kinds of mounts, autofs, /etc/fstab
+
+Mounting a filesystem is the act of placing the root of one filesystem on
+a directory, or mount point, of a currently mounted filesystem. The mount
+command allows the user to do this manually. Typically, only the superuser
+can perform mounts.
+
+.. code-block:: console
+
+ -bash-4.1# mount -t ext4 -o noatime /dev/sdb1 /mnt
@igalic
igalic added a note

This might be nitpicking, but we go at great length elsewhere to describe how to properly setup a comfortable working environment, so perhaps we should lead in our code-pastes with examples of those ;)

What does that mean in this context?

@igalic
igalic added a note

instead of -bash-4.1#, you'd have a nice root@nibox #, or nibalizer@nibox %

(being "used" Solaris' horrible default Bash configuration, seeing it from many, many, many colleagues, who simply don't take the 30 seconds it'd take to transfer their dotfiles and have a sensible working environment, this is somewhat of a personal irk to me ;)

Oh! I feel the same way. I just copied the bash prompt from elsewhere in this file thinking it was standard. I'll fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filesystems_101.rst
@@ -144,7 +144,76 @@ man mkfs
Mounting a filesystem
=====================
-.. todo:: explain different kinds of mounts, autofs, /etc/fstab
+
+Mounting a filesystem is the act of placing the root of one filesystem on
+a directory, or mount point, of a currently mounted filesystem. The mount
+command allows the user to do this manually. Typically, only the superuser
+can perform mounts.
+
+.. code-block:: console
+
+ -bash-4.1# mount -t ext4 -o noatime /dev/sdb1 /mnt
+
+It is common to specify which filesystem type is present on ``/dev/sdb1`` and
+which mounting options you would like to use, but if that information is not
+specified then the linux mount command is pretty good at picking sane defaults.
@igalic
igalic added a note

Linux should be capitalised, and mount should probably be quoted with ``
This we should do with all commands.

Fixed in latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@igalic igalic commented on the diff
filesystems_101.rst
((25 lines not shown))
+the filesystem on disk. Files (generally) do not care what kind of filesystem
+they are on, it is only in configuring initial filesystem creation, automatic
+mounting, and performance tuning that you have to concern yourself with the
+filesystem type. Example filesystem types are ``ext2, ext3, ext4, FAT, NTFS
+HFS, JFS, XFS, ZFS, BtrFS``. At a operations 101 level on linux hosts, use
+ext4. For maximum compatibility with Windows and Macintosh, use FAT.
+
+.. code-block:: console
+
+ -bash-4.1$ cat /etc/fstab
+
+ # <file system> <mount point> <type> <options> <dump> <pass>
+ /dev/sda5 / ext4 errors=remount-ro 0 1
+ /dev/sda6 none swap sw 0 0
+ /dev/sda1 /boot/efi auto auto 0 0
+
@igalic
igalic added a note

Perhaps explain what we are actually seeing in this listing, instead of just explaining what we could be seing in this space.

I believe I have addressed this. Do you agree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@nibalizer

Changed the prompts. Added new, specific, discussion on /etc/fstab.

@miketheman miketheman commented on the diff
filesystems_101.rst
@@ -144,7 +144,85 @@ man mkfs
Mounting a filesystem
=====================
-.. todo:: explain different kinds of mounts, autofs, /etc/fstab
+
+Mounting a filesystem is the act of placing the root of one filesystem on
+a directory, or mount point, of a currently mounted filesystem. The mount
@miketheman Collaborator

Is this 100% accurate? Root fs gets mounted at /, what mounted fs is that attaching to?

This is accurate for all filesystems that aren't root. As I understand it, in most modern Linuxes, the root fs gets mounted on something like /real_root in the initrd and then pivot_root happens which chroots into that. I think that discussion is outside the scope of what we're trying to do here. Maybe a parenthetical statement that "root is special and that will be covered in the boot process documentation"?

@miketheman Collaborator

I'd be amiable to that. Maybe even a link to that topic?

Added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filesystems_101.rst
((12 lines not shown))
+
+ -root@opsschool # mount -t ext4 -o noatime /dev/sdb1 /mnt
+
+It is common to specify which filesystem type is present on ``/dev/sdb1`` and
+which mounting options you would like to use, but if that information is not
+specified then the Linux ``mount`` command is pretty good at picking sane
+defaults. Most administrators would have typed the following instead of the
+above:
+
+.. code-block:: console
+
+ -root@opsschool # mount /dev/sdb1 /mnt
+
+The type of the filesystem refers to the format of the data structure that is
+the filesystem on disk. Files (generally) do not care what kind of filesystem
+they are on, it is only in configuring initial filesystem creation, automatic
@miketheman Collaborator

maybe remove "configuring" from this phrase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filesystems_101.rst
((16 lines not shown))
+which mounting options you would like to use, but if that information is not
+specified then the Linux ``mount`` command is pretty good at picking sane
+defaults. Most administrators would have typed the following instead of the
+above:
+
+.. code-block:: console
+
+ -root@opsschool # mount /dev/sdb1 /mnt
+
+The type of the filesystem refers to the format of the data structure that is
+the filesystem on disk. Files (generally) do not care what kind of filesystem
+they are on, it is only in configuring initial filesystem creation, automatic
+mounting, and performance tuning that you have to concern yourself with the
+filesystem type. Example filesystem types are ``ext2, ext3, ext4, FAT, NTFS
+HFS, JFS, XFS, ZFS, BtrFS``. At a operations 101 level on Linux hosts, use
+ext4. For maximum compatibility with Windows and Macintosh, use FAT.
@miketheman Collaborator

I disagree with the wording of "At ops 101 level..." - rather something better along the lines of "As of this writing, a good default to use is ext4..."

@miketheman Collaborator

Also - maybe add a link to wikipedia's comparison of filesystems page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filesystems_101.rst
((25 lines not shown))
+The type of the filesystem refers to the format of the data structure that is
+the filesystem on disk. Files (generally) do not care what kind of filesystem
+they are on, it is only in configuring initial filesystem creation, automatic
+mounting, and performance tuning that you have to concern yourself with the
+filesystem type. Example filesystem types are ``ext2, ext3, ext4, FAT, NTFS
+HFS, JFS, XFS, ZFS, BtrFS``. At a operations 101 level on Linux hosts, use
+ext4. For maximum compatibility with Windows and Macintosh, use FAT.
+
+The fstab, or file system table, is the file that configures automatic mounting
+at boot. It tabulates block devices, mount points, type and options for each
+mount. The dump and pass fields control booting behavior. Dumping is the act
+of creating a backup of the filesystem (often to tape), and is not in common use.
+Pass is much more important. When the pass value is nonzero, the filesystem is
+analyzed early in the boot process by fsck, the file system checker, for errors.
+The number, fs_passno, indicated priority. The root filesystem should always be
+1, other filesystems should be 2 or more. In ``/etc/fstab``, there are a number
@miketheman Collaborator

2 or more - but your example shows 0. Explain that 0 disables fsck at boot time, commonly used to speed boot process...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filesystems_101.rst
((44 lines not shown))
+
+.. code-block:: console
+
+ -root@opsschool # cat /etc/fstab
+
+ # <file system> <mount point> <type> <options> <dump> <pass>
+ /dev/sda5 / ext4 errors=remount-ro 0 1
+ /dev/sda6 none swap sw 0 0
+ /dev/sda1 /boot/efi auto auto 0 0
+
+This ``/etc/fstab`` file mounts ``/dev/sda5`` on ``/`` using the ext4 filesystem
+. If it encounters a filesystem corruption it will use the ``fsck`` utility
+early in the boot process to try to clear the problem. If the physical disk
+reports errors in writing while the filesystem is mounted, the os will remount
+``/`` readonly. The ``/dev/sda6`` partition will be used as swap. The
+``/dev/sda`` partition will be mounted on ``/boot/efi`` using autodetection, the
@miketheman Collaborator

should be /dev/sda1 per the fstab above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@miketheman miketheman commented on the diff
filesystems_101.rst
((54 lines not shown))
+This ``/etc/fstab`` file mounts ``/dev/sda5`` on ``/`` using the ext4 filesystem
+. If it encounters a filesystem corruption it will use the ``fsck`` utility
+early in the boot process to try to clear the problem. If the physical disk
+reports errors in writing while the filesystem is mounted, the os will remount
+``/`` readonly. The ``/dev/sda6`` partition will be used as swap. The
+``/dev/sda`` partition will be mounted on ``/boot/efi`` using autodetection, the
+partition will not be scanned for filesystem errors.
+
+.. code-block:: console
+
+ -root@opsschool # cat /etc/auto.master
+
+ /home -rw,hard,intr,nosuid,nobrowse bigserver:/exports/home/&
+ /stash ldap:ou=auto_stash,ou=Autofs,dc=example,dc=com -rw,hard,intr,nobrowse
+
+The ``auto.master`` file controls the ``autofs`` service. It is another way to
@miketheman Collaborator

note: there's also auto_master (BSD/OSX will have those)

Added a note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
filesystems_101.rst
((65 lines not shown))
+
+ /home -rw,hard,intr,nosuid,nobrowse bigserver:/exports/home/&
+ /stash ldap:ou=auto_stash,ou=Autofs,dc=example,dc=com -rw,hard,intr,nobrowse
+
+The ``auto.master`` file controls the ``autofs`` service. It is another way to
+tabulate filesystems for mounting. It is different from the ``/etc/fstab``
+because the filesystems listed in ``auto.master`` are not mounted at boot. The
+automounter allows the system to mount filesystems on demand, then clean up those
+filesystems when they are no longer being used. In this case, the system mounts
+home directories for each user from a remote NFS server. The filesystem remains
+unmounted until the user logs in, and is unmounted a short time after the user
+logs out. The automounter is triggered by an attempt to cd into ``/home/<key``,
+it will then attempt to find an nfs share on ``/exports/home/<key>`` and mount it
+on ``/home/key``, then allow the ``cd`` command to return successfully. The
+``/home`` example above is using the ``&`` expansion syntax, the second line is
+using the ldap syntax to look up a key under ``/stash/<key>`` in ldap. Ldap will
@miketheman Collaborator

LDAP is an acronym, and should be all-caps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@nibalizer

Updates per review.

@nibalizer nibalizer Introduce mounting, fstab, autofs
Introduces the mount command and some of its options. Takes apart
an /etc/fstab file. Briefly introduces autofs and an
/etc/auto.master file. Autofs has a bit too many prerequisites to
be meaningfully covered here, but it is at least introduced with
an example, and discusses the chain of events during an automount.
51e19d6
@miketheman miketheman merged commit cae34df into from
@miketheman
Collaborator

Thanks for working through this!

@nibalizer nibalizer deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 18, 2013
  1. @nibalizer

    Introduce mounting, fstab, autofs

    nibalizer authored
    Introduces the mount command and some of its options. Takes apart
    an /etc/fstab file. Briefly introduces autofs and an
    /etc/auto.master file. Autofs has a bit too many prerequisites to
    be meaningfully covered here, but it is at least introduced with
    an example, and discusses the chain of events during an automount.
This page is out of date. Refresh to see the latest.
Showing with 86 additions and 1 deletion.
  1. +86 −1 filesystems_101.rst
View
87 filesystems_101.rst
@@ -144,7 +144,92 @@ man mkfs
Mounting a filesystem
=====================
-.. todo:: explain different kinds of mounts, autofs, /etc/fstab
+
+Mounting a filesystem is the act of placing the root of one filesystem on
+a directory, or mount point, of a currently mounted filesystem. The mount
@miketheman Collaborator

Is this 100% accurate? Root fs gets mounted at /, what mounted fs is that attaching to?

This is accurate for all filesystems that aren't root. As I understand it, in most modern Linuxes, the root fs gets mounted on something like /real_root in the initrd and then pivot_root happens which chroots into that. I think that discussion is outside the scope of what we're trying to do here. Maybe a parenthetical statement that "root is special and that will be covered in the boot process documentation"?

@miketheman Collaborator

I'd be amiable to that. Maybe even a link to that topic?

Added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+command allows the user to do this manually. Typically, only the superuser
+can perform mounts. The root filesystem, mounted on ``/``, is unique and
+it is mounted at boot. See :doc:`boot_process_101`.
+
+.. code-block:: console
+
+ -root@opsschool # mount -t ext4 -o noatime /dev/sdb1 /mnt
+
+It is common to specify which filesystem type is present on ``/dev/sdb1`` and
+which mounting options you would like to use, but if that information is not
+specified then the Linux ``mount`` command is pretty good at picking sane
+defaults. Most administrators would have typed the following instead of the
+above:
+
+.. code-block:: console
+
+ -root@opsschool # mount /dev/sdb1 /mnt
+
+The root filesystem, mounted on ``/``, is unique and its mounting
+
+The type of the filesystem refers to the format of the data structure that is
+the filesystem on disk. Files (generally) do not care what kind of filesystem
+they are on, it is only in initial filesystem creation, automatic
+mounting, and performance tuning that you have to concern yourself with the
+filesystem type. Example filesystem types are ``ext2, ext3, ext4, FAT, NTFS
+HFS, JFS, XFS, ZFS, BtrFS``. On Linux hosts, ext4 is a good default. For
+maximum compatibility with Windows and Macintosh, use FAT.
+
+http://en.wikipedia.org/wiki/Comparison_of_file_systems
+
+The fstab, or file system table, is the file that configures automatic mounting
+at boot. It tabulates block devices, mount points, type and options for each
+mount. The dump and pass fields control booting behavior. Dumping is the act
+of creating a backup of the filesystem (often to tape), and is not in common use.
+Pass is much more important. When the pass value is nonzero, the filesystem is
+analyzed early in the boot process by fsck, the file system checker, for errors.
+The number, fs_passno, indicated priority. The root filesystem should always be
+1, other filesystems should be 2 or more. A zero value causes skips to be
+checked, an option often used to accelerate the boot process. In ``/etc/fstab``,
+there are a number of ways to specify the block device containing the filesystem
+. ``UUID``, or universally unique identifier, is one common way in modern Linux
+based systems to specify a filesystem.
+
+.. code-block:: console
+
+ -root@opsschool # cat /etc/fstab
+
+ # <file system> <mount point> <type> <options> <dump> <pass>
+ /dev/sda5 / ext4 errors=remount-ro 0 1
+ /dev/sda6 none swap sw 0 0
+ /dev/sda1 /boot/efi auto auto 0 0
+
@igalic
igalic added a note

Perhaps explain what we are actually seeing in this listing, instead of just explaining what we could be seing in this space.

I believe I have addressed this. Do you agree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+This ``/etc/fstab`` file mounts ``/dev/sda5`` on ``/`` using the ext4 filesystem
+. If it encounters a filesystem corruption it will use the ``fsck`` utility
+early in the boot process to try to clear the problem. If the physical disk
+reports errors in writing while the filesystem is mounted, the os will remount
+``/`` readonly. The ``/dev/sda6`` partition will be used as swap. The
+``/dev/sda1`` partition will be mounted on ``/boot/efi`` using autodetection, the
+partition will not be scanned for filesystem errors.
+
+.. code-block:: console
+
+ -root@opsschool # cat /etc/auto.master
+
+ /home -rw,hard,intr,nosuid,nobrowse bigserver:/exports/home/&
+ /stash ldap:ou=auto_stash,ou=Autofs,dc=example,dc=com -rw,hard,intr,nobrowse
+
+The ``auto.master`` file controls the ``autofs`` service. It is another way to
@miketheman Collaborator

note: there's also auto_master (BSD/OSX will have those)

Added a note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+tabulate filesystems for mounting. It is different from the ``/etc/fstab``
+because the filesystems listed in ``auto.master`` are not mounted at boot. The
+automounter allows the system to mount filesystems on demand, then clean up those
+filesystems when they are no longer being used. In this case, the system mounts
+home directories for each user from a remote NFS server. The filesystem remains
+unmounted until the user logs in, and is unmounted a short time after the user
+logs out. The automounter is triggered by an attempt to cd into ``/home/<key``,
+it will then attempt to find an nfs share on ``/exports/home/<key>`` and mount it
+on ``/home/key``, then allow the ``cd`` command to return successfully. The
+``/home`` example above is using the ``&`` expansion syntax, the second line is
+using the LDAP syntax to look up a key under ``/stash/<key>`` in LDAP. LDAP will
+be covered later in the curriculum. The ``auto.master`` file is known as
+``auto_master`` on FreeBSD, Solaris, and Mac OS X.
+
+
Filesystem options
==================
Something went wrong with that request. Please try again.