BSD DevCenter
oreilly.comSafari Books Online.Conferences.


FreeBSD Basics

Mounting Other Filesystems


Anyone who has ever worked in a networked environment running different operating systems using different filesystems knows the frustration of trying to get every computer to see the data on every other computer. Even on my multi-boot test computer, NT can't see the data on my FAT32 partition, Windows 98 can't see the data on my NTFS partition, DOS can't see data on either partition -- and these operating systems are all installed on the same hard drive.

Fortunately, I also have FreeBSD installed on this computer, and it has no problem accessing the data anywhere on that hard drive, thanks to the mount command.

The mount command is one of the most powerful commands available to root. It allows root to mount filesystems so users can access either data physically located on a device cabled to that computer or data physically located on other computers that understand the mount command.

The mount command itself is simple:

mount (-t filesystem) devicename mountpoint

Let's start with some common device names:







SCSI drives


IDE drive, FreeBSD 2.x and 3.x


IDE drive, FreeBSD 4.x


Each device is numbered starting with 0. Storage devices will also have the sub partition unit, or "slice" number appended to them. The slice number (represented above as s#) consists of the letter 's' and a number.

For example, my test computer has one IDE drive that has been partitioned as follows:

200 MB FAT partition containing DOS
1.8 GB partition containing FreeBSD 4.0
500 MB NTFS partition containing NT Server 4.0
1.5 GB FAT32 partition containing Windows 98

If I boot to DOS, it only recognizes a partition named C:.

If I boot to NT, it sees a FAT partition called C: and an NTFS partition called D:.

If I boot to Windows 98, it sees a FAT partition called C: and a FAT32 partition called D:.

Because they don't recognize each other's filesystems, both Windows 98 and NT think they reside on a partition called D, even though they reside on different partitions of my hard drive.

FreeBSD's logic makes a bit more sense, as it sees my drive like this:

/dev/ad0s1 as FAT
/dev/ad0s2 as FreeBSD
/dev/ad0s3 as NTFS
/dev/ad0s4 as FAT32

since I've "sliced" my first IDE drive into 4 sections.

If you are multi-booting your FreeBSD computer, you can check out the device names for your partitions with /stand/sysinstall. As root, type /stand/sysinstall and choose Configure, then Fdisk, and then use your spacebar to select the drive

The "Name" column will list the device name; the "Desc" column will list the type of filesystem. If you used DOS fdisk to partition your hard drive, it will only show two entries: one for the primary partition and the other for the extended partition. An Intel BIOS may support up to 4 primary partitions, but DOS-based Fdisk utilities will only let you create one primary partition, and FreeBSD's Fdisk utility does not show logical partitions. I prefer to use Partition Magic, as it lets me create four primary partitions.

The mount command also requires you to specify a mountpoint. A mountpoint is simply an empty directory you've created as a reference point to access mounted data. The mounted data is not actually placed in this directory; instead, think of the mountpoint as a virtual shell where you can use your Unix commands to manipulate the mounted data. It is important that you keep your mountpoint directories empty; use other directories for storing files.

Mountpoints are usually created as subdirectories of /; to see them, type:

cd /

Among the subdirectories listed, note that FreeBSD has already created 2 mountpoints for you: /cdrom and /mnt.

When you create your mountpoints, give them useful names. For example:

/floppy, /ntfs, /fat32, /fat.

Now for the filesystem: Notice that I put -t filesystem in brackets when I gave the syntax for the mount command. The filesystem switch is optional; FreeBSD assumes you want to mount the UFS (Unix File System) unless you specify otherwise. The most common filesystem types you'll probably specify are:

-t msdos

for FAT floppies, FAT16, and FAT32 partitions

-t cd9660

for data CDROMs

-t ntfs

for primary NTFS partitions

A few notes on floppies and Unix: If you are used to sticking a floppy into the floppy drive of a Windows computer and then ejecting it at will, it'll take some getting used to how Unix computers treat floppies.

Both hard drives and floppies contain filesystems that must be mounted for their data to be accessed. Only root can mount filesystems, so you must be root to mount a floppy. Also, you can't just eject a mounted floppy; you must tell Unix to unmount it first.

Keep in mind that hard drives are considered to be permanent storage devices, while floppies are temporary storage devices. You wouldn't dream of physically removing your hard drive and adding another one while your computer was booted into an operating system on that first hard drive. For the same reason, don't mount a floppy and then eject it without telling Unix to unmount it first.

Pages: 1, 2

Next Pagearrow

Sponsored by: