头图

Preface

I don't know how many people build central storage devices at home, that is, NAS. In my daily life, this thing stores a lot of personal information, family photos, technical information, and various high-definition film and television dramas. With the IP of the public network, it can truly meet the needs of reading data at any time and anywhere.

I have written a basic introduction article on playing NAS before, including public network application and port mapping. Interested friends can read:

https://mp.weixin.qq.com/s/MwaZeDQZfk0tRt1D4iE-5g

However, after using NAS for a period of time, you can read and save files anytime and anywhere. But I found that there are still many inconveniences.

For example, a data in my computer needs to be read from the NAS in the public network environment (note that it is a public network, the internal network actually does not matter), and I encountered the following troubles:

1. Open the management interface of the NAS, log in with authorization, and download the file to run locally. If the file is small, it’s okay. If the file is large, such as 20 gigabytes for a movie, then I have to wait for the movie to be downloaded locally before I can watch it.

2. Synology NAS provides a Synology driver file synchronization tool. Each computer needs to install a client software. Computer A will synchronize it, and computer B will have to wait for the Synology driver to synchronize before starting the file. I always think this method is feasible, but it is still too cumbersome, and it can only be used with the support of third-party synchronization software. Not native.

3. If the mount access is through ftp, sftp, etc., the same problem is also true. It is nothing more than replacing the authorized login of the webpage with the authorization of ftp. And ftp doesn't seem to support stream reading, and movies cannot be read and played directly.

4. As for the smb protocol method, mapping smb to the public network has security risks. Moreover, the transmission efficiency of smb is also very low.

So I later use the webdav protocol to mount, and mount nas to a local network hard drive for access. I always think this way is the best way, because it is equivalent to directly operating the NAS disk locally. It can also play video resources in a streaming way. Multiple computers can also be mounted at the same time, save it here, and read it there in real time. Quite convenient.

But when using webdav, I also found some drawbacks, for example, some software or games do not support direct installation in the network disk.

So I thought, if the system can treat the network disk as its own local disk. That would be perfect.

Some time ago, an old man and I introduced the iSCSI protocol, which can really achieve this kind of operation. After I researched it, I successfully mounted a part of the NAS disk space to the local perfectly, and the system will treat this disk completely as local disk space. My macbook pro instantly expanded the capacity of one T!

Okay, the introduction is a bit long, so this article is to introduce the iSCSI protocol to students who play NAS.

What is iSCSI

iSCSI (Internet Small Computer System Interface) is a standard for data block transmission over TCP/IP. It was initiated by CiSCO and IBM, and has received great efforts from major storage vendors. support. iSCSI encapsulates SCSI commands in TCP/IP packets and uses a SCSI frame header. iSCSI can implement the SCSI protocol running on the IP network, enabling it to perform fast data access and backup operations such as high-speed Gigabit Ethernet, that is, network-based storage.

This is an explanation of iSCSI, let me translate it for everyone:

First of all, iSCSI is a protocol standard for communication transmission, which is based on Ethernet for data transmission, and the transmission rate is very high. Secondly, the storage bottom layer of many systems currently supports this protocol, and the bottom layer of many systems also supports this protocol, such as windows and macOS. Therefore, this protocol can be recognized by the bottom layer of the system's storage, so that it can be mounted from the kernel level. This type of mounting will be considered as a local disk by the system, but it will use the network transmission protocol.

: The operating system natively treats the NAS as its own local hard drive. No problem installing software games.

Next, let’s start. The settings are mainly divided into 2 terminals, the server (NAS) and the client (PC's operating system).

NAS side settings

I will only introduce Synology's NAS operating system here. I have never played QNAP's, but the principles are the same.

First, you have to update Synology's NAS operating system to version 7.0, which can be checked through the control panel -> update and restore interface:

image.png

Then, find the SAN Manager package in the middle of the package and install it:

image.png

Open the installed SAN Manager, select the LUN, and click Add.

Select the disk you used to create the space, and then enter the allocated capacity. I allocated 1T capacity here. Here is the meaning of dividing a piece of space from your disk as a virtual disk.

image.png

Going all the way down here, the LUN will be created, and the SAN Manager will automatically create a Target for you, and bind the LUN to the Target. In iSCSI, you will see the Target that has been created and mapped. The Target here is the target that your client will eventually connect to.

image.png

Then you need to map the 3260 port of the NAS server through the router. If you do port mapping, I won't talk about it here. If not, please baidu by yourself.

At this point, the NAS side setting is complete.

Windows settings

Windows natively supports the iSCSI protocol. The configuration can be completed without third-party software. Here I take the settings of windows 10 as an example.

First, open win+R and enter services.msc

image.png

Then find Microsoft iSCSI Initiator Service in the opened service window and start it

image.png

Then find the management tool in the control panel, open it

image.png

Find the iSCSI initiator in the management tool and double-click to open it

image.png

In the pop-up window, select the Discovery tab page, click Discovery Portal

image.png

In the pop-up window, enter the public network IP address of your home router (if you don’t know how to apply for the public network, you can see the introduction in another article at the beginning) and port. The port I mapped here is 33260.

image.png

If the test passes, return to the target tab page, and you will see the target target that has been found, just click the link.

image.png

After setting these, you will find that your disk does not have an extra piece. Don't worry, the disk needs to be initialized as the last step. Right-click on My Computer, click Manage, and open the Disk Manager. You will find that there is a disk that has not been allocated (here I am taking a demo of allocated 5G space)

image.png

Select the GPT partition table method to confirm, and then format it. Pay attention to the disk format here. If you want to mount on multiple windows computers, choose NTFS, if you want to mount together between macOS and windows, choose FAT32.

After formatting, we can see. This disk already appears to be local.

image.png

At this time, when we turn on my computer, we will find that there is an extra disk, and from the surface, you can't see that this is an iSCSI-mounted hard disk at all. You can even install software and games in it!

image.png

Settings on macOS-Initiator X

Apple has not integrated the iSCSI protocol under Mac, so third-party software is needed for mounting.

There are not many software to mount iSCSI under macOS. And most of them need to be charged. After researching, there are 2 options under macOS, daemon tools and Initiator X.

Initiator X can only mount one target without paying. ( at the end of the article on how to obtain the Initiator X software).

Install the software, click Discovery in the upper left corner, and fill in your public network address and port

image.png

Then the system will load the target under this ip port

image.png

After double-clicking to connect, there will be an extra icon like this on the desktop

image.png

Then drag this into your finder list of favorites.

image.png

Then, let us look at the capacity of this disk

image.png

Isn't it? It has a capacity of one T more, and it feels close to a native disk. Isn't it awkward?

Settings on macOS-Deamon Tools

Another software is Deamon Tools, I use this software to mount iSCSI disks myself. It is a fee-based software

Why don't I need it for free? The main reason is that I have multiple computers and several disks to mount. Free ones can’t satisfy me. Another reason is that Deamon Tools is indeed an old-fashioned virtual disk mapping tool. Out of trust in this software, I Bought its serial number, buy it once, and use it forever. And it's not expensive.

The charging standard is as follows, here I only bought 2 machines, and the lifetime authorization fee is not expensive, and only 78 RMB. Moreover, it supports WeChat and Alipay payment, which is also relatively friendly to Chinese people.

image.png

After the installation, the interface looks like this, we only need its remote device function, right click to add, the same way as before, enter the public network ip and port, and then return to the main interface to automatically find the target, double-click to connect That's it.

image.png

The operation after that is the same as before, there will be an extra disk on the desktop, just drag this to the favorites list.

Because my mac computer doesn't shut down very much, opening Deamon Tools directly will help us connect automatically. This is much more convenient.

What is the transmission rate

The transmission rate is divided into two aspects, writing and reading.

Because iSCSI-mounted disks are essentially network disks, writing and reading still depend on the transmission rate of the network. But here the point of writing and reading is different.

Writing depends on the upstream speed of your current network and the downstream speed of your home network, take the minimum value. For example, the uplink speed of my company is 50Mbps, and the downlink speed of my home network is 300Mbps, then the speed I write is 50Mbps, which is equivalent to 6MB per second when converted into actual speed.

Reading depends on the downlink speed of your current network and the uplink speed of your home network. Take the minimum value. For example, the downlink speed of our company is 500Mbps, and the uplink speed of my home network is 30Mbps, so the speed I read is 30Mbps. Converted into actual speed, it is approximately equal to 4MB per second.

Generally speaking, the upward speed of the enterprise will be faster than the upward speed of the home, so if you are using it in the company. The writing speed is generally greater than the reading speed.

Some friends may feel that the speed of this kind of 6M write and 4M read is really slow. In fact, as long as you don't transfer movies, general data files are more than enough. And even if it’s a movie, you don’t need to download it to watch it locally, just open it to watch it, and it will be read in a stream.

According to the actual measurement, the reading rate of 4M can be stopped when watching 2K videos. 4K video requires a relatively high transmission rate, and 4K still has a stutter.

Things to note

The mounting method of iSCSI is equivalent to dividing a piece of virtual space from your NAS.

This virtual space is like your local disk, it needs to be formatted and even partitioned. But the files you put in this disk space will not be read out on your NAS.

Some friends will ask, what is the meaning of this. I can’t read it on my NAS.

In fact, if you have multiple computers, you will call it an artifact. Because the files are stored in the NAS, the NAS system is actually not needed for use. The user must be your computer. You save it in computer A, and computer B can be used as if it were locally. Isn't it fragrant? It is equivalent to the use level, so that you will not feel the existence of NAS. The files are actually stored in the NAS, and your NAS does not need to read the files to use.

postscript

This article introduces some sharing of my playing NAS. If anyone is interested in this topic, I will continue. For this reason, I have built a NAS exchange group. If you are interested, please reply "NAS" in my official account to join the group chat. Regarding the software mentioned in this article, I will package and share it in the group.

My official account has opened 4 new columns, which are open source recommendation, technical dry goods, technical men’s worldview, and technology changes lives. I am a technical man who likes tossing. In addition to writing professional knowledge, I also share my views on the world and the introduction of digital applications. I hope that technology can change and improve our life efficiency. If you are interested in my content, I hope you can like, share, and most importantly follow me.

image.png


铂赛东
1.2k 声望10.4k 粉丝

开源作者&内容创作者,专注于架构,开源,微服务,分布式等领域的技术研究和原创分享