This is how I run my Tvheadend Server on Debian Stretch on a Windows 10 Hyper-V virtual machine.
I write how I have done it and the choices I have made, not every choice you can make.
This may be useful if you like my are not to comfortable with *nix systems, however if you are and you find something in here that is not good or correct, please let me know.
Before you start doing things, read trough it as there are some useful info at the end about checkpoints (snapshots).
* The steps are these:
* Create Hyper-V Guest
* Install Debian
* Config Debian
* Install Tvheadend
* Add recordings to Windows PC
* Info about checkpoints (snapshots) import/export (backup)
Create a machine in Hyper-V as a gen 2 guest, disable secure boot.
The disk size I set as dynamic expanding end a maximum size of 20GB, this leaves enough space for transcoding timeshift ans some local recordings,
larger and longer recordings are stored on a Windows machine containing all my other mediafiles.
Start the machine and stop it, assign it a static mac adress under network adapter advanced features.
Start it and install Debian, DO NOT set a root password and enable ssh and standar utilities at the end of the guide.
I place all my stuff on one partition when it asks for partitioning.
When the setup is done connect to it using SSH and do these steps for configuration.
Enable the NOOP scheduler, using the following commands:
sudo sed -i '/GRUB_CMDLINE_LINUX_DEFAULT/ s/^\(.*\)\("\)/\1 elevator=noop\2/' /etc/default/grub
sudo update-grub
sudo reboot
After reboot make sure brackets have moved from cfq to noop:
cat /sys/block/sda/queue/scheduler
More info: http://www.lowefamily.com.au/2016/08/05/how-to-run-debian-on-hyper-v/4/#performance-optimisation
Some stuff to make Debian run nicer under Hyper-V
sudo apt-get install hyperv-daemons
sudo echo "" >> /etc/initramfs-tools/modules
sudo echo "# Hyper-V Modules" >> /etc/initramfs-tools/modules
sudo echo "hv_vmbus" >> /etc/initramfs-tools/modules
sudo echo "hv_storvsc" >> /etc/initramfs-tools/modules
sudo echo "hv_blkvsc" >> /etc/initramfs-tools/modules
sudo echo "hv_netvsc" >> /etc/initramfs-tools/modules
sudo echo "hv_balloon" >> /etc/initramfs-tools/modules
sudo echo "hv_utils" >> /etc/initramfs-tools/modules
sudo update-initramfs -u
sudo reboot
Set a static IP:
Change to this (if your network is different yous your own stuff):
sudo nano /etc/network/interfaces
And paste this:
auto eth0
iface eth0 inet static
address 192.168.1.9
netmask 255.255.255.0
gateway 192.168.1.1
To save: ctrl+o (enter)
To exit: ctrl+x
DNS servers:
(if your network is different yous your own stuff)
sudo nano /etc/resolv.conf
domain workgroup
search workgroup
nameserver 192.168.1.1
nameserver 192.168.1.1
To save: ctrl+o (enter)
To exit: ctrl+x
If you want to disable IPv6, paste this at the very bottom of the file (this is optional)
sudo nano /etc/sysctl.conf
#Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
To save: ctrl+o (enter)
To exit: ctrl+x
sudo reboot
This installs latest stabel TVH, look at documentation if you want something else
sudo apt-get -y install coreutils wget apt-transport-https lsb-release ca-certificates
sudo wget -qO- https://doozer.io/keys/tvheadend/tvheadend/pgp | sudo apt-key add -
sudo sh -c 'echo "deb https://apt.tvheadend.org/stable stretch main" | tee -a /etc/apt/sources.list.d/tvheadend.list'
sudo apt-get update
sudo apt-get install tvheadend
And from there it is just like installing tvh on anything and configure it.
As I wrote above I use a Windows machine to store all larger recordings, its a Win10 called mypc and have ip 192.168.1.2 with a share called recordedtv, ther is a local user on it called kodi with the passwork kodi and this user have full permissions on the share and folder on the machine.
I dont want this to be permanently attachaed - so the solution is autofs.
To add recordings to my Windows machine here is how:
sudo apt-get install cifs-utils autofs
sudo mkdir /mnt/mypc
sudo chmod 7777 /mnt/mypc
Add this at the bottom of the file and comment the line +auto.master and paste the info
sudo nano /etc/auto.master
#+auto.master
/mnt/mypc /etc/auto.mypc --timeout=60 --ghost
To save: ctrl+o (enter)
To exit: ctrl+x
sudo id hts
Replace uid and gid with what the user hts have on you system and then paste the line
sudo nano /etc/auto.mypc
recordedtv -fstype=cifs,rw,username=kodi,password=kodi,uid=107,gid=111 ://192.168.1.2/recordedtv
To save: ctrl+o (enter)
To exit: ctrl+x
Restart it:
sudo /etc/init.d/autofs restart
In TVH webgui enter this as recordingpath to store recordings on you Win PC:
/mnt/mypc/recordedtv
General info...
So now you have a TVH server that is up and running, but if you are like me and feel a bit worried whenever you make changes to it and have no or a very basic understanding of how the machine works and how to troubleshoot it if you make a bad choice or if your hard drive explode... let's use checkpoints and import/export as a backup. Also, during this setup you can use checkpoints anywhere before making any of the changes I suggest, much easier that starting over every time :)
Checkpoint, this is useful if you want to make a small change and you are unsure if it is a good or bad choice. Before you do that change create a checkpoint. If the choice was bad and you want to go back to the way things where just apply the checkpoint, if things where good then just delete the checkpoint. There are great guides and documentation so just google how to use it. It is however very important to NOT leave the checkpoints a long time, a few days are just fine but always try to delete them as soon as you can after creating one.
For longer and regular backups use import and export. You can do this trough the GUI or Powershell, I have created a scheduled task that export my Tvheadend server once a month so that I have a backup of it on a regular interval if i break it or the disk breaks.
I hope you find this guide and info useful :)