最近偷懶,沒學(xué)習(xí),反想起自己的路由刷了Openwrt,正好閑置了一個(gè)硬盤想拿來(lái)做個(gè)網(wǎng)絡(luò)硬盤,于是開始了折騰....這里將不談?wù)撊绾嗡penwrt,如何ssh,如何添加PPOE,如何添加相對(duì)應(yīng)服務(wù)的包等等,網(wǎng)上太多資料了...
這里只記錄了耗時(shí)1天半,折磨自己,例如,擴(kuò)展了系統(tǒng)容量,設(shè)置了Samba,aria2和aria2webui, 構(gòu)建Owncloud私有云盤,的一些過程和一些配置文件干貨。有些配置完了突然感覺然并卵,但是過程很愉快算是減壓的好玩具。
硬件大概這個(gè)樣子....WNDR4300

系統(tǒng)環(huán)境:
1. 系統(tǒng)版本:OpenWrt CHAOS CALMER (15.05, r46767)
2. 路由型號(hào):WNDR4300
3. 硬盤分區(qū):/dev/sda2 NTFS 網(wǎng)絡(luò)共享硬盤 647.51GB
/dev/sda3 SWAP SWAP 1GB
/dev/sda4 EXT4 Openwrt系統(tǒng) 49.09 GB
U盤實(shí)現(xiàn)熱插拔:
添加USB相關(guān)支持
[plain] view plain copy
Kernel modules —> USB Support —> <*> kmod-usb-core. ##默認(rèn)已經(jīng)選了
Kernel modules —> USB Support —> <*> kmod-usb-ohci. ##默認(rèn)已選 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. ##默認(rèn)已經(jīng)選了 usb2.0
添加SCSI支持
[plain] view plain copy
Kernel modules —> Block Devices —> <*>kmod-scsi-core ##默認(rèn)已經(jīng)選了 usb3.0
添加USB掛載
[plain] view plain copy
Base system —> <*>block-mount
添加文件系統(tǒng)支持
[plain] view plain copy
Kernel modules —> Filesystems —> <*> kmod-fs-ext4 (移動(dòng)硬盤EXT4格式選擇)
Kernel modules —> Filesystems —> <*> kmod-fs-vfat(FAT16 / FAT32 格式 選擇)
Kernel modules —> Filesystems —> <*> kmod-fs-ntfs (NTFS 格式 選擇)
退出保存 make V=99
自動(dòng)掛載U盤:編輯 /etc/hotplug.d/block/10-mount 寫入以下內(nèi)容
[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盤啟動(dòng)
確認(rèn)掛載盤符,文件系統(tǒng)最好選擇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:上面添加的腳本就可以幫助我們不用在手動(dòng)掛載或者管理頁(yè)面添加掛載。

這里samba使用samba36-server,修改/etc/samba/smb.conf重啟Samba服務(wù)并不起作用,全局和共享是分開的配置文件,分別修改/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
效果展示:
最后我將網(wǎng)盤映射成了本地,迅雷下載,百度云盤,還有云音樂下載都放在了網(wǎng)絡(luò)硬盤上,基本滿足了我網(wǎng)絡(luò)存儲(chǔ)需求。

手機(jī)IOS訪問,nplayer效果,個(gè)人感覺nplayer太好用了....


傳送:
[Openwrt擴(kuò)展中篇]添加Aria2和webui
[Openwrt 擴(kuò)展上篇]USB掛載&U盤啟動(dòng)&Samba共享
參考資料:
http://blog.csdn.net/u011641885/article/details/46530327
http://blog.sina.com.cn/s/blog_4849d5ac0102v4hy.html
浙公網(wǎng)安備 33010602011771號(hào)