Mounting Other Filesystems
Pages: 1, 2
It is possible to format a floppy with DOS from FreeBSD. To format a floppy, do NOT mount it first. Remember, you mount filesystems, and you don't have a filesystem until you format. As root, put a floppy in your floppy drive, then type:
fdformat /dev/rfd0Format 1440 floppy '/dev/rfd0'? (y/n):
When it is finished processing,
disklabel -w -r /dev/rfd0 fd1440 newfs_msdos -f 1440 fd0
You can now mount that floppy like this:
mount -t msdos /dev/fd0 /floppy cd /floppy ls
ls command should confirm that there is nothing on the floppy. Let's copy something onto the floppy:
cp /etc/fstab /floppy ls
You should now see a file called "fstab" on your floppy. Type:
You should be able to hear your floppy drive churn as you view the contents of fstab. If you try to unmount the floppy,
umount: unmount of /floppy failed: Device busy
You can't unmount a filesystem if it is your present working directory. Let's try again:
cd / umount /floppy
It is now safe to eject the floppy from the floppy drive.
Now let's try a CD-ROM. Put a data CD-ROM, not a music CD-ROM, into your CD-ROM bay and type:
mount /cdrom ls
You should be able to see the contents of the CD. Why did the shortened
mount command work? Remember that FreeBSD already created a mountpoint
/cdrom for you? Well, it also added an entry to a file that is read
by the mount command if you don't specify a device name. Try this:
# Device Mountpoint FStype Options Dump Pass# /dev/ad0s2b none swap sw 0 0 /dev/ad0s2a / ufs rw 1 1 /dev/ad0s2f /usr ufs rw 2 2 /dev/ad0s2e /var ufs rw 2 2 /dev/acd0c /cdrom cd9660 ro,noauto 0 0 proc /proc procfs rw 0 0
Notice that there is an entry for
/cdrom with its options set at
"noauto." This tells FreeBSD not to mount your CD-ROM automatically when you
reboot; however, it now shortens the mount command for when you do want to
mount a CDROM. Let's unmount the CDROM and add an entry to the
/etc/fstab file to
shorten the mount command for floppies:
cd / umount /cdrom pico /etc/fstab
At the end of the file, add this line:
/dev/fd0 /floppy msdos rw,noauto 0 0
Make sure you tab over to keep your columns neat; also, make sure it all fits on one line. Doublecheck for typos before saving this file.
Now, insert a floppy into your floppy drive and try:
mount /floppy ls cd / umount /floppy
I can also mount my C:\ drive while in FreeBSD; since its device name is /dev/ad0s1, I issue this command:
mount -t msdos /dev/ad0s1 /fat
I can then enter
cd /fat and freely edit and delete files on the C:\ drive using my favorite Unix commands. I can also copy files back and forth between C:\ and FreeBSD.
If I want to get real fancy, I'll also mount my FAT32 partition:
mount -t msdos /dev/ad0s4 /fat32
and I can copy a file from C:\ to what Windows 98 calls the D:\ partition:
cp /fat/test.txt /fat32/test.txt
Saves a lot of rebooting if I just want to move some files around. If I
want to save myself some typing when I wish to access these filesystems,
I'll add the following lines to the end of
# Device Mountpoint FStype Options Dump Pass# /dev/ad0s1 /fat msdos rw 0 0 /dev/ad0s4 /fat32 msdos rw 0 0
Because these file systems are located on my permanent storage device, I can have FreeBSD mount them at every boot; therefore, I haven't set the Options to "noauto".
If I've rebooted since adding these lines to
/etc/fstab, these partitions will be mounted for me. I can simply use the commands
cd /fat or
cd /fat32 to access the data on these partitions.
Today's article focused on accessing the file systems of devices physically attached to your FreeBSD computer. Next week, we'll discuss how to access data located on Microsoft computers within your network.
Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.
Read more FreeBSD Basics columns.
Discuss this article in the Operating Systems Forum.
Return to the BSD DevCenter.