Table of Contents
FreeBSD Mastery: Specialty Filesystems
Copyright 2015 by Michael W Lucas (https://www.michaelwlucas.com).
All rights reserved.
Author: Michael W Lucas
BSD Daemon copyright 1988 by Marshall Kirk McKusick. All rights reserved.
Technical Review: Edward Tomasz Napieraa
Copyediting: Lindy Lou Losh
Cover art: Beastie sort de l'Opra , illustration copyright 2015 Eddie Sharam, after Le Sortie de l'opra en l'an 2000, 1882, by Albert Robida
ISBN-13: 978-0692610442
ISBN-10: 0692610448
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, smoke signals, or by any information storage or retrieval system, without the prior written permission of the copyright holder and the publisher. For information on book distribution, translations, or other rights, please contact Tilted Windmill Press (accounts@tiltedwindmillpress.com)
Product and company names mentioned herein might be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this book is provided on an As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor Tilted Windmill Press shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
Tilted Windmill Press
https://www.tiltedwindmillpress.com
For Liz
Acknowledgements
I planned to spend six weeks writing this book. Six months later, when I finally typed the last words, I looked back at the plan and laughed maniacally. FreeBSD has an incredible variety of special-purpose filesystems, and getting a handle on them took far longer than expected (mainly because Im not nearly as smart or efficient as I think I am). Some of these filesystems will solve problems you never knew you had. Some of them will make you glad you dont have the problems these filesystems solve.
As overdue as this book is, it would have been completely impossible without all the people who offered advice, suggestions, and feedback. These people include John W. De Boskey, Lars Engels, Peter Jeremy, Alex Kozlov, Marie Helene Kvello-Aune, Ruslan Makhmatkhanov, Ravi Pokala, and Dag-Erling Smrgrav, all of whom were kind enough to review this manuscript before it reached you.
I specifically want to thank John Hixson for patiently helping me sort out the madness depravity complexities of the NFSv4 Access Control Lists.
Finally, Edward Tomasz Napieraa, author of many of FreeBSDs newer filesystem features, carefully reviewed this book. Trasz has the most charming way of telling me how wrong I am, and he had frequent opportunity to simultaneously exercise that talent and practice patience.
This book was written on hardware from iXsystems, using test systems from iXsystemsmeaning that I didnt have any hardware problems. Which was good, because I had quite a sufficient number of problems understanding all these filesystems
Chapter 0: Introduction
Storage: a hole with no bottom, into which you pour data.
The last 50 years of computing have seen countless types of data storage hardware. Modern flash drives improve on spinning disks, which in turn improved on punch cards, which improved on tape, which was a lot better than carved marble tablets. BSD operating systems, and FreeBSD in particular, have been around for most of that time, and at one time had ways to utilize many different data storage methods. Support for that hardware remains long after the hardware was in common use. Even paper tape support lingers in the bcd(6) command.
Once you pick a physical medium, though, you have to decide how youre going to use it. Different operating systems have evolved entirely different filesystems to stuff data onto each sort of media. Your FreeBSD installation might need to interoperate with all of these, and more.
Then there are filesystems developed for special purposes, such as devfs and the Memory File System. The network opens up many storage possibilities, such as iSCSI and the Network File System and various replication technologies.
To truly master FreeBSD, you need to understand many of these. Thats where this book comes in. You wont find information about GEOM and the Unix File System here, or about ZFS, or about how to implement filesystems in code. Those topics have their own books. This book is for all the other filesystems, storage methods, and data storage tricks.
Prerequisites
As this book is for filesystems meant for special situations, it has perhaps the widest range of prerequisites of any book Ive ever written.
While the individual topics in this book arent difficult, they presume you understand FreeBSDs GEOM storage subsystem. You dont need to understand how to write storage classes, but I assume youre familiar with commands like glabel(8) and geom show . Partitioning is another complex topic you need to bring to the table. Some filesystems assume a disk uses Master Boot Record (MBR) partitions, while others work only on Globally Unique ID (GUID) Partition Tables (GPT). Similarly, youll need to understand the basics of the Unix File System (UFS), including critical system files like /etc/fstab . Well also cover some ZFS issues, where ZFS interoperates with other filesystem attributes.
This book pulls in knowledge from the whole spectrum of systems administration practice. If you want to use FreeBSDs iSCSI support, youd best know something about TCP/IP and storage hardware. Using the Filesystem in Userspace (FUSE) support with the SSH module means you should understand starting and stopping services as well as SSH.
Filesystems require support in the kernel. That support might be included in the GENERIC kernel or a kernel module. You need to understand how to load, unload, and view kernel modules.
If youre sketchy on any of these prerequisites, you can find extensive documentation online or in other books.
This book addresses FreeBSD 10.2 and newer. Many topics also work on older releases, but FreeBSD 10 includes several new filesystem features, such as FUSE and iSCSI. Those features have grown their own features as FreeBSD 10 has progressed.
Finally, any complex work with filesystems requires shell scripts. This book includes several to get you started, but youll need to modify them to fit your environment. For your convenience, the included scripts are also available at the authors GitHub site (https://github.com/mwlucas).
FreeBSD Mount Commands
We normally use the mount command to attach a filesystem to the directory tree. Using multiple filesystems changes how you use mount(8).
The mount command assumes that any local disk partitions use UFS. If you try to mount a different filesystem youll get an error.
# mount /dev/da4s1 /mnt
mount: /dev/da4s1: Invalid argument
The device /dev/da4s1 exists, but it contains neither a UFS nor a UFS2 filesystem. You need to tell mount(8) what kind of filesystem this partition contains. Use either the t command-line argument or a filesystem-specific mount command.
Every filesystem has a name, listed either in mount(8) or in the filesystem manual page. (Every filesystem has a manual page, in section 5). Give the filesystem name as an argument with t .