Introduce mounting, fstab, autofs #122

Merged
merged 1 commit into from Mar 22, 2013

Projects

None yet

3 participants

@nibalizer
Contributor

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 Mar 15, 2013
@igalic igalic and 1 other commented on an outdated diff Mar 15, 2013
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 Mar 15, 2013 Contributor

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 ;)

@nibalizer
nibalizer Mar 15, 2013 Contributor

What does that mean in this context?

@igalic
igalic Mar 15, 2013 Contributor

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 ;)

@nibalizer
nibalizer Mar 15, 2013 Contributor

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.

@igalic igalic and 1 other commented on an outdated diff Mar 15, 2013
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 Mar 15, 2013 Contributor

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

@nibalizer
nibalizer Mar 15, 2013 Contributor

Fixed in latest.

@igalic igalic commented on the diff Mar 15, 2013
filesystems_101.rst
+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 Mar 15, 2013 Contributor

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

@nibalizer
nibalizer Mar 17, 2013 Contributor

I believe I have addressed this. Do you agree?

@nibalizer
Contributor

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

@miketheman miketheman commented on the diff Mar 16, 2013
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
miketheman Mar 16, 2013 Member

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

@nibalizer
nibalizer Mar 17, 2013 Contributor

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
miketheman Mar 18, 2013 Member

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

@nibalizer
nibalizer Mar 18, 2013 Contributor

Added.

@miketheman miketheman commented on an outdated diff Mar 16, 2013
filesystems_101.rst
+
+ -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
miketheman Mar 16, 2013 Member

maybe remove "configuring" from this phrase

@miketheman miketheman commented on an outdated diff Mar 16, 2013
filesystems_101.rst
+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
miketheman Mar 16, 2013 Member

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
miketheman Mar 16, 2013 Member

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

@miketheman miketheman commented on an outdated diff Mar 16, 2013
filesystems_101.rst
+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
miketheman Mar 16, 2013 Member

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

@miketheman miketheman commented on an outdated diff Mar 16, 2013
filesystems_101.rst
+
+.. 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
miketheman Mar 16, 2013 Member

should be /dev/sda1 per the fstab above.

@miketheman miketheman commented on the diff Mar 16, 2013
filesystems_101.rst
+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
miketheman Mar 16, 2013 Member

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

@nibalizer
nibalizer Mar 17, 2013 Contributor

Added a note.

@miketheman miketheman commented on an outdated diff Mar 16, 2013
filesystems_101.rst
+
+ /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
miketheman Mar 16, 2013 Member

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

@nibalizer
Contributor

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 opsschool:master Mar 22, 2013

1 check passed

default The Travis build passed
Details
@miketheman
Member

Thanks for working through this!

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