• [Openwrt 扩展上篇]USB挂载&U盘启动&Samba共享


    最近偷懒,没学习,反想起自己的路由刷了Openwrt,正好闲置了一个硬盘想拿来做个网络硬盘,于是开始了折腾....这里将不谈论如何刷Openwrt,如何ssh,如何添加PPOE,如何添加相对应服务的包等等,网上太多资料了...

    这里只记录了耗时1天半,折磨自己,例如,扩展了系统容量,设置了Samba,aria2和aria2webui, 构建Owncloud私有云盘,的一些过程和一些配置文件干货。有些配置完了突然感觉然并卵,但是过程很愉快算是减压的好玩具。

    硬件大概这个样子....WNDR4300

    系统环境:

      1. 系统版本:OpenWrt  CHAOS CALMER (15.05, r46767)

      2. 路由型号:WNDR4300

      3. 硬盘分区:/dev/sda2  NTFS    网络共享硬盘  647.51GB

            /dev/sda3  SWAP    SWAP 1GB

            /dev/sda4  EXT4  Openwrt系统 49.09 GB

    U盘实现热插拔:

    添加USB相关支持
    [plain] view plain copy Kernel modules —
    > USB Support —> <*> kmod-usb-core. ##默认已经选了 Kernel modules —> USB Support —> <*> kmod-usb-ohci. ##默认已选 old usb1.0 Kernel modules —> USB Support —> <*> kmod-usb-uhci. ## usb1.1 Kernel modules —> USB Support —> <*> kmod-usb-storage. Kernel modules —> USB Support —> <*> kmod-usb-storage-extras. Kernel modules —> USB Support —> <*> kmod-usb2. ##默认已经选了 usb2.0 添加SCSI支持
    [plain] view plain copy Kernel modules —
    > Block Devices —> <*>kmod-scsi-core ##默认已经选了 usb3.0 添加USB挂载
    [plain] view plain copy Base system —
    > <*>block-mount 添加文件系统支持
    [plain] view plain copy Kernel modules —
    > Filesystems —> <*> kmod-fs-ext4 (移动硬盘EXT4格式选择) Kernel modules —> Filesystems —> <*> kmod-fs-vfat(FAT16 / FAT32 格式 选择) Kernel modules —> Filesystems —> <*> kmod-fs-ntfs (NTFS 格式 选择) 退出保存 make V=99 自动挂载U盘:编辑 /etc/hotplug.d/block/10-mount 写入以下内容
    [plain] view plain copy
    #!/bin/ash case "$ACTION" in add) for i in $(ls /dev/ | grep 'sd[a-z][1-9]') do mkdir -p /mnt/$i mount -o iocharset=utf8,rw /dev/$i /mnt/$i if [ $? -ne 0 ] then mount -o rw /dev/$i /mnt/$i fi done ;; remove) MOUNT=`mount | grep -o '/mnt/sd[a-z][1-9]'` for i in $MOUNT do umount $i if [ $? -eq 0 ] then rm -r $i fi done ;; esac

    USB挂载&U盘启动

    确认挂载盘符,文件系统最好选择EXT4 ,可以在路由里格式化也可以用Diskgenius格式化(建议用Diskgenius十分方便)

    vim /etc/config/fstab
    
    config global
            option anon_swap '0'
            option anon_mount '0'
            option auto_swap '1'
            option auto_mount '1'
            option delay_root '5'
            option check_fs '0'
    
    config swap
            option device '/dev/sda3'
            option enabled '1'
    
    config mount
            option target '/mnt/sda4'
            option uuid 'fbca3c60-5c6a-d748-93bd-d5b54aeb575c'
            option enabled '1’
    
    
    reboot

    效果展示: 

    Samba + ntfs + guest共享

    软件包如果你要挂载NTFS格式的硬盘的话,PS:上面添加的脚本就可以帮助我们不用在手动挂载或者管理页面添加挂载。

      

    这里samba使用samba36-server,修改/etc/samba/smb.conf重启Samba服务并不起作用,全局和共享是分开的配置文件,分别修改/etc/samba/smb.conf.template和/etc/config/samba

    /etc/samba/smb.conf.template

    [global] netbios name = Sean-OpenWrt display charset = UTF-8 interfaces = 127.0.0.1/8 lo 66.66.66.60/24 br-lan server string = Sean-OpenWrt unix charset = UTF-8 workgroup = WORKGROUP browseable = yes deadtime = 30 domain master = yes encrypt passwords = true enable core files = no guest account = nobody guest ok = yes #invalid users = root local master = yes load printers = no map to guest = Bad User max protocol = SMB2 min receivefile size = 16384 null passwords = yes obey pam restrictions = yes os level = 20 passdb backend = smbpasswd preferred master = yes printable = no security = user smb encrypt = disabled smb passwd file = /etc/samba/smbpasswd socket options = TCP_NODELAY IPTOS_LOWDELAY syslog = 2 use sendfile = yes writeable = yes

     

    /etc/config/samba

    [homes] comment
    = Home Directories browsable = no read only = no create mode = 0750 [NetworkShare] path = /mnt/sda2 read only = no guest ok = yes create mask = 0777 directory mask = 0777

    效果展示:

    最后我将网盘映射成了本地,迅雷下载,百度云盘,还有云音乐下载都放在了网络硬盘上,基本满足了我网络存储需求。

    手机IOS访问,nplayer效果,个人感觉nplayer太好用了....

     

    传送:

      [Openwrt扩展中篇]添加Aria2和webui

      [Openwrt 扩展上篇]USB挂载&U盘启动&Samba共享

    参考资料:

      http://blog.csdn.net/u011641885/article/details/46530327

      http://blog.sina.com.cn/s/blog_4849d5ac0102v4hy.html

      

  • 相关阅读:
    Deformable 可变形的DETR
    https://start.aliyun.com/
    english note 111
    HTTP/2.0与HTTP/1.1协议区别
    什么是长连接
    使用pycharm
    Java使用率大幅度下降,Python使用率逐渐攀升
    SELECT command denied to user 'root'@'localhost' for table 'user'
    mysql 问题阅后归档
    响应式编程
  • 原文地址:https://www.cnblogs.com/sean-yao/p/8224174.html
Copyright © 2020-2023  润新知