Home server
Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – Sharing USB disk with Samba – Part4
Now we will install SAMBA, the well known suite of programs for file and printer sharing.
We will provide a basic configuration for home users, with a share for files downloaded for example with Bittorent and home dir for each user.
Let’s install needed packages:
homeserver:~# apt-get install samba samba-common smbclient smbfs
We will configure the service later, leave the default value at the first question and answer “No” to the second.
Our configuration will be very easy, first of all remove the default configuration generated by debconf:
homeserver:~# mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
Now we will create the directory that we will use for sharing downloaded files and we will add write permission to all (remember that we mount the USB disk as /data)
homeserver:~# mkdir /data/download
homeserver:~# chmod a+w /data/download
Now let’s create a private directory for the first of our users:
homeserver:~# mkdir /data/users_shares/
Now we need to edit the configuration file for Samba /etc/samba/smb.conf.
The file was renamed a few steps above and so now it’s empty, insert the following content:
[global]
workgroup = HOME
netbios name = FILESERVER
server string = Home Fileserver %v
map to guest = Bad User
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
preferred master = No
local master = No
dns proxy = No
security = User
# Sharing for downloaded files
[download]
path = /data/download
valid users = family
read only = No
create mask = 0777
directory mask = 0777
#Home shares for users
[homes]
path = /data/users_shares/%S
comment = Home Directories
browseable = no
valid users = %S
create mask = 0700
directory mask = 0700
Now we need to restart the Samba service to apply the new configuration.
homeserver:~# /etc/init.d/samba restart
Pay attention that the valid user required for the “download” share is “family”, so we need to create it:
homeserver:~# useradd -c “Family User” family
homeserver:~# smbpasswd -a family
New SMB password:
Retype new SMB password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
Added user family.
We can now create the first user (in our example “user1″) with his own samba password:
homeserver:~# mkdir /data/users_shares/
homeserver:~# adduser
The wizard will prompt you for password and basic informations.
For example we created “user1″ and the directory “/data/users_shares/user1″
Now we need to se SMB password for the user:
homeserver:~# smbpasswd -a
New SMB password:
Retype new SMB password:
Added user
You home server is now sharing the external USB disk!
From a Windows machine in your home network you can now map shares of your home server.
This is for example the command to view available shares via Windows command prompt (cmd.exe):
C:\Users\username> net view \\IP_Home_Server
And this is the command to map the network drive “download”:
C:\Users\username> net use * \\IP_Home_Server\download
In the next post we will install Bittorrent with a Web User Interface.
Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – External USB disk mounted at boot – Part3
The Compact Flash we created is used only for the operating system and the binaries of the applications, we need some space for saving our data.
Most of PC Engines boards, like the Alix 2D2 we are using, have 2 USB 2.0 ports, perfect for managing an external USB disk!
If available a 2.5 inch external disk (for example an used notebook disk with an external case) is preferable because it’s lower power hungry and noisy respect a 3.5 disk.
This new post will describe how to format and mount an external USB disk at each boot to make available all the space we need for our data.
First of all, let’s power on our disk and plug it into a free USB port.
Now we need to identify the special device assigned to the new disk, partition and format: follow instructions in the first part of this howto.
Please remember that you want to work on the newly added USB disk, and not on the CF (hda1)
Fdisk will permanently delete all data contained in the disk, please pay attention.
Once the partition is created you can format it with ext3 filesystem with the following command:
homeserver:~# mkfs.ext3 /dev/sda1
We will use this new ext3 partition to store all downloaded and personal data.
We need a script to mount the disk at each boot of the operating system.
Let’s create a file mount_usb.sh in the directory /etc/init.d:
homeserver:~# touch /etc/init.d/mount_usb.sh
Edit it with "nano" and add the following content:
#! /bin/sh
mount -o defaults /dev/sda1 /data
We need to make this file executable and create the mount point
homeserver:~# chmod 755 /etc/init.d/mount_usb.sh
homeserver:~# mkdir /data
We can now try the script and see if the disk is correctly mounted with the command “df”:
homeserver:~# /etc/init.d/mount_usb.sh
homeserver:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 3.7G 337M 3.2G 10% /
tmpfs 125M 0 125M 0% /lib/init/rw
udev 10M 24K 10M 1% /dev
tmpfs 125M 4.0K 125M 1% /dev/shm
tmpfs 125M 0 125M 0% /tmp
tmpfs 125M 0 125M 0% /var/tmp
tmpfs 125M 24K 125M 1% /var/run
tmpfs 125M 100K 125M 1% /var/log
tmpfs 125M 0 125M 0% /var/lock
/dev/sda1 29G 173M 27G 1% /data
Everything is working correctly, we can now configure the automatic execution of this scripts at each boot.
homeserver:~# update-rc.d -f mount_usb.sh start 89 2 3 4 5 .
Now the mount_usb script is executed at boot time at each runlevel (remember the dot at the end of the command!).
But we also need to unmount the external disk when the system is powered off
Create a file umount_usb.sh always in the directory /etc/init.d:
homeserver:~# touch /etc/init.d/umount_usb.sh
homeserver:~# chmod 755 /etc/init.d/umount_usb.sh
edit it with nano and add the following content:
#! /bin/sh
umount /dev/sda1
Now we need to configure the execution the the umount_usb.sh script when the system powers off.
homeserver:~# update-rc.d -f umount_usb.sh stop 89 0 1 6 .
Now we have a lot of free space for our needs!
Debian Lenny CF Image file for Pc Engines Alix 2D2 available for download
You can download and try a ready Compact Flash image for PC Engines Alix 2D2 created following the guide described in our previous posts.
I tried this image in a live Alix 2D2 for several days without having any problem… but this image is still in Beta and may have some issues.
Alix 2D2 is shipped without RTC clock, so a NTP server is installed.
If the network connection isn’t available it can take a while for booting, don’t worry.
You will need a 4 GB Compact Flash and a CF reader, for example a USB unit.
With Linux it’s pretty simple to download a pre-built image file and writing it to a compact flash.
First of all enter the tmp directory where you will download the file.
debiandev:~# cd /tmp
debiandev:~# wget http://www.networksoul.net/wp-content/uploads/2009/08/lenny-master-ntp-alix.tar.gz
Uncompress the file:
debiandev:~# tar -xzf ./lenny-master-ntp-alix.tar.gz
If you want check the integrity of the downloaded file:
debiandev:~# md5sum -c lenny-master-ntp-alix.md5
If everything is ok the output is like this: “lenny-master-ntp-alix.image: OK”
Find the special device assigned to your CF unit:
debiandev:~# fdisk -l
…
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×000aad23
…
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5033 40427541 83 Linux
/dev/sda2 5034 5221 1510110 5 Extended
/dev/sda5 5034 5221 1510078+ 82 Linux swap / Solaris
…
Disk /dev/sdb: 4034 MB, 4034838528 bytes
255 heads, 63 sectors/track, 490 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00000000
…
Device Boot Start End Blocks Id System
For example, in my case the special device assigned to USB card reader is sdb
Now let’s write the image file into the CF with the command “dd”
debiandev:~/test-pub# dd if=/tmp/lenny-master-ntp-alix.image of=/dev/sdb
7880544+0 records in
7880544+0 records out
4034838528 bytes (4.0 GB) copied, 2167.93 s, 1.9 MB/s
Depending on the size and the speed of your card/reader.. it can took a while.
- Minimal Debian Lenny installation
- Lightweight Linux Kernel optimized for Alix/WRAP board (Voyage Linux)
- Custom kernel modules for Alix board
- Console on the serial port
- Filesystem configured to minimize write access to the CF (tmpfs)
- NTP server syncronized with nt1.ien.it
This image has Eth0 configured with the following parameters:
IP: 192.168.1.99
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DNS: OpenDNS
Openssh-server is enabled, you can manage your new server via console or SSH with:
Username: root
Password: networksoul
After having logged on, you can change the password with the command “passwd“.
After having written the CF with “dd”, you can mount the partition (for example with “mount /dev/sdb1 /mnt/cf“).
If you want to change network configuration, edit the files “/etc/network/interfaces” and “/etc/resolv.conf” to set your own IP and DNS.
For any problem or if you simply find useful our work… please leave a comment! :)
This is the download link for this pre-built image (size 247 MB):
Image file Debian Lenny with Voyage kernel for Pc Engines Alix 2DX
Setting up a Linux home server based on a low cost and low power hardware (Pc Engines Alix) – Part2
Debian is installed and our new green home server is up running but first of all we have to set a password for root.
Connected via null-modem console cable (you can use for example Putty COMx, 38400) you have to log on with user root and launch the command “passwd”.
The system is now manageable via SSH.
Now we have to do tuning to the OS for having a stable and problem-free system.
Most of Alix boards don’t have onboard clock battery, it very important to adjust time at each boot via NTP (Network Time Protocol.
Let’s install ntpdate for adjusting manually the clock:
homeserver:~# apt-get update
homeserver:~# apt-get install ntpdate
To manually adjust clock we can launch this command:
homeserver:~# ntpdate ntp1.ien.it
We are now ready for installing and configuring the ntp server and the time-sync tool adjtimex
homeserver:~# apt-get install ntp adjtimex
Let’s modify the ntp configuration file /etc/ntp.conf adding our custom ntp server below the row “#server ntp.your-provider.example” :
server ntp1.ien.it
server ntp2.ien.it
Now restart the ntp service with:
homeserver:~# /etc/init.d/ntp restart
If you have an Internet connection with dynamic IP like residential DSL you should install a Dynamic DNS client like No-ip, Dyndns etc
For expample this is the command for installing no-ip.com Linux client (remember first to register your free account in the website and add your host).
homeserver:~# apt-get install noip2
The configuration wizard is very simple.
Categories
- AskoziaPBX (6)
- cisco (1)
- Debian Lenny (6)
- general (1)
- Home server (6)
- Linux (6)
- m0n0wall (1)
- switching (1)
- voice (1)
- Voyage Linux (6)
