最近偷懶,沒學習,反想起本身的路由刷了Openwrt,正好閒置了一個硬盤想拿來作個網絡硬盤,因而開始了折騰....這裏將不談論如何刷Openwrt,如何ssh,如何添加PPOE,如何添加相對應服務的包等等,網上太多資料了...html
這裏只記錄了耗時1天半,折磨本身,例如,擴展了系統容量,設置了Samba,aria2和aria2webui, 構建Owncloud私有云盤,的一些過程和一些配置文件乾貨。有些配置完了忽然感受然並卵,可是過程很愉快算是減壓的好玩具。
ios
硬件大概這個樣子....WNDR4300web
系統環境:vim
1. 系統版本:OpenWrt CHAOS CALMER (15.05, r46767)網絡
2. 路由型號:WNDR4300dom
3. 硬盤分區:/dev/sda2 NTFS 網絡共享硬盤 647.51GBssh
/dev/sda3 SWAP SWAP 1GBsocket
/dev/sda4 EXT4 Openwrt系統 49.09 GB學習
U盤實現熱插拔:ui
添加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 擴展上篇]USB掛載&U盤啓動&Samba共享
參考資料:
http://blog.csdn.net/u011641885/article/details/46530327
http://blog.sina.com.cn/s/blog_4849d5ac0102v4hy.html