mount FS without filesystem type

Greg Freemyer greg.freemyer at gmail.com
Thu Jul 21 16:36:13 EDT 2011


On Thu, Jul 21, 2011 at 7:37 AM, Javier Martinez Canillas
<martinez.javier at gmail.com> wrote:
> 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,

Don't forget /etc/fstab.

I almost positive the priority is:

 - command line arg
 - /etc/fstab
 - auto-detect

Greg



More information about the Kernelnewbies mailing list