惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

xnum’s blog

2025/03 初春日本四國遊記 2024/8 菲律賓遊學記 使用DNS紀錄來自動更新IP白名單 lvremove 遇到 contains a filesystem in use 淘寶退貨 順豐寄回大陸經驗 在Linux上面安裝glances並設定為系統服務 在dnsmasq加上自動生成PTR紀錄 ultrahuman ring air 台灣購買兼使用心得 AI Singing Voice Conversion (SVC) 的試玩心得
多媒體檔案管理和下載伺服器 - 軟體篇
Jia Jun Yeh · 2024-05-26 · via xnum’s blog

在管理多媒體檔案時,常見的RAID方案能提供即時保護,將多個硬碟模擬成一個虛擬硬碟給作業系統使用。這些虛擬硬碟經過格式化後,就能進行檔案存取。

常見的RAID方案有RAID1、RAID5和RAID6。RAID1是將兩顆硬碟存放相同內容,因此會浪費一半的硬碟空間。若要擴充,必須以兩顆硬碟為單位加入。

RAID5則使用一顆硬碟作為校驗盤,換取更大的可用容量,所以五顆硬碟的組合只佔用20%的空間。不過,RAID5有一些缺點,例如讀取檔案時需要多顆硬碟同時啟動,硬碟壞掉後復原過程較長且有失敗風險。RAID6則適用於超過五顆硬碟的情況,能提供更高的安全性。

另一種方式是JBOD,將多顆硬碟合併成一個大硬碟,但缺點是若有一顆硬碟損毀,整個虛擬硬碟的資料都會損毀。

以前,我使用JBOD管理下載機,但認為還有改進空間:

  1. 若只需存取特定檔案,應該只有一顆硬碟啟動提供服務,其他硬碟保持休眠,以省電並延長壽命。
  2. 若某顆硬碟損毀,我只想損失該硬碟上的檔案,其他硬碟仍能正常使用。

最近我發現了一個完美方案:mergerfs加上snapraid。

不同於RAID,mergerfs是一種特殊檔案系統,能將多個檔案系統合併成一個虛擬檔案系統。

假設我有三顆硬碟,分別格式化成ext4,並掛載到/mnt/disk{1,2,3},使用mergerfs可將這三個掛載點合併成/mnt/storage,並包含所有資料夾和檔案。我也能直接對/mnt/disk1進行讀寫,不影響/mnt/storage的運作。當/mnt/disk1損毀,/mnt/storage的內容會減少為/mnt/disk{2,3}的總和。

以下是我的/etc/fstab設定,由於後續要設定snapraid,其中一顆硬碟為parity_disk:

UUID="528592ce-dcc2-4aaa-9f92-d27166edfdfc" /mnt/disk1 ext4 noatime,nodiratime 0 0
UUID="414d7b98-d278-4397-80ff-9f5b103623ac" /mnt/disk2 ext4 noatime,nodiratime 0 0
UUID="c3017979-34eb-421a-bb94-c4291b15ffa4" /mnt/disk3 ext4 noatime,nodiratime 0 0
UUID="8878733e-eba1-4f5c-9dab-aa1f08835fd9" /mnt/parity_disk1 ext4 noatime,nodiratime 0 0

/mnt/disk* /mnt/storage fuse.mergerfs cache.files=partial,dropcacheonclose=true,moveonenospc=true,defaults,allow_other,minfreespace=100G,fsname=mergerfs,category.create=mspmfs,nonempty,noatime 0 0

我將category.create設為mspmfs,因為希望同一個torrent下載的檔案存放在同一硬碟,避免分散到多顆硬碟上。

mergerfs的另一個優點是硬碟容量不需一致。假設硬碟組合為4T、8T、12T,總可用空間即為24T。

mergerfs的小缺點是在移動檔案時,檔案不一定會落在同一硬碟上,跨硬碟操作會造成大量讀寫。處理此問題可以直接存取/mnt/disk*。使用qBittorrent時可能會遇到這個問題。

接下來是snapraid設定,與RAID的parity設計相似,但snapraid是非即時的,需手動觸發更新parity資料。適合寫入後不再改變的大型檔案。可設計小型暫存區,先複製檔案至RAID硬碟,更新parity後再刪除暫存檔案,避免遺失。

以下是我的/etc/snapraid.conf設定範例:

parity_disk須為RAID中最大硬碟。假設硬碟組合為4T、8T、12T,parity_disk須至少12T。

parity /mnt/parity_disk1/snapraid.parity
content /mnt/disk1/snapraid.content
content /mnt/disk2/snapraid.content
content /mnt/disk3/snapraid.content
data d1 /mnt/disk1/
data d2 /mnt/disk2/
data d3 /mnt/disk3/

exclude *.tmp
exclude *.temp
exclude *~
exclude Thumbs.db
exclude .DS_Store

exclude @Recycle/
exclude lost+found/

這樣就完成了一個適合多媒體檔案庫的自建NAS系統,硬碟可動態擴充,不需一次買齊,且能取得最佳性價比。