Mount(8) and FFS


The mount(8) command attaches disk partitions to mount points on the system. Boot your OpenBSD system into single-user mode and follow along.

When the system boots it mounts the root partition read-only, which gives the operating system enough information to do basic setup and get core systems running before mounting the rest of the file systems. You'll only have the programs in /bin and /sbin available. If you're comfortable editing files with ed(1), you may be just fine. If not, you'll want to mount some of your other file systems.

Mounting Standard File Systems

To mount a single file system that is listed in /etc/fstab, such as /usr or /var, give the file system mount point as an argument to mount(8).

 # mount /usr # 

This mounts /usr exactly as /etc/fstab describes it, with the same options.

Mounting with Options

To use a different option that is not specified in /etc/fstab for that file system, use the options flag "-o." We discussed the available FFS options earlier, in the "FFS Mount Options" section. For example, to mount /var as read-only, enter this:

 # mount -o rdonly /var # 

A read-only mount is very useful for a damaged file system. In the past, I've had file systems that were so badly damaged that fsck(8) choked on them. These were Usenet news servers with hundreds of thousands of articles, and I generally did something to cause such problems. If you just want to pull some information off the disk without risking further damage to data, you can mount the partition as read-only and copy to your heart's content. (This isn't true in the case of physical disk damage, mind you; if one of the platters is coming apart, your data is doomed.)

Forcing Read-Write Mounts

If a partition is marked dirty, fsck(8) it before mounting it read-write. I hate to say that you should ever skip the fsck(8) step before trying to read-write mount a partition, but someone would inevitably point out some circumstance involving a blue moon, cows in tutus dancing down Broadway, and a Libertarian presidential victory, under which you could safely or intelligently write a damaged partition read-write. So, for completeness, you can use the "-f" flag to force a dirty file system to mount read-write. This may crash your system, damage your data further, or any combination of the two.

 # mount -f /tmp # 

Mounting All Standard File Systems

To mount all the file systems as listed in /etc/fstab, use the "-A" option.

 # mount -A # 

This will not mount file systems with the "noauto" option set.

Mounting Partitions at Other Mount Points

You can mount partitions at arbitrary locations if you have the block device name and the mount point. You might use this when you're installing a new disk, so you can copy the contents of the old partition onto their new location, or you can use this to mount temporary file systems. Here, we mount a partition on a SCSI disk under /mnt.

 # mount /dev/sd0a /mnt # 

Unmounting FFS File Systems

When you need to disconnect a mounted file system, you can unmount it with umount(8). The only argument you need is the mount point. Here, I'm unmounting that same SCSI disk — although it could be anything that is mounted at /mnt.

 # umount /mnt # 

If you cannot unmount a drive, you're probably accessing it in some way. If you are reading or writing a file on a partition, you cannot unmount it. You cannot even have a command prompt sitting idle in a directory on that partition if you want to unmount it. If you think that you have nothing in a file system, but you still get complaints that the file system is busy, use fstat(1) or install /usr/ports/ sysutils/lsof to identify the problem.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net