mount FS without filesystem type

Javier Martinez Canillas martinez.javier at gmail.com
Thu Jul 21 07:37:58 EDT 2011


On Thu, Jul 21, 2011 at 10:20 AM, piyush moghe <pmkernel at gmail.com> wrote:
> I have a question regarding mounting filesystem without giving filesystem
> type as argument to mount command:
>
> Now my question is that if I don't provide FS type name to mount command how
> the FS gets mounted. Is there some other path for this code or if before
> calling compat_sys_mount i.e in user mode FS type is determined somehow?
>
> Regards,
> Piyush

Hello Piyush,

The mount command, resolves in userspace. Most mount binaries are
compiled against libblkid library that is used to identify the content
of block devices.

root at aopcjm:~# ldd /bin/mount | grep blkid
	libblkid.so.1 => /lib/libblkid.so.1 (0xb76e3000)

Mounting without specifying the FS type for my pendrive, the mount
syscall is invoked with FS type vfat

root at aopcjm:~# strace -emount mount /dev/sdb1 /mnt/pendrive/
mount("/dev/sdb1", "/mnt/pendrive/", "vfat", MS_MGC_VAL, NULL) = 0

Is very well described in the mount man page:

If no -t option is given, or if the auto type is specified, mount will
try to guess the desired type. If mount was compiled with the blkid
library, the guessing is done by this library. Otherwise, mount
guesses itself by probing the superblock; if that does not turn up
anything that looks familiar, mount will try to read the file
/etc/filesystems, or, if that does not exist, /proc/filesystems. All
of the filesystem types listed there will be tried, except for those
that are labeled "nodev" (e.g., devpts, proc, nfs, and nfs4). If
/etc/filesystems ends in a line with a single * only, mount will read
/proc/filesystems afterwards.

>From the blkid man page:

The blkid program is the command-line interface to working with
libuuid(3) library. It can determine the type of content (e.g.
filesystem, swap) a block device holds, and also attributes (tokens,
NAME=value pairs) from the content metadata (e.g. LABEL or UUID
fields).

Hope this helps,

-- 
Javier Martínez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Autònoma de Barcelona
Barcelona, Spain



More information about the Kernelnewbies mailing list