BSD Newsletter.com
   Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·Advocacy
·Drivers
·Events
·Flavours
·FAQs
·Guides
·Programming
·Security
·Software
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/Determine_which_filesystems_are_currently_mounted_and_which_will_be_mounted_at_system_boot.html.

Determine which filesystems are currently mounted and which will be mounted at system boot

Concept

Be able to determine: * which filesystems are currently mounted, and * which will be mounted at boot time.

Introduction

The UNIX paradigm "everything is a file" means that almost any device can be mounted to almost any location on the filesystem hierarchy.

At boot time, init(8) mounts devices as shown in the file /etc/fstab, which may be edited by the superuser to add or remove additional boot-time mounts or change their parameters. To see all devices currently mounted on the filesystem, call mount(8) with no arguments.

Examples

A typical 'fstab'. Note that the "noauto" option for the entry /dev/acd0 means that init will not attempt to mount the cdrom during bootup, but the CD can be mounted with mount /cdrom by a user with the appropriate privileges.

$ cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ad0s1b             none            swap    sw              0       0
/dev/ad0s1a             /               ufs     rw              1       1
/dev/ad0s1e             /usr            ufs     rw              2       2
/dev/ad0s1d             /var            ufs     rw              2       2
/dev/acd0               /cdrom          cd9660 ro,noauto        0       0

Here is the output of mount(8) for the same system:

$mount
/dev/ad0s1a on / (ufs, local, soft-updates)
devfs on /dev (devfs, local)
/dev/ad0s1e on /usr (ufs, NFS exported, local, soft-updates)
/dev/ad0s1d on /var (ufs, local, soft-updates)
devfs on /var/named/dev (devfs, local)

Mount here gives a couple of details not visible in the system fstab --- one is the existence of devfs(5), the "device file system", which occurs twice here because this system runs named(8) in a "sandbox" (chrooted) environment. The other is the fact that /usr is exported as a Network File System. In this case, you might wish to call showmount(8) to see if anyone is connected to your exported file system before you umount(8) it or call shutdown(8). (Network mounts are introduced in section Configure data to be available through NFS.)

The 'df' tool can also show mounted filesystems:

$ df -m 
Filesystem 1M-blocks Used Avail Capacity Mounted on /dev/wd0a 1008 23 934 2% / /dev/wd0f 4032 10 3820 0% /var /dev/wd0e 15121 1541 12823 10% /usr /dev/wd0g 10081 500 9076 5% /home kernfs 0 0 0 100% /kern

The -t switch for df can be used to specify or exclude some filesystems. To exclude, prefix the filesystem name with "no", such as "noffs" or "noprocfs". For example, on DragonFly- and NetBSD:

$ df -t nfs
Filesystem  1K-blocks   Used    Avail Capacity  Mounted on
office:/pub  20644846 858522 18134738     5%    /pub

$ df -t noffs
Filesystem  512-blocks      Used     Avail Capacity  Mounted on
kernfs               2         2         0   100%    /kern

More details on df are covered in Determine disk capacity and which files are consuming the most disk space.

Practice Exercises

  1. Compare the output of mount on your system(s) with the output shown above.

  2. If the machine isn't "mission-critical", try removing the "noauto" option above and rebooting the system with the optical drive empty. What do you predict will happen? What actually happens? (Note that you might want to have a backup copy of /etc/fstab stored somewhere in the root of your filesystem if you try this.)

  3. What is a quick "one-liner" to get everything "back to normal" if mount shows only the following (when you expect 3 or 4 filesystems)?

# mount
/dev/ad0s1a on / (ufs, local, read-only)

More information

mount(1), df(1), fstab(5)



Front | Information | Lists | Newsfeeds