[ Prev ] [ Index ] [ Next ]

mount

Created Thursday 13/10/2005

This document describes mount(8) and the various options for mounting different filesystems and devices, such as hdd, iso image, usb and so on.

1. Mounting a usb flash/memory stick

Use the standard mount(8) for mounting these type of devices. First, establish what device the unit is attached to. Do this with fdisk(8) as root or run the Hardware Browser as root either from Applications—▶System Tools—Hardware Browser or by directly running /usr/bin/hwbrowser. The usb flash/memory stick devices should appear as /dev/sd?? (e.g., /dev/sda1).

bash $ fdisk -l
    or
bash $ /usr/bin/hwbrowser

From within the Hardware Browser, the usb flash devices should appear under Hard Drives. E.g.,

/dev/sda
	sda1   1   32   244   fat32

Now that the device is identified, simply mount (as root) with:

bash $ mount -t vfat /dev/sda1 /mnt/flash

2. automounter (autofs)

The automounter is started and stoped by the init.d script /etc/init.d/autofs. The options are start, stop and restart which are the options available to most init.d scripts. E.g.,

bash # /etc/init.d/autofs start

Configuration is performed from /etc/auto.<category> where <category> is something like misc or net or similar (e.g., the misc category that mounts external devices on /misc is typically configured in the autofs file /etc/auto.misc). The entries in the automounter configuration have the same options as for /etc/fstab.

Automounting a flash device, assume the device is attached as /dev/sda1, requires an entry in one of the autofs configuration files. We'll use /etc/auto.misc:

# This is auto.misc
flash  -fstype=vfat,rw,noauto,uid=nobody,gid=usb,umask=0022 :/dev/sda1
smb    -fstype=nfs,exec,rw,intr,soft,pamconsole,_netdev joslyn:/home/public
cd     -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

3. Supported Filesystems

The mount(8) command and the automounter can support a bucketload of different filesystems such as ntfs, ext3, vfat, nfs/nfs4, smbfs, hpfs to more weird ones such as the proc, qnx4, ramfs, reiserfs, romfs, sysv, tmpfs, system level filesystems to fixed and other filesystem types like iso9660, udf, ufs, umsdos, usbfs, xenix, xfs, xiafs and etc.

For the more unusual filesystems (actually this includes ntfs as well), there is, In many cases, no kernel support in the vanilla kernel, nor in any loadable modules, supplied with the major linux distributions such as Fedora Core, Mandrake, SuSE, Debian/Ubuntu and similar. Support for these filesystems must be compiled into a custom kernel or a compatible kernel module must be compiled for the exact platform and version of the kernel currently being run. To make this process easier, It is quite common for kernel modules for some unsupported filesystems to be made available by apt, yum, up2date and similar. This is particularly true of ntfs.

To determine what filesystems are supported by the currently booted kernel, use the filesystems table in the proc filesystem:

bash $ cat /proc/filesystems

4. automounter /net

The auto.net entries for Fedora Core are mounted on /net. For example, of a host called joslyn exports a filesystem /multimedia to a host called client, then on client, the filesystem can be accessed via nfs through the path /net/joslyn/multimedia. The rpc and portmapper processes must be running on both server (host doing the exporting) and the client (host doing the mount).

In addition the portmapper port 111 must be open to the client for udp and tcp traffic and the nfs port 2049 must be open for tcp. The easiest way to ensure that rpc and the portmapper are running is to use the init.d script nfs. The following the server host is indicated by the prompt server# and the client with client#:

server# /etc/init.d/nfs start
server# /etc/init.d/nfslock start
client# /etc/init.d/nfs start
client# /etc/init.d/nfslock start

The relevant ports can be opened using either the system-config-securitylevel applet or with the iptables(1) command. The following opens 111 for tcp and udp and 2049 for tcp:

server# /sbin/iptables -I INPUT 1 -i eth0 -p tcp --tcp-flags SYN,RST,ACK SYN --dport 111 -m state --state NEW -j ACCEPT
server# /sbin/iptables -I INPUT 1 -i eth0 -p udp --tcp-flags SYN,RST,ACK SYN --dport 111 -m state --state NEW -j ACCEPT
server# /sbin/iptables -I INPUT 1 -i eth0 -p tcp --tcp-flags SYN,RST,ACK SYN --dport 2049 -m state --state NEW -j ACCEPT

5. Mounting an ISO image over the loop device

An ISO image can be mounted using the loop device. This is fairly trivial and can be done (as root) with:

bash # mount some_image.iso /mnt/iso/ -o loop

There are several options that can be given when mounting to the loop device, such as the blocksize and and which loop device to use. By default (i.e., if just -o loop is specified) then /dev/loop0 is used. To specify a different blocksize, provide the blocksize= option after loop, e.g., -o loop,blocksize=1024.

6. Mounting a filesystem with ssh

SSH can be used to mount a filesystem by installing fuse-sshfs, (see yum). The fuse-sshfs package includes the sshfs binary and the ssh fileystem library sshnodelay.so. The fuse package and fuse library packages (fuse-libs) must be installed:

bash # yum install fuse fuse-libs fuse-sshfs

Once installed, the fuse option for mount becomes available and accessible with mount -t fuse or mount.fuse. Configuration and use is essentially trivial and comes done to ensuring that sshd(1) running on the host whose filesystem will be mounted (i.e., exported).

It is important to add any users that are allowed to do the sshfs mount to the fuse group in /etc/group. This will allow individual users to mount and umount filesystems with mount -t fuse (or with sshfs directly):

bash # cat /etc/group | grep '^fuse:'
fuse:x:499:foo,bar,baz

The following example mounts the path /media/multimedia on host joslyn as a read-only filesystem using the fuse infrastructure and sshfs. The ssh connection is established as user foo:

bash $ mount -t fuse sshfs#foo@joslyn:/media/multimedia ~/Music/joslyn -o ro

Note that preceeding example uses the non-privileged user to perform the mount. This works because because the user foo belongs to the fuse group. The same mount outcome can be achieved with the following sshfs command (again as a non-privileged user):

bash $ sshfs joslyn:/multimedia ~/Music/joslyn

The sshfs rpm is a derivative the SSHFS filesystem distributed with LUFS. The main difference is that sshfs is based on FUSE (the userspace filesystem framework for Linux).

7. MS-DOS in a can

A raw file can set aside and formatted for use as another operating system or filesystem. For example, a raw block of 100M may be allocated and an MSDOS filesystem installed using a combination of dd(1) and mkdosfs(8).

The following example first creates a raw image file (containing nulls, ascii zero) with dd(1) and then uses mkdosfs(8) to install an msdos filesystem into the allocated disk file. The dd(1) command specifies a blocksize of 100MB and writes a single count from /dev/zero. The same effect can be achieved by reading 100 counts of a 1MB blocksize:

bash $ dd if=/dev/zero of=zipslack.img count=1 bs=100M
bash $ /sbin/mkdosfs -F 16 zipslack.img
bash # mkdir -p /mnt/zipslack /var/clients/default
bash # mount -t msdos -o loop zipslack.img /mnt/zipslack
bash # cd /mnt/zipslack
bash # unzip -qq ~amitg/zipslack.zip
bash # cd
bash # umount /mnt/zipslack
bash # mount -t umsdos -o loop zipslack.img /mnt/zipslack
bash # cd /mnt/zipslack
bash # find . -xdev -print0 | cpio -pa0Vdmu --sparse /var/clients/default
bash # cd
bash # umount /mnt/zipslack
bash # rmdir /mnt/zipslack

Stuart Moorfoot © 13 Oct 2005 foo@bund.com.au


Backlinks: ssh hdd autofs