• 统信UOS_麒麟KYLINOS禁用USB存储


    原文链接:统信UOS/麒麟KYLINOS禁用USB存储
    hello,大家好啊,今天给大家带来一篇在统信UOS/麒麟KYLINOS禁用USB存储的文章,文章通过三种方式:1、在文件管理器中通过图形化方式移除USB;2、通过禁用USB存储模块实现禁用;3、通过添加udev规则实现禁用。大家可以选择不同的方式实现,欢迎大家分享转发。关注我吧!
    1、查看系统版本

    pdsyw@pdsyw-PC:~/Desktop$ cat /etc/os-version 
    [Version] 
    SystemName=UOS Desktop
    SystemName[zh_CN]=统信桌面操作系统
    ProductType=Desktop
    ProductType[zh_CN]=桌面
    EditionName=Professional
    EditionName[zh_CN]=专业版
    MajorVersion=20
    MinorVersion=1060
    OsBuild=11014.100.100
    pdsyw@pdsyw-PC:~/Desktop$ 
    pdsyw@pdsyw-PC:~/Desktop$ uname -a
    Linux pdsyw-PC 4.19.0-arm64-desktop #6030 SMP Tue Jun 27 15:28:10 CST 2023 aarch64 GNU/Linux
    pdsyw@pdsyw-PC:~/Desktop$ 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    image.png

    2、查看USB存储信息

    pdsyw@pdsyw-PC:~/Desktop$ lsmod | grep usb_storage
    usb_storage            73728  1
    pdsyw@pdsyw-PC:~/Desktop$ 
    
    • 1
    • 2
    • 3

    image.png

    3、可以通过卸载按键进行卸载
    image.png

    4、也可以点击安全移除按键进行移除
    image.png

    5、可以通过命令行卸载移除USB

    pdsyw@pdsyw-PC:~/Desktop$ sudo rmmod usb_storage
    
    • 1

    image.png

    6、移除后查看USB信息

    pdsyw@pdsyw-PC:~/Desktop$ lsmod | grep usb_storage
    usb_storage            73728  0
    pdsyw@pdsyw-PC:~/Desktop$ 
    
    • 1
    • 2
    • 3

    image.png

    7、通过禁用usb存储模块实现禁用USB存储

    pdsyw@pdsyw-PC:~/Desktop$ sudo -i
    root@pdsyw-PC:~# echo "install usb-storage /bin/true" > /etc/modprobe.d/usb-storage.conf
    root@pdsyw-PC:~# chmod 644  /etc/modprobe.d/usb-storage.conf
    root@pdsyw-PC:~# update-initramfs -u
    update-initramfs: Generating /boot/initrd.img-4.19.0-arm64-desktop
    cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries 
        nor crypto modules. If that's on purpose, you may want to uninstall the 
        'cryptsetup-initramfs' package in order to disable the cryptsetup initramfs 
        integration and avoid this warning.
    setupcon is missing. Please install the 'console-setup' package.
    W: plymouth: The plugin label.so is missing, the selected theme might not work as expected.
    W: plymouth: You might want to install the plymouth-themes package to fix this.
    I: The initramfs will attempt to resume from /dev/sda3
    I: (UUID=9aaca392-458c-4f32-925b-04692d3f9a43)
    I: Set the RESUME variable to override this.
    live-boot: core filesystems devices utils udev blockdev dns.
    Adding IMA binaries
    root@pdsyw-PC:~# reboot 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    image.png

    8、重新插入u盘已经无法识别
    image.png

    9、通过删除usb-storage.conf文件取消USB存储禁用

    pdsyw@pdsyw-PC:~/Desktop$ sudo rm -rf /etc/modprobe.d/usb-storage.conf 
    pdsyw@pdsyw-PC:~/Desktop$ 
    pdsyw@pdsyw-PC:~/Desktop$ sudo update-initramfs -u
    update-initramfs: Generating /boot/initrd.img-4.19.0-arm64-desktop
    cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries 
        nor crypto modules. If that's on purpose, you may want to uninstall the 
        'cryptsetup-initramfs' package in order to disable the cryptsetup initramfs 
        integration and avoid this warning.
    setupcon is missing. Please install the 'console-setup' package.
    W: plymouth: The plugin label.so is missing, the selected theme might not work as expected.
    W: plymouth: You might want to install the plymouth-themes package to fix this.
    I: The initramfs will attempt to resume from /dev/sda3
    I: (UUID=9aaca392-458c-4f32-925b-04692d3f9a43)
    I: Set the RESUME variable to override this.
    live-boot: core filesystems devices utils udev blockdev dns.
    Adding IMA binaries
    pdsyw@pdsyw-PC:~/Desktop$ reboot 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    image.png

    10、取消禁用重启后可以识别USB存储
    image.png

    11、通过添加udev规则实现禁用usb存储

    pdsyw@pdsyw-PC:~/Desktop$ sudo vi /etc/udev/rules.d/10-usb-block.rules
    请输入密码:
    验证成功
    pdsyw@pdsyw-PC:~/Desktop$ cat /etc/udev/rules.d/10-usb-block.rules
    ACTION=="add", KERNEL=="sd[a-z][0-9]*", SUBSYSTEM=="block", RUN+="/bin/sh -c 'echo 0 > /sys/block/%k/device/authorized'"
    
    pdsyw@pdsyw-PC:~/Desktop$ reboot 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    image.png

    12、重启后u盘无法识别
    image.png

    13、删除10-usb-block.rules取消禁用

    pdsyw@pdsyw-PC:~/Desktop$ sudo rm -rf /etc/udev/rules.d/10-usb-block.rules 
    请输入密码:
    验证成功
    pdsyw@pdsyw-PC:~/Desktop$ reboot 
    
    • 1
    • 2
    • 3
    • 4

    image.png

    14、重启后可以识别u盘
    image.png

  • 相关阅读:
    ardupilot开发 ---传感器驱动,外设驱动篇
    Redis设计与实现(一)| 数据结构 & 对象
    matplotlib笔记分享之基础设置(二)
    DPVS的定时器
    海象赋值表达式减少重复变量
    计算机专业毕设课设选题攻略
    MySQL处理Json数据
    背包问题学习笔记-01背包
    CentOS7安装MySQL8(Red Hat版)
    COCO 数据集 人体关键点格式
  • 原文地址:https://blog.csdn.net/m0_69493559/article/details/134457103