Introduction and the beginning of

Note: Our Raspberry Pi streaming textbook has been completely updated. This feature was first published in May 2013

The best thing about Raspberry Pi (RPI) is its versatility – originally launched as a training device, is to surpass these limitations become the go to a computer for just about anything you can think of. For example, it can double as a very capable headless server.

Contrary to popular belief, not every problem requires a lot of server processing power. For example, if you want to upload your files and share them with users on the network, regardless of operating system or device, you do not need a car with a multi-core processor in. In fact, using the old Linux machine as such a seedbox is a popular way to save discarded hardware.

The only drawback of this approach is that it consumes a lot of electricity. Most modern routers have a port USB, and connected to the device will share with all computers connected to the router. But what if you have an older router and want to do more than just share files?

With RPi, you can do all this and more, without the costs associated with traditional computer without capping devices, such as routers

DHCP

Assemble ingredients

We used the Raspberry Pi 2 1 GB of RAM for this tutorial, but it will work fine on other models Pi too, including the brand new Raspberry Pi zero . It will be equipped with the latest version as of this writing Raspbian (Version 2015-11-21-raspbian-Jesse).

The best thing about the new releases that they can use all the memory is increased without any tweaks. They also come with enabled SSH, which allows users to access and configure the RPI never connect it to the monitor.

Download the latest version of Raspbian distribution and flash it to the SD-card or with dd on Linux or Win32DiskImager if you’re on Windows. While you can use the Wireless USB adapter to connect the RPI on the Internet, it is best to use the Ethernet port and tighten the cable to the router.

After you connect and supply power to the RPI, head-to-router management page (or a router, check the documentation for the address). In all likelihood, your router uses DHCP to assign IP addresses to connected devices.

Explore the admin interface, search for a list of all connected devices and write down the IP-address of the router assigned RPi, later, you will have to assign a static IP-address to ensure that the RPI is always available at the same address.

At present, let’s assume a dynamic IP-address assigned to the RPI 192.168.3.100. With this bit of information, we are ready to connect to and prepare Raspbian RPi using SSH.

Each Linux distribution comes with the client SSH (it is built in the terminal Mac too). Members Windows, you can use [19459009PuTTY] tool. To connect to a remote Linux machine, run the terminal and enter the following command:

$ Sudo SSH pi@192.168.3.100

After agreeing to add this address to the list of trusted hosts You will be asked for login credentials. In the open, unadjusted Raspbian establish a password for ‘pi’ default user “raspberry”.

From this perspective, the teams in this lesson will be the same, regardless of whether connected to RPi from Linux machine or Windows. This is because the team will work on the distribution on Linux Raspbian RPi.

Since this is a fresh install, you will be prompted to configure it before you move on. Enter the following command:

$ Sudo raspi-configuration

This brings up a screen with many options. Scroll down and select An expanded version of , then select A0 Update , which will grab the latest version of the configuration utility.

Once this is done, the RPI can resume and you’ll have to rebuild with the help of SSH command or PuTTY as before. You have to do this every time you tweak any parameter and restart the RPI.

User Settings

When you return to the utility, select Expand the file system [] option 19459006 let Raspbian section to take on the entire space on the SD-card. We also recommend to change the user’s password at this time, too.

Next, select Download Options and select B1 console to stop loading the desktop GUI. Finally, select Split memory option in the Advanced , which allows you to partition of RAM on RPi between the GPU and the CPU. So how do we access the Pi only through a remote connection, make sure you assign a minimum memory of the GPU, which 16MB.

Close raspi-configuration and reboot. Next, you need to add other users to the RPI. Later, we will restrict access to certain folders on the USB devices attached to specific users and user groups, while at the same time being in public places on the device. But first:

$ Sudo AddUser

Replace with your target user name (do not include the <> marks). This will add a user to create the appropriate directories. The team will ask for the user’s password and other details. Then add the user to the user group:

$ Sudo usermod -a -G users

Raspi config

For the dance floor

When you’re done, it’s time to make available to the IRC users on the Internet. To do this, we will use Samba, which allows us to share files via the Common Internet File System (CIFS) protocols. To install Samba on the RPI, such as:

$ Sudo APT-get install Samba Samba-common-bin

When this is done, you’ll have to add people Samba. To do this, the user Pi default:

$ Sudo smbpasswd -a PI

You will be prompted to enter the password. It is usually safe to use the same password as the user account password. Repeat this step for each user in the system.

Samba is controlled by a configuration file that you need to configure before you can use it. It’s always a good idea to back up the existing configuration files before making any changes:

$ Sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old

Now use the command-line nano text editor to edit the configuration file:

$ Sudo nano /etc/samba/smb.conf

In file search in the section marked Global. In this section, remove the hash mark at the beginning of the line reads #security = user , so now reads security = user (if it is not, add the following line of Workgroup).

This will ensure that Samba only allows users to enter in who have home directories on RPi. To allow users access to their own home directory, look for the [Home] section under Share Definitions , and make sure viewed = yes and read Not only = no .

to exit nano, press [Ctrl] + [X], and then type y and press [ Enter ], when it shows the name of the file. Every time you make any changes to any of the services, you must restart it before the changes will be included. To restart Samba:

$ SUDO service Smbd restart

$ Sudo service nmbd restart

It’s time to connect the USB device to the RPI. Even if your Pi has only two or even four-port USB, it’s a good idea to connect any additional USB devices using a USB powered hub, especially if you connect more USB storage devices, which consume a lot of energy.

In addition, pay close attention to how the disk is formatted. By default, many flash drives USB, formatted for FAT32. This may be the best format in terms of the compatibility of the operating system, but it is much worse for file sharing over the network.

Then there is NTFS, which is used by many large external storage USB. This is not a format for you, if you want to stream media from a remote device that is best using ext4. However, to use ext4, only if the drive will be used in a network or on the machine Linux, and you know what you’re doing -. It can be a nightmare to configure permissions

After connecting the drive to find his place with Sudo FDISK -l . This is a list of devices connected to RPi and partition them. Scanning production and look for the disk, the size of which corresponds to the drive USB, which you are connected. The device is likely to be in the SDA, and we want to mount a partition on sda1.

Create a mount point and mount the device:

$ Sudo MkDir / highway / USB

$ sudo mount / DEV / sda1 / highway / USB

USB drive will be connected to reload the RPI. To avoid having to rewire the device, first find its UUID:

$ Sudo BLKID

/ DEV / sda1: LABEL = “USB” UUID = “3B5C053D35CAD865” TYPE = “NTFS”

Now, add it to the list of devices that are mounted at boot:

$ Sudo nano / etc / Fstab

UUID = 3B5C053D35CAD865 / highway / USB NTFS-3g UID = 1000, GID = 100, Umask = 0002 0 0

Change the NTFS-3g to VFAT, if your drive is FAT32. Save the file, and enter the following command to mount the drive correctly at boot:

$ sudo mount -a

Setting torrent server

Samba is for the sharing of files and folders, which are defined in the configuration file. Sharing folders on the USB, let’s assume that has a bunch of folders:

$ Ls / highway / USB

Documents Downloads Music Videos

To share a folder downloads, open [19459006/etc/samba/smbconf] file with nano, scroll down to the bottom and enter:

[Download]
Comment = Put ​​all your download here
Path = / highway / USB / file
Browseable = yes
for recording = yes
read only = no
valid users = @ users

This text block will share the / mnt / USB / Downloads directory with all users in the user group. Later, we will mount the directory on both computers, Linux and Windows. People will then be able to customize their download managers to save files directly to this folder on the USB, attached to RPi, from any computer on the network.

You can also restrict access to certain folders in some users only:

[Documents]
comment = Important eyes only for the PDF file
Path = / highway / USB / documents
visible = no
for recording = yes no
not read only = no
valid users = pi, bodhi

This will only Pi users and Bodhi mount and edit the contents of a folder.

Transmission

Set server torrent

torrents are the preferred medium for sharing content with open source. Most Linux distributions are distributed through one way or spies or through linuxtracker.org.

There is no shortage of torrent clients for desktop Linux. What sets apart from other programs is its easy-to-use web interface that resembles a table. We will install the programs on Raspbian, and then access it from any browser on any computer to add, monitor and control torrent

To install the gearbox, SSH in RPi and type :.

$ Sudo APT-get install transmission-daemon

This will install and start the daemon broadcasts. But before you can use it to download torrents, you must configure it. Before making any changes in the configuration file transmission, make sure that the daemon is not running:

$ Sudo transmission service daemon stop

In addition, before to go further, to add transmission (Debian-transmission), which is created automatically when you install a daemon to our user group:

$ Sudo usermod -a -G users Debian-transmission

Now create a public resource on the device, USB, where we download torrents. First, create a public share USB and assign the user to transfer his owner:

$ Sudo MkDir / highway / USB / public
$ Sudo Chaun Debian-Tranmission / highway / USB / public

Now add the share of the Samba configuration file to:

[Public]
comment = Public share torrents
viewed = yes
path = / mnt / USB / public
public = yes
for recording = yes
guest ok = yes

Share

Restart Smbd and nmbd services to make the share accessible to all. With public stakes in place, it’s time to configure the daemon broadcasts. Its parameters are defined in:

/etc/transmission-daemon/settings.json

Open file in nano before change “RPC-enabled whitelist”: true parameter to “RPC-enabled whitelist” lie to allow users to connect all computers.

Next, specify the download directory:

“download-DIR”: “/ highway / USB / public / download / complete”

You You can separate the incomplete files, storing them in a different folder. Firstly, enable the option by changing “incomplete DIR-enabled”: false parameter “incomplete DIR-enabled”: the truth , and then specify a directory that will house incomplete download from “incomplete dir”, “/ mnt / USB / public / downloads / incomplete”

User authentication and access to shares of

User Authentication

Since we gave the ownership of the / mnt / USB / shared directory for the user transmitting, it will automatically create new directories. While downloaded torrent community, you can ensure that not everyone in the queue for downloading torrents.

Pi connect

One way to do this by asking users to authenticate themselves before allowing them access to the transmission. To do this, first change “RPC-authentication is required” lies the “RPC-authentication is required”: the truth if necessary, and then define the password in “RPC- password “:” “[parametr19459006], the transmission of which will automatically encrypt

Now save the file and start the daemon transmission :.

$ Sudo service transmission start daemon

By default, the transmission operates at the port 9091. In this example, the complete address for the Web user interface of transmission would be 192.168.3.100 : 9091 ~~ dobj. Open your browser and head to this address.

If you include the password option, you will be asked for login credentials. The user name and password is the transfer that you specified in the configuration file.

Before you can download a torrent, you need the location of the .torrent file. Go to the web interface of the transmission and then click Open torrent. Paste the URL in the window that appears, and click Upload, to begin.

The interface is easy to navigate. By default, it shows all added torrent, but you can use the pull-down menus to view their download torrents State or trackers. When you right-click on the listed flow, it displays a context menu.

Once the flow has been downloaded, according to our configuration, it will automatically be moved to a public / highway / USB / community / download / complete directory. The easiest way to access a share in Linux is enter the address in the file manager by default. Most modern managers Linux File, such as Nautilus Gnome support Samba. Open Nautilus and press [Ctrl] + [L], to access the address bar

Now enter SMB :. distros