2

I need a way to allow a user to format a disk to the filesystem of their choice the way that GParted does. We have devices that use NTFS, EXT4, XFS, and JFS so I'm mainly interested in those.

I just need a list of what is supported.

GParted provides the following list of what's available:

enter image description here

I'm having trouble figuring out how to get a similar list though.

The command cat /proc/filesystems provides the following output:

nodev   sysfs
nodev   rootfs
nodev   ramfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cpuset
nodev   tmpfs
nodev   devtmpfs
nodev   debugfs
nodev   securityfs
nodev   sockfs
nodev   pipefs
nodev   anon_inodefs
nodev   configfs
nodev   devpts
nodev   hugetlbfs
nodev   autofs
nodev   pstore
nodev   mqueue
nodev   selinuxfs
        xfs
nodev   rpc_pipefs
nodev   nfsd
nodev   binfmt_misc
        fuseblk
nodev   fuse
nodev   fusectl
        btrfs
        jfs
        ext3
        ext2
        ext4

This list doesn't make it obvious to me that NTFS is supported though. Is it included in a module under a different name? I've also read that this command does not provide a comprehensive list.

I then tried the command ls -l /lib/modules/$(uname -r)/kernel/fs which provided the following output:

total 52
drwxr-xr-x. 2 root root    18 Mar  7  2017 9p
-rw-r--r--. 1 root root 21853 Mar  2  2017 binfmt_misc.ko
drwxr-xr-x. 2 root root    21 Mar  7  2017 btrfs
drwxr-xr-x. 2 root root    26 Mar  7  2017 cachefiles
drwxr-xr-x. 2 root root    20 Mar  7  2017 ceph
drwxr-xr-x. 2 root root    20 Mar  7  2017 cifs
drwxr-xr-x. 2 root root    22 Mar  7  2017 cramfs
drwxr-xr-x. 2 root root    19 Mar  7  2017 dlm
drwxr-xr-x. 2 root root    24 Mar  7  2017 ecryptfs
drwxr-xr-x. 2 root root    22 Mar  7  2017 exofs
drwxr-xr-x. 2 root root    20 Mar  7  2017 ext4
drwxr-xr-x. 2 root root    48 Mar  7  2017 fat
drwxr-xr-x. 2 root root    23 Mar  7  2017 fscache
drwxr-xr-x. 2 root root    34 Mar  7  2017 fuse
drwxr-xr-x. 2 root root    20 Mar  7  2017 gfs2
drwxr-xr-x. 2 root root    21 Mar  7  2017 isofs
drwxr-xr-x. 2 root root    20 Mar  7  2017 jbd2
drwxr-xr-x. 2 root root    19 Mar  7  2017 jfs
drwxr-xr-x. 2 root root    21 Mar  7  2017 lockd
-rw-r--r--. 1 root root 19629 Mar  2  2017 mbcache.ko
drwxr-xr-x. 6 root root  4096 Mar  7  2017 nfs
drwxr-xr-x. 2 root root    38 Mar  7  2017 nfs_common
drwxr-xr-x. 2 root root    20 Mar  7  2017 nfsd
drwxr-xr-x. 2 root root  4096 Mar  7  2017 nls
drwxr-xr-x. 2 root root    23 Mar  7  2017 overlayfs
drwxr-xr-x. 2 root root    23 Mar  7  2017 pstore
drwxr-xr-x. 2 root root    24 Mar  7  2017 reiserfs
drwxr-xr-x. 2 root root    24 Mar  7  2017 squashfs
drwxr-xr-x. 2 root root    19 Mar  7  2017 udf
drwxr-xr-x. 2 root root    19 Mar  7  2017 xfs

Again, this does not make it obvious to me that this system supports NTFS.

I'm currently working on CentOS (which didn't support NTFS by default but was added by installing ntfs-3g and ntfsprogs) but I need a cross-platform solution for making a list of supported filesystems. Mainly for CentOS, Ubuntu, and Raspbian.

  • "I need a cross-platform solution" Are you saying you need a cross platform NTFS module? A module is kernel version ...specific not so much distribution. (Ubuntu, CentOS...). My guess is if /proc/filesystems does not show NTFS then that system does not have a NTFS module available. – jc__ Jan 23 '18 at 16:19
  • @jc__ except NTFS support is often handled by fuse – ivanivan Jan 23 '18 at 16:31
  • No, just a cross-platform method for determining which filesystems are supported. Mainly if NTFS is supported. – Blackwood Jan 23 '18 at 16:32
  • So would ls -l /lib/modules/$(uname -r)/kernel/fs | grep ntfs let you know if module exist and cat /proc/filesystems | grep ntfs let you know if module loaded or compiled in kernel? – jc__ Jan 23 '18 at 16:39
  • Unfortunately no, since ntfs doesn't show up in either list. As ivanivan mentioned, I suspect that the ntfs support in CentOS is handled by fuse. However, fuse existed on the system before I even added ntfs support so I don't know how to determine if ntfs support has been added to it. – Blackwood Jan 23 '18 at 16:43
0

First off, I would not assume that GParted retrieves a list of file systems from the underlying system. It may simply be a hard-coded list of common file systems.

That said, to detect ntfs support, the easiest way, and (probably!) cross-platform is to look for mount.ntfs binary. RedHat's (and CentOS') ntfs-3g package will put it into /usr/sbin.

This doesn't work for all file system types, though; there is no mount.ext4, for instance.

You can also look for /usr/sbin/mkfs.* which is probably more complete (and also more interesting for you since that is what you'd use to format partitions).

The location of these files may well vary from one distribution to the next, though - some may put it into /sbin, and potentially you may also find it in /usr/local/sbin, especially if NTFS support was compiled from source. You might even find it in the corresponding /bin directories.

  • I think the list for GParted is hard coded but dynamic. It had NTFS and JFS grayed out until I added support for both of them. Based on what I've learned here, I would assume that they have code to check for filesystem support on a per-distro basis. I think that I'll have to do the same. If I'm lucky maybe I can generalize for RedHat distros and for Debian distros. Either way, it's not hard to make special cases for different OS's. – Blackwood Jan 23 '18 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.