当前位置:网站首页>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
边栏推荐
- 中国消费者和产业链都很难离开苹果,iPhone的影响力太大了
- 02 linear structure 2 multiplication and addition of univariate polynomials (linked list solution)
- JS image to Base64
- C进阶——数据的存储
- How QT creator changes the default build directory
- The biggest crisis for testers in the workplace is not at the age of 30, but being laid off in middle age
- Examples of map search
- Acwing 92. recursive implementation of exponential enumeration
- Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]
- Wechat applet - drawing dashboard
猜你喜欢

ThinkPHP realizes database backup

Use abp Zero builds a third-party login module (4): wechat applet development

自己实现is_default_constructible

Zhihuihuayun | cluster log dynamic collection scheme

Seckill implementation diagram

Microsoft SQL Server database language and function usage (XII)

使用TypeFace设置TextView的文字字体
![[rust] Why do I suggest you learn rust | a preliminary study of rust](/img/33/a5e7d22e87502fa8582920cb34de9f.png)
[rust] Why do I suggest you learn rust | a preliminary study of rust

QT notes - realize form adaptation

Implementing deep learning framework from zero -- further exploration of the implementation of multilayer bidirectional RNN
随机推荐
String matching KMP
Solutions to problems in IE6 browser
Buckle exercise - 35 combination sum II
ERROR: [Synth 8-439] module ‘xxx‘ not found not found 错误解决办法
元宇宙更多的功能和作用在于对于传统生活方式和生产方式的深度改造
Buckle practice - sum of 34 combinations
一文看懂MES系统能实现企业哪些目标
Taishan Office Technology Lecture: layout difficulties of paragraph borders
Shell script case ---2
02 linear structure 2 multiplication and addition of univariate polynomials (linked list solution)
MES系统设备管理概述(中)
Buckle practice - 24 remove repeated letters
try...finally总结
树莓派自建 NAS 云盘之——数据自动备份
SSH服务突然连接不了案例总结
Is there a free and commercially available website for US media video clips?
QT notes - qtablewidget table spanning tree, qtreewidget tree node generates table content
SQL multi condition query cannot be implemented
6-16 vulnerability exploitation -rlogin maximum permission login
How QT creator changes the default build directory