Basically, it would be a vmware virtual machine.

Why freebsd? Just for fun 🙂 And I have a hope to save some RAM on my home-lab vmware host.

Let’s start..

FreeBSD 11 Installation
1. Download FreeBSD pre-cooked vmdk here:
https://download.freebsd.org/ftp/releases/VM-IMAGES/11.0-RELEASE/amd64/Latest/

Un-xz it with 7zip.

2. Create new Freebsd VM and add unpacked vmdk as an existing hard drive.

3. Power on the VM.

FreeBSD Initial Configuration
1. Add root password.
root@:~ # passwd
Changing local password for root
New Password:
Retype New Password:
root@:~ #

3. Add IP
ifconfig em0 192.168.1.100/24

4. Permit root login
vi /etc/ssh/sshd_config
Find and uncomment this string:
PermitRootLogin yes

5. Start SSHd
service sshd onestart

Now you should be able to login through SSH.

FreeBSD Configuration
1. Create new file /etc/rc.conf
vi /etc/rc.conf

And add this:
hostname="server.yudin.us"
ifconfig_em0="inet 192.168.1.100 netmask 255.255.255.0" #interface config
defaultrouter="192.168.1.1" #gateway
sshd_enable="YES" #enabling sshd autostart
ifconfig_em0_ipv6="inet6 accept_rtadv" #enabling ipv6
rtsold_enable="YES" #enabling ipv6

2. Add DNS servers
vi /etc/resolv.conf
nameserver 192.168.1.1

2. Update and upgrade.
freebsd-update fetch
freebsd-update install
pkg update && pkg upgrade

3. Install vmware tools.
FreeBSD 11 seems to be not supported by vmware tools so that I’ve istalled Open VM Tools;
pkg install open-vm-tools-nox11

To run the Open Virtual Machine tools at startup, you must add the following settings to your /etc/rc.conf

vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="NO"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"

Open VM tools is set of four kernel modules (vmemctl, vmxnet, vmblock, vmhgfs) and one daemon (guestd).

vmemctl is driver for memory ballooning
vmxnet is paravirtualized network driver
vmhgfs is the driver that allows the shared files feature of VMware Workstation and other products that use it. This is not optimal to use on server therefore we do not enable it.
vmblock is block filesystem driver to provide drag-and-drop functionality from the remote console.
VMware Guest Daemon (guestd) is the daemon for controlling communication between the guest and the host including time synchronization.

Reboot your system.
reboot

Installing SAMBA and Transmission

1. Configure timezone and setup time autosync
cp /usr/share/zoneinfo/Europe/Kaliningrad /etc/localtime; ntpdate 0.freebsd.pool.ntp.org;
echo '0 0 * * * /usr/sbin/ntpdate 0.freebsd.pool.ntp.org' >> /var/cron/tabs/crontab && crontab /var/cron/tabs/crontab

2. Add ports collection to your system
# portsnap fetch
# portsnap extract

3. Install “screen” terminal manager.
cd /usr/ports/sysutils/screen/ && make install clean

4. Optimize compiler for the best performance.
Create /etc/make.conf
CPUTYPE?=core2
CFLAGS= -O3 -pipe -funroll-loops
COPTFLAGS= -O2 -pipe -funroll-loops
NO_PROFILE=true
BUILD_OPTIMIZED=YES
BUILD_STATIC=YES
WITHOUT_DEBUG=YES
#turn off graphic for server
WITHOUT_X11=YES
WITHOUT_FONTCONFIG=YES

5. Create screen session and start samba installation
screen
cd /usr/ports/net/samba46/ && make -DBATCH install clean

*screen will save your terminal session so that you could reconnect to it anytime by typing screen -r
**-DBATCH will tell the ports system that you are “batch-builing” ports and won’t be hanging around to answer config questions. It will use the default options for any ports that need configuring.

6. Add SAMBA to autostart
echo 'samba_server_enable="YES"' >> /etc/rc.conf

7. Start transmission torrent client installation
cd /usr/ports/net-p2p/transmission/ && make -DBATCH install clean

6. Add transmission to autostart
echo 'transmission_enable="YES"' >> /etc/rc.conf

Configuring SAMBA and Transmission

1. Add SAMBA config

vi /usr/local/etc/smb4.conf
[global]
workgroup = WORKGROUP
server string = Samba Server
log file = /var/log/samba4/log.%m
max log size = 500
socket options = TCP_NODELAY
os level = 1
map to guest = Bad Password
[DATA]
comment = Public Folder
path = /data
public = yes
writable = yes
guest ok yes
read only = no
create mask = 0777
directory mask = 0777

2. Make data dir
mkdir /data && chmod 777 /data

3. Start SAMBA
service samba_server start

Now you can try it:

4. Configure Transmission
Edit the configuration:

vi /usr/local/etc/transmission/home/settings.json
"rpc-bind-address": "192.168.1.100",
"rpc-whitelist-enabled": false,
"download-dir": "/data",

5. Start it
service transmission start

Now you can access it through web interface by typing http://192.168.1.100:9091 in your browser: