pavement

X Windows Terminal

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
Line 436: Line 436:
 
  # cd /diskless_ro
 
  # cd /diskless_ro
 
  # ln -s /var/tmp /usr/home
 
  # ln -s /var/tmp /usr/home
p 69
+
nstallation then you have to setup the server manually like so:
</pre>
+
 
+
and you should see this:
+
<pre>
+
root      inetd      13719 5  udp4    *:69                *:*
+
</pre>
+
 
+
==NFS Setup==
+
Network File System.  Here we share all the directories from the server so that the diskless clients see these drives as if those directories were the diskless client's.
+
 
+
===Server Setup===
+
If you forgot to select 'Yes' to NFS server setup in the FreeBSD installation then you have to setup the server manually like so:
+
  
 
Enable NFS /etc/rc.conf
 
Enable NFS /etc/rc.conf

Revision as of 06:20, 4 December 2008

Contents

Advantages

X Windows can be used in a Server-Client relationship. By setting up your X Windows Server you allow the use of all the programs on that computer to all the client PC's.

There are many advantages of running client computers in this manner:

  • They don't even need a hard drive.
  • It's silent as there are no moving parts
  • The solution saves power as your computers are very thin.
  • Everything can be backed up centrally.
  • Boot times for client PC's are the fastest around.
  • Clients don't need much CPU speed, memory, etc. Because of this they would be very cheap. You could get away with using a Pentium 100Mhz with 32MB ram, no hard drive, no CD-ROM, no Floppy and a fanless power supply. You just need a ethernet card with a PXEBOOT ROM. (XDM mode)
  • Central management of applications, users, config

From the Beginning

I've based this document on FreeBSD 6.1.

Install FreeBSD 6.1 as per usual. I've setup my mount points as this:

 Part    Mount        Size
 ad0s1b  Swap         (equal to how much memory I have in my machine)
 ad0s1a  /            512MB
 ad0s1d  /var         1G
 ad0s1e  /tmp         512MB
 ad0s1f  /usr         2GB    min.
         /diskless_ro 512MB
         /diskless_rw 1GB    min.

I selected 'A' for auto and then deleted /usr and created /usr as 2g.

Select User-X install. Yes to Ports if you have the room.

Select SSH Server and NFS Server in the installation process, for the rest of the options go with the default.


NOTE: If you forget to add any of the labels above, you will have to reboot as you cannot add labels to your boot drive when you have booted off it. So boot of the installation CD and use the configure -> label option in the sysinstall screen to add these labels to your boot drive. You may need to retype the mount points for /, /var, /tmp and /usr by hitting 'm' on each label. Once you have created these labels in the 'Disklabel Editor' then you can hit 'w' to write them to the disk. answer 'yes' to the next question, hit 'ok' to the warning message. Now quit and reboot. Add them to fstab (/dev/ad0s1g /diskless_ro) & (/dev/ad0s1h /diskless_rw) and mount.

I find the best way to get this working is to break it down in to small steps and get each step working independantly. IE: Setup NFS and see if you can mount it from another FreeBSD machine, don't just assume it will work and boot your PXE-Boot machine.


Throughout my documentation

192.168.1.1 = the Server

192.168.1.2 = the client (may be a full freebsd system or pxeboot)


At this point I normally install fluxbox with the following line:

shell# pkg_add -r fluxbox-devel


change your ~/.xinitrc file to the following:

startfluxbox

Copy to .xsession

$ ln -s ~/.xinitrc ~/.xsession


Use the following command to update your fluxbox menus:

shell$ fluxbox-generate_menu

Running a single application

To get started I have my server setup running FreeBSD, with X-Windows and a few applications. Nothing too special. Then I have my client PC, which to start off I used the frenzy 1.0 boot CD to perform these initial tests. You can get this from frenzy website. I entered into fluxbox, but you could equally use any X session. You must allow incoming connections this is done with two commands

client$ startx -listen_tcp
client$ xhost +

This allows all computers to start applications on your client PC. It's dangerous but good for testing everything is setup correctly.

client$ ssh <server user@server ip>
eg: ssh mick@192.168.1.1
ssh$ export DISPLAY='192.168.1.2:0'

Or if your running bash:

ssh$ DISPLAY=<client ip>:<client display>; export DISPLAY
eg: DISPLAY=192.168.1.2:0; export DISPLAY


ssh$ xcalc &

This should display on your client

Running a whole X Windows Session (XDM)

This sets up a server so that you can share your X session with any clients which want to connect. (Simular to Terminal Services under windows)


server

edit:

/usr/X11R6/lib/X11/xdm/xdm-config

comment out with a '!' the request line

DisplayManager.requestPort: 0

edit:

/usr/X11R6/lib/X11/xdm/Xaccess

Enter a single asterisk any where in the file, so the contents should be one asterisk and the rest commented out. There should be an asterisk on line 49 which you can uncomment.

Whilst in the /usr/X11R6/lib/X11/xdm directory do these commands:

shell# vi Xstartup

Add into this file:

#!/bin/sh
#
# Xstartup
#
# This program is run as root after the user is verified
#
if [ -f /etc/nologin ]; then
   xmessage -file /etc/nologin -timeout 30 -center
   exit 1
fi
sessreg -a -l $DISPLAY -x /usr/X11R6/lib/xdm/Xservers $LOGNAME
/usr/X11R6/lib/xdm/GiveConsole
exit 0


shell# chmod +x Xstartup


Make sure your firewall has all traffic for you lan. (Need to know which exact ports to allow).


run xdm on server as root

shell# xdm


You can put this xdm into the /etc/ttys so that it starts automatically on boot up.

client

make sure your not in X

type this command:

shell# X -broadcast

This assumes that you are running only one server. Otherwise use:

shell# X -query 192.168.1.1

DHCP - Install and setup

Server setup.

install through package

# pkg_add -r isc-dhcp3-server

We do this so we can define the root path for the diskless system.

copy /usr/local/etc/dhcpd.conf.sample to /usr/local/etc/dhcpd.conf

edit /usr/local/etc/dhcpd.conf and make sure it has these lines in it.

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 3600;
max-lease-time 86400;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# ad-hoc DNS update scheme - set to "none" to disable dynamic DNS updates.
ddns-update-style none;

option root-path "192.168.1.1:/diskless_ro";

# lines added for pxeboot client
use-host-decl-names on;
next-server 192.168.1.1;
filename "pxeboot";

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.


# This is a very basic subnet declaration.

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.10 192.168.1.20;
}

Create the leases file

# touch /var/db/dhcpd.leases


Restart the daemon

# killall dhcpd
# dhcpd


Add to /etc/rc.conf

dhcpd_enable="YES"

Using a seperate DHCP server

If you already have a DHCP server and you want to use that instead then you have to do these steps.


On your DHCP Server

1. edit /usr/local/etc/dhcpd.conf and add the following

authoritative;
ddns-update-style none;

option root-path "<X Server IP>:/diskless_ro";

# lines added for pxeboot client
use-host-decl-names on;
next-server <X Server IP>;
filename "pxeboot";

restart dhcpd

# /usr/local/etc/rc.d/isc-dhcpd.sh restart

Client

Your client should boot now just remember that you may get a different IP now that you are talking to a different DHCP server so you have to change your exports file and copy accross a directory in /diskless_rw for the new IP. All this is done on the X Server.

TFTP Setup

TFTP helps us transport the kernel to the PXE-Boot machines.

# mkdir /tftpboot
# cp /boot/pxeboot /tftpboot

Uncomment the following line in /etc/inetd.conf

tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /tftpboot

Restart the inetd service

# killall -HUP inetd

If inetd has not started automatically do the following:

Add the following to /etc/rc.conf

inetd_enable="YES"

Now start inetd manually.

# inetd

Test

To test that tftp has loaded type the following:

# sockstat -4l | grep 69 

and you should see this:

root      inetd       13719 5   udp4    *:69                 *:*

NFS Setup

Network File System. Here we share all the directories from the server so that the diskless clients see these drives as if those directories were the diskless client's.

Server Setup

If you forgot to select 'Yes' to NFS server setup in the FreeBSD installation then you have to setup the server manually like so:

Enable NFS /etc/rc.conf

rpcbind_enable="YES"
nfs_server_enable="YES"

Test

A quick test to see if your NFS server is acting normal:

Edit the /etc/exports and add the following

/usr       -alldirs

This allows anyone to connect to your /usr mount.

Now run these commands to restart and view your mounts

# kill -HUP `cat /var/run/mountd.pid`
# showmount -e

Now try and mount it from a client running BSD

# mount -t nfs 192.168.1.1:/usr /mnt


Server exports setup

Make directories for each IP for your clients

# cd /diskless_rw
# mkdir 192.168.1.2
# cd 192.168.1.2
# mkdir etc var

Configure /etc/exports

# file systems accessible only for reading:
# Original way of linking up the /usr
#/usr -ro -maproot=0 -network 192.168.1.0 -mask 255.255.255.0

/usr -network 192.168.1.0 -mask 255.255.255.0
/diskless_ro -ro -maproot=0 -network 192.168.1.0 -mask 255.255.255.0
/diskless_rw/192.168.1.2/etc /diskless_rw/192.168.1.2/var -maproot=root 192.168.1.2

Restarting NFS

# kill -HUP `cat /var/run/mountd.pid`


If NFS is not started yet do the following:

data# rpcbind
data# nfsd -u -t -n 20 -h 192.168.1.1
data# mountd -r

Testing to see if the exports are correct

data# showmount -e
Exports list on localhost:
/usr                              192.168.1.0
/diskless_rw/192.168.1.2/var      192.168.1.2
/diskless_rw/192.168.1.2/etc      192.168.1.2
/diskless_ro                      192.168.1.0

Setup diskless_rw

Create directories

# cd /diskless_rw/192.168.1.2/etc
# mkdir pam.d X11

# cd /diskless_rw/192.168.1.2/var
# mkdir home log run tmp
# chmod 1777 tmp

Create a swap file in the var directory for the client

# dd if=/dev/zero of=/diskless_rw/192.168.1.2/var/swap bs=1k count=32000

in the /diskless_rw/<ip>/var/log directory I created the following log files so that syslogd would have files to write to:

# cd /diskless_rw/192.168.1.2/var/log
# touch messages security auth.log maillog lpd-errs xferlog cron debug.log slip.log ppp.log


Copy the following files from the systems /etc directory to /diskless_rw/<client ip>/etc

# cp -Rv <files> /diskless_rw/<ip>/etc
auth.conf
disktab
gettytab
group
hosts
login.access
login.conf
login.conf.db
motd
master.passwd
netconfig
protocols
pam.d
pwd.db
services8
spwd.db
syslog.conf
termcap -> /usr/share/misc/termcap
ttys

Here is a shortcut which you can just copy and paste in an xterm window.

# cd /etc
# cp -Rv auth.conf disktab gettytab group hosts login.access login.conf login.conf.db master.passwd motd netconfig protocols pam.d pwd.db services spwd.db syslog.conf termcap ttys /diskless_rw/<ip>/etc

It's very important that you copy all the files in pam.d across otherwise you will not have a password prompt on your login.

Create a fstab in /diskless_rw/<ip>/etc

# touch /diskless_rw/<ip>/etc/fstab

Setup diskless_ro

This is the common root mount for all pxe-boot clients.

Copy accross important directories and kernel from boot to diskless_ro

# cp -rv /bin /lib /libexec /sbin /boot /diskless_ro

For some client machines you may have to disable the ACPI (Power management) in the /diskless_ro/boot/device.hints

hint.acpi.0.disabled="1" 

So we can use the systems /var/tmp and /usr/home directory make soft links to them

# cd /diskless_ro
# ln -s /var/tmp /usr/home

nstallation then you have to setup the server manually like so:

Enable NFS /etc/rc.conf

rpcbind_enable="YES"
nfs_server_enable="YES"

Test

A quick test to see if your NFS server is acting normal:

Edit the /etc/exports and add the following

/usr       -alldirs

This allows anyone to connect to your /usr mount.

Now run these commands to restart and view your mounts

# kill -HUP `cat /var/run/mountd.pid`
# showmount -e

Now try and mount it from a client running BSD

# mount -t nfs 192.168.1.1:/usr /mnt


Server exports setup

Make directories for each IP for your clients

# cd /diskless_rw
# mkdir 192.168.1.2
# cd 192.168.1.2
# mkdir etc var

Configure /etc/exports

# file systems accessible only for reading:
# Original way of linking up the /usr
#/usr -ro -maproot=0 -network 192.168.1.0 -mask 255.255.255.0

/usr -network 192.168.1.0 -mask 255.255.255.0
/diskless_ro -ro -maproot=0 -network 192.168.1.0 -mask 255.255.255.0
/diskless_rw/192.168.1.2/etc /diskless_rw/192.168.1.2/var -maproot=root 192.168.1.2

Restarting NFS

# kill -HUP `cat /var/run/mountd.pid`


If NFS is not started yet do the following:

data# rpcbind
data# nfsd -u -t -n 20 -h 192.168.1.1
data# mountd -r

Testing to see if the exports are correct

data# showmount -e
Exports list on localhost:
/usr                              192.168.1.0
/diskless_rw/192.168.1.2/var      192.168.1.2
/diskless_rw/192.168.1.2/etc      192.168.1.2
/diskless_ro                      192.168.1.0

Setup diskless_rw

Create directories

# cd /diskless_rw/192.168.1.2/etc
# mkdir pam.d X11

# cd /diskless_rw/192.168.1.2/var
# mkdir home log run tmp
# chmod 1777 tmp

Create a swap file in the var directory for the client

# dd if=/dev/zero of=/diskless_rw/192.168.1.2/var/swap bs=1k count=32000

in the /diskless_rw/<ip>/var/log directory I created the following log files so that syslogd would have files to write to:

# cd /diskless_rw/192.168.1.2/var/log
# touch messages security auth.log maillog lpd-errs xferlog cron debug.log slip.log ppp.log


Copy the following files from the systems /etc directory to /diskless_rw/<client ip>/etc

# cp -Rv <files> /diskless_rw/<ip>/etc
auth.conf
disktab
gettytab
group
hosts
login.access
login.conf
login.conf.db
motd
master.passwd
netconfig
protocols
pam.d
pwd.db
services8
spwd.db
syslog.conf
termcap -> /usr/share/misc/termcap
ttys

Here is a shortcut which you can just copy and paste in an xterm window.

# cd /etc
# cp -Rv auth.conf disktab gettytab group hosts login.access login.conf login.conf.db master.passwd motd netconfig protocols pam.d pwd.db services spwd.db syslog.conf termcap ttys /diskless_rw/<ip>/etc

It's very important that you copy all the files in pam.d across otherwise you will not have a password prompt on your login.

Create a fstab in /diskless_rw/<ip>/etc

# touch /diskless_rw/<ip>/etc/fstab

Setup diskless_ro

This is the common root mount for all pxe-boot clients.

Copy accross important directories and kernel from boot to diskless_ro

# cp -rv /bin /lib /libexec /sbin /boot /diskless_ro

For some client machines you may have to disable the ACPI (Power management) in the /diskless_ro/boot/device.hints

hint.acpi.0.disabled="1" 

So we can use the systems /var/tmp and /usr/home directory make soft links to them

# cd /diskless_ro
# ln -s /var/tmp /usr/home
Personal tools