Foreign Filesystems

Any partition that uses a non-FFS filesystem is foreign to OpenBSD. Although OpenBSD can access many foreign filesystems, don’t expect it to be seamless.

Support for some filesystems is incomplete. For example, you can mount Microsoft NTFS partitions only as read-only. Other filesystems don’t support the full range of OpenBSD commands. Because FAT filesystems don’t have any concept of file ownership or permissions, commands like chmod and chown won’t change anything on the disk.

Each supported filesystem has its own mount program to handle the vagaries of that filesystem. To simplify your life, mount can usually recognize supported filesystems from the on-disk format and call the correct mount program as needed. To mount a foreign filesystem, you need the device node and a mount point. Depending on the filesystem, you may also need to know the type of filesystem you’ll be mounting.

Inodes vs. Vnodes

Before we talk about foreign filesystems, let’s touch on something that confused me for a long time: the difference between inodes and vnodes.

The FFS uses index nodes, or inodes, to map blocks of disk that contain data. This worked just dandy when hard drives were big, expensive things that no one moved between computers. Over the years, however, swapping disks between machines has become more popular.

Although Unix-like systems think in terms of accessing files via inodes, the FAT32 filesystem doesn’t use inodes, ext2fs’s inodes don’t map directly onto FFS inodes, and CDs use a completely different layout. To access all of these filesystems in a consistent way, BSD needed another layer of abstraction.

The virtual node, or vnode, is an abstraction layer the kernel uses to access all filesystems. Users never manipulate vnodes directly, but you’ll see references to them throughout OpenBSD’s documentation. Every tool that reads or writes to disks does so through vnodes, which map the requests to the filesystem. When you write to an FFS block or inode, the kernel addresses data to a vnode, which in turn maps to an inode. When you write to a FAT32 filesystem, the kernel addresses data to a vnode mapped to a point in the FAT32 filesystem. You use inodes only when dealing with FFS systems, but your data will pass through a vnode when accessing any filesystem.

Don’t let references to vnodes on non-FFS systems confuse you. They’re part of OpenBSD, not the filesystem.

Common Foreign Filesystems

Common foreign filesystems include MS-DOS, NTFS, ext2fs, and CD. We’ll look at how to access disks formatted for those operating systems with OpenBSD.

MS-DOS

OpenBSD supports the FAT, FAT16, and FAT32 filesystems. These formats are commonly found on flash media, old Microsoft operating systems, and floppy disks.

To mount a filesystem with a FAT filesystem partition, use mount_msdos(8).

# mount_msdos /dev/sd3i /mnt

Not sure which partition on the disk is the FAT filesystem? Run disklabel(8) on the drive and see. FAT filesystems are often located on the i partition. And even if you try inserting your USB drive and mounting its i partition, OpenBSD will probably figure out that it’s a FAT system.

If you work with FAT disks often, you might investigate /usr/ports/sysutils/mtools, a collection of software for working with FAT filesystems without mounting them. While mount_msdos is quite reliable, mtools offers a more elegant interface.

NTFS

To mount disks formatted for modern Microsoft operating systems, use mount_ntfs(8).

# mount_ntfs /dev/sd3k /mnt

As I write this, OpenBSD supports NTFS4 (from Windows NT) and NTFS5 (in Windows 2000 and XP). Windows Vista and newer systems are not yet supported, but they might be by the time you read this.

If you need to view file attributes specific to the NTFS filesystem, check the mount_ntfs man page for details.

ext2fs

To mount ext2fs and ext3fs filesystems, use mount_ext2fs(8). (The one program mounts both types of filesystem.)

# mount_ext2fs /dev/sd3l /mnt

Owing to their shared Unix heritage, the Linux ext2fs and ext3fs filesystems support many FFS-like features. Unlike with NTFS, you can safely read and write ext2fs and ext3fs disks in OpenBSD. You cannot, however, read ext4fs partitions using OpenBSD.

CD

Compact discs formatted for data use the ISO-9660 filesystem. To mount a CD, use mount_cd9660(8).

# mount_cd9660 /dev/cd0a /mnt

Mount CDs using either the a or c partition on the device. If you would like to save yourself a few keystrokes, mount(8) is very good at automatically detecting ISO-9660 filesystems. The device node for a CD is tied to the CD drive, not the disk itself, so the node shouldn’t change unless you add another drive.

If you’re interested in burning a CD, look at mkhybrid(8) and cdio(1).

Foreign Filesystem Ownership

Most foreign filesystems either have no concept of file ownership or have an ownership scheme incompatible with that of Unix-like operating systems. (Notable among these filesystems are FAT and NTFS.) The programs that mount these kinds of filesystems thoughtfully allow you to specify the ownership of files on the filesystem. The -u flag lets you specify a file owner, and the -g flag lets you specify the group.

For example, here’s how I would mount a FAT filesystem as owned by my account:

# mount_msdos -u mwlucas -g mwlucas /dev/sd3c /mnt

Some other filesystems use permissions schemes compatible with OpenBSD’s permissions. For example, all of the information OpenBSD needs to assign permissions to files and directories is contained within an ext2fs filesystem. That doesn’t mean that an ext2fs filesystem will perform seamlessly on OpenBSD, however. Though OpenBSD will respect the ext2fs disk’s permissions, the user ID numbers probably won’t match up between the operating systems.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.200.206