当前位置:网站首页>Raspberry pie self built NAS cloud disk -- raspberry pie built network storage disk
Raspberry pie self built NAS cloud disk -- raspberry pie built network storage disk
2022-07-24 12:37:00 【Brother Xing plays with the clouds】
Follow these step-by-step instructions to build your own raspberry pie based NAS System .
In the next three articles, I will talk about how to build a simple 、 Economic NAS Cloud disk system . I store data in this centralized storage system , And let it automatically back up incremental data every night . This series of articles will utilize NFS The file system mounts the disk to different devices under the same network , Use Nextcloud To access data offline 、 Share data .
This article mainly describes the software and hardware steps of attaching the data disk to the remote device . The second article in this series will discuss data backup strategies 、 How to add a scheduled backup data task . In the last article, we will install Nextcloud Software , User pass Nextcloud Provided web The interface can easily access data offline or online . This series of tutorials finally builds NAS Cloud disk supports multi-user operation 、 File sharing and other functions , So you can share data easily through it , For example, you can send an encrypted link , Share your photos with friends and so on .
The final system architecture is shown in the figure below :
Hardware
First, you need to prepare the hardware . The solutions listed in this article are just one example , You can also purchase according to different hardware schemes .
The main thing is raspberry pie 3, It has four cores CPU、1G RAM, as well as ( Compare ) Fast network interface . The data will be stored in two USB On disk drive ( Use here 1TB disk ); One disk is used for daily data storage , The other is for data backup . Be sure to use active USB Disk drive or with additional power supply USB A hub , Because raspberry pie can't be two USB Disk drive power .
Software
The most active operating system in this community is Raspbian, Easy to customize personalized items . There are already many Operation guide Tell me how to install in raspberry pie Raspbian System , So I won't repeat it here . At the time of writing , The latest officially supported version is Raspbian Stretch, It's easy for me to use .
Here we are , I will assume that you have configured the basic Raspbian The system can also pass ssh Visit your raspberry pie .
Get ready USB disc drive
In order to better read and write data , I suggest using ext4 File system to format disk . First , You must first find the disk connected to the raspberry pie . You can /dev/sd/<x> Disk device found in . Use command fdisk -l, You can find the two pieces just connected USB disc drive . Please note that , The following steps will clear USB All data on the disk drive , Please make a backup .
[email protected]:~ $ sudofdisk-l<...>Disk/dev/sda:931.5GiB,1000204886016 bytes,1953525168 sectorsUnits: sectors of 1*512=512 bytesSectorsize(logical/physical):512 bytes /512 bytesI/O size(minimum/optimal):512 bytes /512 bytesDisklabel type: dosDisk identifier:0xe8900690DeviceBootStartEndSectorsSizeIdType/dev/sda1 204819535251671953523120931.5G83LinuxDisk/dev/sdb:931.5GiB,1000204886016 bytes,1953525168 sectorsUnits: sectors of 1*512=512 bytesSectorsize(logical/physical):512 bytes /512 bytesI/O size(minimum/optimal):512 bytes /512 bytesDisklabel type: dosDisk identifier:0x6aa4f598DeviceBootStartEndSectorsSizeIdType/dev/sdb1 *204819535216631953519616931.5G83Linux
Because these devices are the only ones connected to raspberry pie 1TB Of disks , So we can easily identify /dev/sda and /dev/sdb That's the two USB disc drive . The partition table at the end of each disk prompts how to view after performing the following steps , These steps will format the disk and create the partition table . For each USB Follow the steps below to operate the disk drive ( Suppose your disk is also /dev/sda and /dev/sdb, For the second operation, you just need to replace the sda by sdb that will do ).
First , Delete the disk partition table , Create a new partition table that contains only one partition . stay fdisk in , You can use interactive single letter commands to tell the program what you want to do . Just at the prompt Command(m for help): Then input the corresponding letters ( have access to m Command for more details ):
[email protected]:~ $ sudofdisk/dev/sdaWelcome to fdisk(util-linux 2.29.2).Changes will remain in memory only,until you decide to write them.Be careful before using the write command.Command(m for help): oCreated a new DOS disklabel with disk identifier 0x9c310964.Command(m for help): nPartition typep primary (0 primary,0 extended,4 free)e extended (container for logical partitions)Select(default p): pPartition number (1-4,default1):First sector (2048-1953525167,default2048):Last sector,+sectors or+size{K,M,G,T,P}(2048-1953525167,default1953525167):Created a new partition 1 of type 'Linux'and of size931.5GiB.Command(m for help): pDisk/dev/sda:931.5GiB,1000204886016 bytes,1953525168 sectorsUnits: sectors of 1*512=512 bytesSectorsize(logical/physical):512 bytes /512 bytesI/O size(minimum/optimal):512 bytes /512 bytesDisklabel type: dosDisk identifier:0x9c310964DeviceBootStartEndSectorsSizeIdType/dev/sda1 204819535251671953523120931.5G83LinuxCommand(m for help):wThe partition table has been altered.Syncing disks.
Now? , We will use ext4 The file system formats the newly created partition /dev/sda1:
[email protected]:~ $ sudomkfs.ext4 /dev/sda1mke2fs1.43.4(31-Jan-2017)Discarding device blocks:done<...>Allocating group tables:doneWriting inode tables:doneCreating journal (1024 blocks):doneWriting superblocks and filesystem accounting information:done
After repeating the above steps , Let's label them according to their use :
[email protected]:~ $ sudo e2label /dev/sda1 data[email protected]:~ $ sudo e2label /dev/sdb1 backup
Now? , Let's install these disks and store some data . Based on my experience of operating the system for more than one year , When raspberry pie starts ( For example, after power failure ),USB Disk drives are not always mounted , So I suggest using autofs Mount when necessary .
First , install autofs And create a mount point :
[email protected]:~ $ sudo apt install autofs[email protected]:~ $ sudomkdir/nas
Then add the following line to mount the device /etc/auto.master:
/nas /etc/auto.usb
If the following does not exist , Create /etc/auto.usb, And then restart it autofs service :
data -fstype=ext4,rw :/dev/disk/by-label/databackup -fstype=ext4,rw :/dev/disk/by-label/backup[email protected]:~ $ sudo service autofs restart
Now you should be able to visit separately /nas/data as well as /nas/backup The disk is gone . obviously , It won't be too exciting yet , Because you just erase the data in the disk . however , You can execute the following command to confirm whether the device has been successfully mounted :
[email protected]:~ $ cd/nas/data[email protected]:/nas/data $ cd/nas/backup[email protected]:/nas/backup $ mount<...>/etc/auto.usb on /nas type autofs (rw,relatime,fd=6,pgrp=463,timeout=300,minproto=5,maxproto=5,indirect)<...>/dev/sda1 on /nas/data type ext4 (rw,relatime,data=ordered)/dev/sdb1 on /nas/backup type ext4 (rw,relatime,data=ordered)
First enter the corresponding directory to ensure autofs Able to mount devices .autofs It will track the access records of the file system , And mount the required equipment at any time . then mount The command will show these two USB The disk drive has been mounted to the location we want .
Set up autofs The process is error prone , If the first attempt fails , Please don't be depressed . You can search the Internet for tutorials .
Mount network storage
Now you have set up basic network storage , We want to install it to the remote Linux On the machine . Use here NFS file system , First install on raspberry pie NFS The server :
[email protected]:~ $ sudo apt install nfs-kernel-server
then , Need to tell NFS The server Open /nas/data Catalog , This is the only device that can be accessed from outside the raspberry pie ( The other is for backup ). edit /etc/exports Add the following to allow all to access NAS The device of cloud disk is attached to storage :
/nas/data *(rw,sync,no_subtree_check)
More details about limiting mount to a single device , see also man exports. After the above configuration , Anyone can access data , As long as they can visit NFS Required port :111 and 2049. I use the above configuration , Only allow access to my home network through the router firewall 22 and 443 port . such , Only devices on the home network can access NFS The server .
If you want to in Linux Computer mount storage , Run the following command :
[email protected]:~ $ sudomkdir/nas/data[email protected]:~ $ sudomount-t nfs <raspberry-pi-hostname-or-ip>:/nas/data /nas/data
Again , I suggest using autofs To mount the network device . If you need other help , Please see How to use Autofs To mount NFS share .
Now you can use on the remote device NFS System access is located in your raspberry pie NAS The data on the cloud disk . In a later article , I'll show you how to use rsync Automatically back up data to the second USB disc drive . You will learn how to use rsync Create incremental backups , It can save equipment space while doing daily backup .
via: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi
author :Manuel Dewald Topic selection :lujun9972 translator :jrg proofreading :wxy
This paper is written by LCTT Original compilation ,Linux China Honor roll out
边栏推荐
- Learn some programming: anti unemployment "vaccine"
- 6-16漏洞利用-rlogin最高权限登陆
- 有没有2、3w前期适合一个人干的创业项目呢?做自媒体可以吗?
- Buckle practice - maximum number of 28 splices
- Installation and deployment of ansible
- How QT creator changes the default build directory
- 1.4.1 many, many symbols (cin/cout unbinding, O3 optimization)
- Conference publishing function of conference OA project
- SQL JOIN 入门使用示例学习左连接、内连接、自连接
- ERROR: [Synth 8-439] module ‘xxx‘ not found not found 错误解决办法
猜你喜欢
向勒索病毒说不,是时候重塑数据保护策略
![[rust] reference and borrowing, string slice type (& STR) - rust language foundation 12](/img/48/7a1777b735312f29d3a4016a14598c.png)
[rust] reference and borrowing, string slice type (& STR) - rust language foundation 12

Opencv:08 image pyramid

Conference publishing function of conference OA project

QT notes - sort a column specified by qtablewidget

Vscode solves the problem of terminal Chinese garbled code
![[function test] test of the project - login and post function](/img/64/c9bbf34964622f4f013b1184eeb1e0.jpg)
[function test] test of the project - login and post function

支持刘海屏

QT based software framework design

Use abp Zero builds a third-party login module (4): wechat applet development
随机推荐
[rust] reference and borrowing, string slice type (& STR) - rust language foundation 12
微信公众号开发:素材管理(临时、永久)
Implementing deep learning framework from zero -- further exploration of the implementation of multilayer bidirectional RNN
How QT creator changes the default build directory
Zabbix5.0.8-odbc monitoring Oracle11g
Wechat applet learning five page Jump methods
Error: [synth 8-439] module 'xxx' not found not found error solution
[rust] what software should I use to develop rust? Recommended editors commonly used to support rust
国产旗舰手机定价近六千,却连iPhone12都打不过,用户选谁很明确
如何将Typora中图片上传到csdn
QT based software framework design
How to find out the function calling process of complex code running as soon as possible
Common shortcuts to VIM editor
中国消费者和产业链都很难离开苹果,iPhone的影响力太大了
如何用WebGPU流畅渲染百万级2D物体?
Buckle practice - 30 set the intersection size to at least 2
Support liuhaiping
QT notes - qtablewidget table spanning tree, qtreewidget tree node generates table content
OpenCV:08图像金字塔
使用Jenkins搭建CI服务器