Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General > Member Success Stories
User Name
Password Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.


  Search this Thread
Old 01-16-2020, 11:20 AM   #1
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 412

Rep: Reputation: Disabled
LTSP @ Home. Yes it's useful.

A few years ago when I started looking into setting up a central media center in my home I wanted to do something different. Something no one else does, at least that I've seen. I found my answer in the LTSP project.

LTSP is basically a package that supplies scripts that automate the creation of a pxe bootable image. This image can contain anything you want, similar to a regular bare metal installation. Working with it is no different than working with a chroot. I decided to pxe boot media centers.

I started with just 1 machine, mainly to see how it went. Started my media collection, currently > 1050 dvds + tv series in the garage, all ripped into the server. A bit of trial and error and I had it working. A fully functional Kodi frontend pxe booting off of my server.

Over time I've refined how I have it run and I'm currently up to 3 pxe boot machines. 1 in our master bedroom, one in the living room, and one in the guest room. All 3 are used frequently. I've added a MythTV backend so it is a full featured media center for us. The living room also doubles as the wife's computer and can be switched to Ubuntu by simply exiting Kodi. Due to a head injury she is not supposed to sit to close to a computer screen. 10 feet away from a 55" flat screen is just fine though. Wireless keyboard and mouse and we are in business.

Recently my wife and I got back into Minecraft, literally 2 days ago. In my current setup as I had all but quit using my desktop, it had become my server. I use my laptop for most things these days. However the server / desktop had the horsepower for Minecraft and that was my choice. Sadly I hit a bit of a wall. Occasionally my fps would plummet to 1 or 2. Reason after looking at top? Maxed out the cpu usage. Looking at the processes it was a combination of the minecraft server itself + my client to play the game. The machine isn't exactly new, i5 3470 quad core. A few years old. But I've got a Radeon RX570 in it so it does well enough.

What to do? I pondered getting another machine for a server to offload the minecraft servers mainly. Not doing well at the moment financially so that was an absolute last resort. Looking at what I already had in play I came up with something I never considered before. And I used LTSP to do it.

One of my media centers in the bedrooms had a decent AM1 quad core with 8gb of ram in it. More than enough for 2 people to play Minecraft on at the same time. But it was pxe booted. Google to the rescue.

First I created a user in the LTSP chroot and gave it a hidden /home directory. I gave this user a uid / gid of 10000 so there would be no possibility of conflicts. Then I needed 2 systemd service files to run the servers. The first to create the non privileged user's crontab on boot. Simple enough, script the command and call the script from the systemd service. The other service would be variable and be able to enable any minecraft server with mcstart@?.service. SSH access to the clients is required. I use a root ssh then just su as needed. This is done by getting your ssh authorized_keys file into the chroot /root/.ssh folder and install ssh to the chroot. You also need the openjdk headless and screen. Rebuild the chroot.

The minecraft worlds folder is on my nfs server and mounted only to this specific machine via the lts.conf.

Once all this is done it should just work. I had to piddle around a bit as I'm not that good with systemd. Several image rebuilds before I got it right.

As I already had existing worlds I didn't need to do anything, they just came up. The service would fail to start though without accepting the EULA file in the world directory. Once that is done just restart the service for the world. As far as the other machines that share the image, the services just fail to start as the directory isn't mounted. Doesn't seem to be an issue.

Done and done. As it sits I now have a PXE booted machine in the guest room running my 3 minecraft servers with plenty of headroom. At a max of 2 players at a time it is more than enough muscle, barring a major TNT stunt.

My Config Files


        LDM_DIRECTX = "true"
        RCFILE_01 = "/etc/ltsp/crontabs"
        KEEP_SYSTEM_SERVICES = "ssh cups"
        CRONTAB_01 = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
        CRONTAB_02 = "USER=root"
        CRONTAB_03 = "00 00 * * 7       echo 3 > /proc/sys/vm/drop_caches"
        CRONTAB_04 = "00 00 * * 7       swapoff -a && /sbin/swapon -a"
        FSTAB_0 = "megalith.mylan.home:/snapraid/pool /snapraid/pool nfs defaults,noauto,x-systemd.automount,x-systemd.idle-timeout=30 0 0"
#       this line is for debian & ubuntu 18.04
        INIT_COMMAND_RM_NBD_CHECKUPDATE = "rm -rf /usr/share/ldm/rc.d/I01-nbd-checkupdate"
        CUPS_SERVER = "print.mylan.home"

        LDM_GUEST_LOGIN = "true"
        LDM_LOGIN_TIMEOUT = "10"
        LDM_SESSION = "openbox"
        LDM_PASSWORD = "1981"

# mom and dad living room kodi set to autologin

        KEEP_SYSTEM_SERVICES = "ssh cups mcstart"
        LIKE = "media"
        LDM_USERNAME = "kodimomdad"
        HOSTNAME = "kodimomdad"
#       FSTAB_1 = "tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=1G 0 0"
        FSTAB_2 = "megalith.mylan.home:/minecraftservers /minecraftservers nfs defaults,noauto,x-systemd.automount,x-systemd.idle-timeout=30 0 0"

# living room kodi / desktop set to autologin to kodi

        LIKE = "media"
        LDM_USERNAME = "kodimain"
        HOSTNAME = "kodimain"
server start service

Description = Launches Minecraft Servers
After =

WorkingDirectory = /minecraftservers/gameworlds/%i
Type = forking
User = mcserver
Group = mcserver
ExecStart = /usr/bin/screen -dmS %i /usr/bin/java -jar /minecraftservers/server.jar nogui
ExecStop = /usr/local/bin/mcstop %i

WantedBy =
unprivileged user to load crontab service

Description = Set crontab for mcserver user
After =

Type = oneshot
ExecStart = /usr/local/bin/mcservercrontab

and script this calls.

main_minecraft_user_crontab() {
00 */3 * * *	mcbackup world1 world2" | su -c "crontab" "$MCSERVERUSR"
*EDIT* Decided to share my minecraft script as well. It is heavily modified from an old init script I found a few years ago. Can't recall where.

main_minecraft_server_controller() {
	mc_backups() {
		screen -p 0 -S "$1" -X eval 'stuff "save off"\015'
		screen -p 0 -S "$server" -X eval \
		"stuff \"say server backup started. going read only.\"\015"
		screen -p 0 -S "$1" -X eval 'stuff "save-all"\015'
		sleep 10
		if [[ -e "$WORLDDIR"/"$1"/.ramdisk ]] ; then
			rsync -auv --progress /ramdisk/gameworlds/"$1"/* "$WORLDDIR"/"$1"/
		case $(date +%I%M) in
				tar -czf /tmp/"$1"."$NOW".tar.gz "$WORLDDIR"/"$1"/*
				rsync -auv --progress /tmp/"$1"."$NOW".tar.gz \
				rm /tmp/"$1"."$NOW".tar.gz
		screen -p 0 -S "$1" -X eval 'stuff "save-on"\015'
		screen -p 0 -S "$server" -X eval \
		"stuff \"say server backup completed. going read/write.\"\015"
	if [[ "$USER" == "$MCSERVERUSR" ]] ; then
		for server in "$@" ; do
			case "$SCRIPTCALL" in
					mc_backups "$server"
					for seconds in 15 10 5 ; do
						screen -p 0 -S "$server" -X eval \
						"stuff \"say server stopping in ${seconds} seconds.\"\015"
						sleep 5
					screen -p 0 -S "$server" -X eval 'stuff "stop"\015'
					sleep 10
					mc_backups "$server"
					echo "${server} is running!"
*EDIT* A few refinements. Running ramdisked now with backups every 10 minutes to the server. World generation was good, but the very occasional stutter. Ramdisk on the server and it is so silky smooth no matter how much i cruise around on a horse or boat. Also added Conditionals on my systemd services so they don't propagate to the other machines

ConditionHost = "kodigst"

Last edited by jmgibson1981; 01-16-2020 at 02:25 PM.
Old 01-18-2020, 12:00 AM   #2
LQ Newbie
Registered: Jul 2018
Posts: 1

Rep: Reputation: Disabled
Quite a nice setup, and a really good read. thanks for that.
Old 01-20-2020, 08:09 AM   #3
Registered: Sep 2018
Location: Missouri
Distribution: Ubuntu 18.04 Bionic Beaver & Linux Mint 19.1 Tessa
Posts: 864
Blog Entries: 1

Rep: Reputation: 82
Thanks for the detailed information concerning setting up, in Linux, a central media center with LTSP.

I was not familiar with the LTSP project so I did an internet search and learned more about it. Here is the link that was helpful to me:

Again, thanks for the detailed information.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Have "did you find this post useful? [yes]" links been removed from LQ? Why? dedec0 LQ Suggestions & Feedback 9 08-07-2018 09:27 AM
Compiling driver for LTSP 2.4.26-ltsp-2 ardian Linux - Software 2 10-21-2005 02:40 AM
3D acceleration YES YES YES glxgears results props666999 Slackware 44 07-29-2005 09:40 PM
Yes Yes Yes! I Got Sound! shazam75 Member Success Stories 2 10-14-2004 05:11 AM
Midi: yes, Mix: yes, Wav: NO J_Szucs Linux - Newbie 1 11-05-2001 09:15 AM > Forums > Linux Forums > Linux - General > Member Success Stories

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration