3.6 Mounting Filesystems
Your computer now has a Microsoft Windows operating system, either FreeBSD 4.7-RELEASE or OpenBSD 3.2-RELEASE and Red Hat Linux 7.3 installed and coexisting peacefully together. Is that all? Is that enough? I am sure, no! One of the most important reasons that I have Microsoft Windows 98(SE) + FreeBSD 4.7-RELEASE + Red Hat Linux 7.3 all running on my computer (on which I prepared a part of this guide you are reading right now) is because I spend most of my time doing things on FreeBSD and on Linux, but I need access to Windows owing to my projects at the university. So, I need to access data stored on my Windows partition from time to time. But every time when I am working on FreeBSD and I need to access some data on my Windows partition, I just cannot afford to reboot my computer, log into Windows, copy the files on a floppy and then logout, reboot once again, log into FreeBSD, and then copy the contents of the floppy on to my /home/ghosh directory on the FreeBSD system. A process like this is not cute, neither logical nor feasible. Thanks to the "mount" command on FreeBSD and Linux systems, I do not have to go through this "not so cute, neither logical nor feasible" process every time I need access to some data on my Windows partition occasionally.
The mount command is definitely one of the most important commands available to the superuser (or root) account on a *nix system. It allows the root user of a *nix system to mount filesystems (for regular users to access and use) which may or may not be physically located on the same computer. That is, in other words, the mount command allows you to mount both a local filesystem (one that is present physically on the same computer) or a remote filesystem using the appropriate path for accessing the remote node. The mount command first appeared in Version 1 AT&T UNIX. See the manual page for the mount command on your FreeBSD or OpenBSD or Linux system for an in-depth analysis of all possible options that can be passed to the mount command.
Though it is a very powerful command on a Unix or Unix-like system, the mount command itself if very simple and easy to use. The syntax for the mount command is: mount -t filesystem device_name mount_point. It means you are instructing the mount command to consider the device file named device_name which is of the filesystem type specified by the switch -t filesystem, and then graft it onto the existing FreeBSD/OpenBSD/Linux system at the directory named as the mount point. As cute as that!
This chapter is divided into the following sections:
For mounting Linux Second Extended filesystem (ext2fs) on a FreeBSD system, I have to build and install a custom FreeBSD Kernel. Building and installing a custom kernel in FreeBSD is easy. I log in as "root" and execute these following steps to build one:
- I execute this from the command line: cd /usr/src/sys/i386/conf. If there is not a /usr/src/sys directory on your system, then the kernel source has not been installed. The easiest way to do this is by running /stand/sysinstall as root, choosing Configure, then Distributions, then src, and then sys.
- I create a copy of the original Kernel configuration file provided there as a sample by executing: cp GENERIC GHOSH. Here, I have named the would-be kernel GHOSH. Feel free to name it otherwise.
- I open the GHOSH text file using ee or vi editor. Though the general format of the configuration file is quite simple, full explanation of all the possible kernel options is beyond the scope of this guide. Please refer to the FreeBSD Handbook for more details. Add the following line: 'options EXT2FS' which provides support for identifying ext2fs Linux native filesystem. Tinker with the other options if you feel like or simply leave them alone.
- Save it and exit. When I are done, I type the following to compile and install the new kernel: /usr/sbin/config GHOSH.
- Then execute: cd ../../compile/GHOSH
- Execute: "make depend", followed by "make" and finally finish-off by executing "make install".
- The new kernel will be copied to the root directory as /kernel and the old kernel will be moved to /kernel.old.. Now, reboot your system to use the new kernel.
Once this done, I try mounting a Linux partition using the command: mount -t ext2fs /dev/ad0s3 /mnt/linux; assuming /dev/ad0s3 is the FreeBSD slice representing a Linux filesystem and /mnt/linux directory exists. The filesystem should mount at the specified directory acting as the mount point.
For mounting MSDOS partitions as well as Windows 95/98(SE)/ME formatted FAT16 and/or FAT32 filesystems, I execute the following command: mount -t msdos /dev/ad0s1 /mnt/windows where, /dev/ad0s1 is the FreeBSD slice that represents the Windows 98(SE) partition on my computer and /mnt/windows directory exists. For unmounting, I execute: umount /mnt/windows simply. For mounting MSDOS-based floppies, I execute: mount -t msdos /dev/fd0 /mnt/floppy. And for unmounting, I execute: umount /mnt/floppy simply. For people who have NTFS filesystem, they can try mounting using the command: mount -t ntfs /dev/fd0 /mnt/floppy and unmount using: umount -t ntfs /dev/fd0 /mnt/floppy. Readers must note: There is limited writing support for NTFS filesystems.
Mounting a FreeBSD filesystem i.e. UFS (Unix FileSystem) under Linux requires building and installing a custom Linux kernel. Building a Linux kernel is an easy job, and you may refer to any documentation you have access to. Here, I am just specifying the main steps. For building a custom Linux kernel, I log in as root and execute the following steps:
- I execute: cd /usr/src/linux-2.4. If the /usr/src/linux-2.4 directory does not exist on your system, then the kernel-source package has not been installed. For kernel compilation, you need to have kernel-source, make, dev86, gcc and a few dependencies installed.
- I make a backup (copy) of the original Makefile by executing: cp Makefile Makefile.bak. You can always refer to the original Makefile by accessing it as Makefile.bak.
- Then, I open the Makefile using vi or any text editor. You may change the EXTRAVERSION value to anything of your choice. For example, on my system, the initial Linux Kernel was 2.4.18-3. Since then I built numerous others as 2.4.18-3ghosh, 2.4.18-3smp, 2.4.18-3_dummy, 2.4.18-3bsd and so on. Thus, the EXTRAVERSION code helps to distinguish between a large number of available Linux Kernels on a system.
- Once done, I save and exit the Makefile. Then, execute: make mrproper. It cleans the compilation folders of any junk that was created while compiling Linux kernels on the same system earlier. Readers must note that all the commands executed (including this one) should be executed from within the /usr/src/linux-2.4 directory.
- I then execute: make menuconfig. Readers may also use xconfig concerned they have access to X11 or the X Window System.
- Once inside menuconfig, tinker with the options available. Make sure you enter the "File systems" section, then select the "UFS file system support (read-only)" and "UFS file system write support (DANGEROUS)" options. Thus, you should have something like this: <*> UFS file system support (read-only) and [*] UFS file system write support (DANGEROUS). The config Kernel-level options are as: CONFIG_UFS_FS and CONFIG_UFS_FS_WRITE for the read-only and write support respectively. Also, enter the "Partition types" section and select the [*] BSD disklabel (FreeBSD partition tables) option i.e. the CONFIG_BSD_DISKLABEL option. This allows you to access and read the FreeBSD disk labels in the FreeBSD slices.
- With these three options enabled, I save the configuration file and exit. Now execute: make dep && clean.
- Then execute: make bzImage && modules for creating the zipped (compressed) Linux kernel image file and the corresponding modules.
- Then execute: make modules_install for installing the newly created modules into their own corresponding directories.
- After this, I copy the bzImage file to the /boot directory. If required, you can also create an initial RAM-disk image file using the intird command.
- Once this done, I open the /boot/grub/grub.conf file using the vi editor and make a corresponding entry into it. Save and exit. Reboot to check whether the new Kernel is properly working or not. I am sure it would.
Once the newly built custom Linux kernel is installed, you can start using it to mount UFS filesystems. Use this command: mount -t ufs /dev/hda2 /mnt/bsd; concerned /dev/hda2 is the FreeBSD slice and /mnt/bsd exists. Unmount using the command: umount /mnt/bsd simply.
For mounting Windows 95/98/ME FAT32 filesystems on Linux, use the command: mount -t vfat /dev/hda1 /mnt/windows. The /mnt/windows directory must exist on the system. Unmount by executing: umount /mnt/windows simply. For readers who are using the NTFS filesystem, there's bad news! They have to include the NTFS filesystem support in the configuration file and build a custom Linux kernel. Readers must note: NTFS writing support is DANGEROUS and limited.
Previous Home Next