Linux Disable Mounting of Uncommon Filesystem

Run the following commands and verify the output is as indicated:

# modprobe -n -v cramfs 
install /bin/true 
# lsmod | grep cramfs 
<No output>

How do I disable mounting of uncommon file systems such as hfs, udf, cramfs etc under Fedora or CentOS / RHEL / Redhat Enterprise Linux?

 

You need to edit /etc/modprobe.conf file to disable uncommon file system which can be loaded using Linux kernel driver. The syntax is:

 

install driverName /bin/true

In this example, disable loading hfs driver

install hfs /bin/true

Type the following command to list all file system drivers:

ls -l /lib/modules/$(uname -r)/kernel/fs

Sample outputs:

total 120
drwxr-xr-x 2 root root 4096 Sep 30 18:28 autofs4
drwxr-xr-x 2 root root 4096 Sep 30 18:28 cachefiles
drwxr-xr-x 2 root root 4096 Sep 30 18:28 cifs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 configfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 cramfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 dlm
drwxr-xr-x 2 root root 4096 Sep 30 18:28 ecryptfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 exportfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 ext3
drwxr-xr-x 2 root root 4096 Sep 30 18:28 ext4
drwxr-xr-x 2 root root 4096 Sep 30 18:28 fat
drwxr-xr-x 2 root root 4096 Sep 30 18:28 freevxfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 fscache
drwxr-xr-x 2 root root 4096 Sep 30 18:28 fuse
drwxr-xr-x 3 root root 4096 Sep 30 18:28 gfs2
drwxr-xr-x 2 root root 4096 Sep 30 18:28 hfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 hfsplus
drwxr-xr-x 2 root root 4096 Sep 30 18:28 jbd
drwxr-xr-x 2 root root 4096 Sep 30 18:28 jbd2
drwxr-xr-x 2 root root 4096 Sep 30 18:28 jffs2
drwxr-xr-x 2 root root 4096 Sep 30 18:28 lockd
drwxr-xr-x 2 root root 4096 Sep 30 18:28 msdos
drwxr-xr-x 2 root root 4096 Sep 30 18:28 nfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 nfs_common
drwxr-xr-x 2 root root 4096 Sep 30 18:28 nfsd
drwxr-xr-x 2 root root 4096 Sep 30 18:28 nls
drwxr-xr-x 2 root root 4096 Sep 30 18:28 squashfs
drwxr-xr-x 2 root root 4096 Sep 30 18:28 udf
drwxr-xr-x 2 root root 4096 Sep 30 18:28 vfat
drwxr-xr-x 2 root root 4096 Sep 30 18:28 xfs

Uncommon file systems can be blocked as follows:

install cramfs /bin/true
install hfs /bin/true
install hfsplus /bin/true
install squashfs /bin/true
install udf /bin/true

/etc/modprobe.d/blacklist File

You can also add them to /etc/modprobe.d/blacklist. Listing a module here prevents the hotplug scripts from loading it. The syntax is as follows:

blacklist driverName

I recommend using /etc/modprobe.conf to block unwanted drivers.

 

  • I am using FC10 at my home. I have dual boot setup. Every time I login to the GUI… all my ntfs partitions mount and cramp my desktop. I can stop ntfs mounting through that way but I wont be able to mount them either. ( Without first loading ntfs drivers.)
    Any way to stop that ? Any way to manage hald? (I suppose it’s hald that’s mounting them)

     

  • Can anyone give me the bash shell script on how to disable the uncommon file systems?

     

      • Mark Southworth Apr 7, 2017 @ 20:41

        sudo echo "install cramfs /bin/false" > /etc/modprobe.d/cramfs.conf
        sudo echo "install freevxfs /bin/false" > /etc/modprobe.d/freevxfs.conf
        sudo echo "install jffs2 /bin/false" > /etc/modprobe.d/jffs2.conf
        sudo echo "install hfs /bin/false" > /etc/modprobe.d/hfs.conf
        sudo echo "install hfsplus /bin/false" > /etc/modprobe.d/hfsplus.conf
        sudo echo "install squashfs /bin/false" > /etc/modprobe.d/squashfs.conf
        sudo echo "install udf /bin/false" > /etc/modprobe.d/udf.conf

        Might of missed some, but you can just add them. Run from CLI or just email me for the full script :)

         

        • You could also disable uncommon protocols:

          echo "install dccp /bin/false" > /etc/modprobe.d/dccp.conf
          echo "install sctp /bin/false" > /etc/modprobe.d/sctp.conf
          echo "install rds /bin/false" > /etc/modprobe.d/rds.conf
          echo "install tipc /bin/false" > /etc/modprobe.d/tipc.conf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值