Senin, 26 Januari 2015

Instalasi LTSP (Linux Terminal Server Project) Thin Client

How to install LTSP (Linux Terminal Server Project) on Ubuntu Server

Overview

I've had a lot of people ask me how I achieved my thin client setup so I thought it's about time I added a guide or two! This particular guide will show you how to create thin Ubuntu Clients. Later guides will show you how to run MS Windows thin clients.
Whilst there are plenty of other LTSP guides out there on the internet they fell short of being helpful to me in 3 ways:
  • They assume your starting point is from a full-blown Ubuntu gnome desktop. Mine isn't, I'm running a headless 64bit Ubuntu Server.
  • They assume your server has two NICSs. Mine doesn't, it only has the one.
  • They assume your Ubuntu desktop/server is performing DHCP duties for your whole network. My ADSL router does that on mine.
So, if you're running a headless server with a single NIC and your router performs the DHCP duties for your network then you might find this guide helpful.
NOTE: If you're jumping into this site here then it's worth mentioning that this guide has been written for Lucid Lynx 10.04 but it may well work on earlier or later versions of Ubuntu.
TIP: If you're going to be following this guide step by step using Putty then you can save yourself some typing by simply highlighting each command below, right-clicking on it and selecting Copy. Then toggle over to your Putty Session and right-click once more. The command you've just copied from here will be automatically pasted into your Putty Session.

Give your server a Fixed IP Address

There are two ways to do this. The first way is called IP Address Reservation. Address Reservation is where you tell your router to always give your server the same IP address. The second way is what's commonly called a Static IP Address. This is where you change the settings on your server to tell the server not to obtain an IP address from your router but to instead always use the one you've hard coded. It is important that you make sure that this static IP address is outside the range issued by your router otherwise you might find you router giving this address to another device on your network. This would not be helpful!
Obviously I can't document here how to change the settings on your particular router to reserve an address for your server so I'll just cover the latter, assigning a static IP address to your server.
If you've been following my guides then you'll already have a static IP address for your server. And if you've been following ALL my guides then you'll also be running KVM which means you'll be running your NIC as a network bridge so you can omit this step in either case.
So, in a Putty session type or paste the following command:
sudo vim /etc/network/interfaces
By default your file should look like this:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
We need to edit the last two lines and add a few more. The settings you will use depend on your own network environment so you'll obviously need to use your own values rather than just paste mine! Once done your file should look like something like this. The # character masks a line out so it does not get executed:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
        address 192.168.1.200
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.254
        dns-nameservers 192.168.1.254
        dns-search home
 When you're done editing the file press the [Esc] key once and type the following:
:wq
This should save the changes and bring you back to the command line. If you make a mistake then issue :q! instead of :wq to abort your changes.

Install LTSP

Now we need to install LTSP. We do this by issuing the following command:
sudo apt-get install ltsp-server-standalone

Edit the dhcpd.conf file to suit your environment

This is probably the trickiest part to get right since the settings you use will depend on your own environment. However I'll explain what settings I changed (shown in red below) so you should be able to adjust this file to suit your network. First off, let's open the dhcpd.conf file for editing by issuing the following command:
sudo vim /etc/ltsp/dhcpd.conf
By default the file should look like this:
# Default LTSP dhcpd.conf config file.
#

authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.20 192.168.0.250;
        option domain-name "example.com";
        option domain-name-servers 192.168.0.1;
        option broadcast-address 192.168.0.255;
        option routers 192.168.0.1;
#      next-server 192.168.0.1;
#      get-lease-hostnames true;
        option subnet-mask 255.255.255.0;
        option root-path "/opt/ltsp/i386";
        if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
                filename "/ltsp/i386/pxelinux.0";
        } else {
                filename "/ltsp/i386/nbi.img";
        }
}
If you're currently viewing this guide using a Windows machine connected to your router and your machine has been assigned an IP address via DHCP then issue the ipconfig /all command in a Command Prompt to see what settings you're currently using. Alternatively you can obtain the required settings from your router interface.
Change the first three sets of numbers of the subnet to match your IP address. The IP address of the machine I'm using currently is 192.168.1.112 so I'd change the subnet value above from 192.168.0.0 to 192.168.1.0
For the range you need to make sure you set these to be outside the DHCP range dished out by your router. My router issues IP addresses from 192.168.1.64 to 192.168.1.253 so I had to firstly change my router to issue address in the range 192.168.1.64 - 192.168.1.199. I then set the range in the dhcpd.conf file to be 192.168.1.202 to 192.168.1.253 (my servers are using .200 & .201)
Set the option domain-name-servers to be the same as the IP address of your router. In my case this is 192.168.1.254. Note, this would be the value of your "DHCP Server" in the output from your ipconfig /all command.
Set the option broadcast-address so the first 3 sets of numbers are the same as the subnet setting plus the 255. So, 192.168.1.255
Set the option routers to be the same as the option domain-name-servers.
All other settings can remain the same.
Here's mine. The red indicates the values which are different from the defaults:
#
# Default LTSP dhcpd.conf config file.
#

authoritative;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.202 192.168.1.250;
        option domain-name "example.com";
        option domain-name-servers 192.168.1.254;
        option broadcast-address 192.168.1.255;
        option routers 192.168.1.254;
#        next-server 192.168.0.1;
#        get-lease-hostnames true;
        option subnet-mask 255.255.255.0;
        option root-path "/opt/ltsp/i386";
        if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
                filename "/ltsp/i386/pxelinux.0";
        } else {
                filename "/ltsp/i386/nbi.img";
        }
}
When you're done editing the file press the [Esc] key once and type the following:
:wq
This should save the changes and bring you back to the command line. If you make a mistake then issue :q! instead of :wq to abort your changes.

Restart the DHCP server on the host

We should now restart the DHCP server by issuing the following command. With any luck we'll see an [OK] to say the DHCP server successfully started:
sudo /etc/init.d/dhcp3-server restart

Build the LTSP environment and the client image

Now we're done configuring the basics let's build the LTSP environment and client image by issuing the following command. This will take some time so be patient. Note, the command will build a 32bit image. If you want to build a 64bit image (which is obviously not recommended if your thin clients don't support it) then omit the "--arch i386" from the command below:
sudo ltsp-build-client --arch i386
This will churn through for quite some time but eventually you should see info: LTSP client installation completed successfully displayed at the bottom of the screen. Now it's time to reboot the host server:
sudo reboot -h now

Time to boot up a Thin Client

Once the host server has rebooted we should now be able to boot our thin client and be presented with the Ubuntu Thin Client logon screen as shown below:
Once you've typed in your username and password you should see a black box (which is actually a Terminal session) appear at the top left corner of the login screen. This is because we've not yet installed a GUI on our LTSP server but carrying out this step does at least show that our basic setup is working properly. Type exit in the Terminal session to quit back to the login screen. Then on the login screen click on Preferences in the bottom left-hand corner of the screen and choose Shutdown.
NOTE: If you've previously followed my VNC guide then you'll be presented with the core gnome desktop rather than a Terminal Session. In which case select Log Out from the System menu before selecting the Preferences option on the Thin Client login screen to Shutdown the thin client.

How to configure LTSP (Linux Terminal Server Project) on Ubuntu Server

In the How to Install LTSP guide we covered how to install LTSP and build the basic client image. We'll now cover how to configure it by firstly installing a full-blown Ubuntu Gnome desktop.

Configure the LTSP environment

The first thing we want to do is expand the list of available package sources from the default list since they are quite limited and secondly to bring our LTSP environment up to date. So issue the following command to copy the source list from the host machine (our server) to the LTSP environment:
sudo cp /etc/apt/sources.list /opt/ltsp/i386/etc/apt/sources.list
During this process it's possible Ubuntu will try to stop and start services as it goes along so we'll prevent this from happening by issuing the following command:
export LTSP_HANDLE_DAEMONS=false
The LTSP environment lives in a separate part of Ubuntu. This means we can add and remove packages in this environment independent of the host machine. So, let's switch into this LTSP environment:
sudo chroot /opt/ltsp/i386
and mount the proc filesystem:
mount -t proc proc /proc
Now let's bring the LTSP environment up to date. Note we are omitting the normal "sudo" prefix from these commands because we're already running as root:
apt-get update
aptitude safe-upgrade
Lastly let's install an Ubuntu Desktop GUI for our LTSP clients:
apt-get install ubuntu-desktop
You might also want to install openoffice and firefox
apt-get install openoffice.org firefox flashplugin-installer

Add an admin user account

Now we have installed the Ubuntu desktop we need to set up an admin user. This is because the existing admin user on our host machine does not get transferred across to this LTSP environment. I used the same credentials for this admin user as on the one on my main server but it's not compulsory, just easier to remember!:
useradd -m adminusername -G sudo
replacing adminusername with the required name of your admin user
Now set the password for this account and type the password when prompted:
passwd adminusername
replacing adminusername with the required name of your admin user. Now add this new user to sudoers file:
visudo
Press the [Insert] key once and insert a blank line after the "%sudo ALL=(ALL) ALL" line and paste the following:
adminusername ALL=(ALL) ALL
replacing adminusername with the required name of your admin user.
When you're done editing the file press the [Esc] key once and type the following:
:wq
This should save the changes and bring you back to the command line. If you make a mistake then issue :q! instead of :wq to abort your changes.
Now exit out of chroot:
exit
And unmount the proc filesystem
sudo umount /opt/ltsp/i386/proc
Whenever you make any changes to your LTSP environment it's always a good idea to run the following commands:
sudo ltsp-update-sshkeys
sudo ltsp-update-kernels
sudo ltsp-update-image --arch i386
The first one MUST be run whenever you change any IP settings. The second one updates the kernel if required and the last one rebuilds the LTSP client image to take account of any packages you've updated.
You should now be able to launch a thin client and once logged on be presented with a full-blown Gnome desktop environment. Enjoy!



Tidak ada komentar:

Posting Komentar