Linux on a USB stick on a thin client

I am installing Debian on a USB stick that will be permanently attached to a Futro X913-T thin client. It will provide the OS of the client.

1. I booted the Debian installer (I used a USB CDROM drive I happen to have, but you could boot from a USB stick).

2. Partitioning, I partition a 16 GB usb stick (sdb) with 3GB swap (the machine has 2GB RAM, so this should allow hibernation by writing the RAM to swap space), the rest as / except I left a few 10s of MB at the front of the drive free. This just seems like a good idea when you want to write a bootable USB. I'm probably wrong! But it does not hurt.

3. Went through install as per normal, installed grub to sdb (sda is the build-in 1GB mSATA drive of the client. It is too small to install Debian on, but currently has SliTaz on it, which the Debian install of GRUB found.)

4. Installed nothing beyond the minimum — unchecked everything when it asked me what software I wanted to install.

5. Modified BIOS settings to boot sdb by default. Since GRUB found SliTaz, I can boot either Debian or SliTaz from GRUB.

On a bare install of Debian — that is, I used the default installer, nothing clever, but unchecked everything when it asked me what I wanted to install, I still fill up nearly 800 MB of disk space. Fat! Then I went to install a display/login manager.

# apt install NAME

Here are the download sizes:

NAME Size (MB)
gdm3    342
sddm    105
lightdm  96
xdm      36
wdm     101
slim     28

So slim it is!

Then flwm and links and xinit and x11-apps; between xinit, flwm and slim, Debian pulls in all the software needed to get a fairly basic but working Xorg system up and running.

Can login to a regular user account and try:

$ startx

Can also reboot and see if the graphical login happens.

startx works, but I get very low resolution screen.

And we are already at 1.1 GB of disk space. Used…

OK, install hwinfo.

hwinfo says video card is Model: “ATI Wrestler [Radeon HD 6250]”

Maybe this is not installed?

# apt search radeon

shows most of it is installed but not all…

# apt install firmware-amd-graphics

This updates the initrd, so we reboot.

Yes, and now we have full resolution.

Good.

What about getting the touchscreen to work? Also, the HID sensor is not working. (Jobs for later. I don’t need them anyway.)

And, bite the bullet, install the 100MB of Firefox and dependencies. A full-on browser is kind of necessary these days. That way the machine is usable standalone for a few tasks. Since it is just on my home LAN, I don’t need to worry about proper remote desktop, I can just use ssh -Y.

Other packages needed included: ssh, wget, curl,,gv, xpdf, poppler-utils, xfig, cups, foomatic-db-compressed-ppds, hpijs-ppds printer-driver-hpijs

OK!

Right so in summary:

Minimal Debian installed on a USB, then added packages I actually wanted.

just use X11 forwarding to log into my desktop box

$ ssh -X -C username@machine

(with X11 forwarding enabled on the desktop box.)

The thin client is quite usable on its own for small tasks, especially because I am not running a full DE, just flwm (and sometimes XFCE), which is my favorite compromise between lightness and simplicity of use.

Sound needed some firmware, but then mpg123 etc all worked fine.

But now we have:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb2 12G 2.6G 8.1G 24% /

But I have kind of given up on being overly efficient, in the interests of productivity.

Probably was not worth attempting the minimal install.

Now, to use as intended. The basic idea is that the desktop machine (server, or host) should sit there, asleep most of the time. I can wake it up to use locally of course, but I want to wake it up from elsewhere on the LAN, use it and put it back to sleep.

(1) On my big desktop, make sure that X11 forwarding, etc, is enabled in /etc/ssh/sshd_config:

X11Forwarding yes

(2) My big desktop is also set up for wake on LAN (WOL)

(3) Now, I had an issue that I could not SSH in from outside unless I was logged in locally. That’s ok unless I have to reboot remotely. The problem is that my .ssh folder is not visible to the external session. You can look here if that is an issue:

https://help.ubuntu.com/community/SSH/OpenSSH/Keys
https://superuser.com/questions/889615/cant-ssh-into-remote-server-unless-i-login-locally-on-the-server-first

This fixes it.

If the remote reboot/halt is unlikely, another option is just to logon locally, say on TTY5 (Ctrl+Alt+F5) then run vlock and leave it forever.

(3) Now, you want to be able to make the desktop machine go back to sleep after you’re done. If you are superuser you can use pm-suspend. Some suspends (hibernations…) seem to be immune to WOL, so do a few tests.

I don’t know about using only user credentials. Maybe this, but don’t hold me to it: Run visudo and add these lines on the server/host.

username ALL=NOPASSWD: /usr/bin/systemctl suspend
username ALL=NOPASSWD: /usr/bin/systemctl hibernate

These still seem to need a user password (to send a wall message), but not sudo or root password.

(4) So now with the server pm-suspended I can sit down at my thin client and run:

$ wakeonlan aa:bb:cc:dd:ee:11

Where aa:bb:cc:dd:ee:11 is the MAC address of the server. (Run ifconfig on the server to get the details.)

(5) Then:

$ ssh -C -X username@192.168.5.55

Where 192.168.5.55 is the IP address of my server.

(6) Get my work done. If I want to basically get the MATE desktop I use locally on the serer, I can type

$ mate-panel &

and then just foreground and kill it when I am done. Usually, I just run the applications I want from the CLI; (often this is a Windows VM, running in VirtualBox on my server). For example, I might type:

$ VBoxManage startvm "Win7_32bit" &

To start the VM. So, my thin client is a window on to 2 computers: mate-panel effectively gives me a Linux desktop computer, and full screening the VM gives me a Windows.

None of this is very complicated, and a few web searches soon show up the needed details, which may vary from distro to distro… Step-by-step it is:

(1) Set the server up for WOL.
(2) Set the server up for X11 forwarding.
(3) Set the server up to allow external login without a local active session (or just install vlock and login locally and lock the terminal).
(4) Install wakeonlan on the client.
(5) If the server is asleep, run wakeonlan to wake it up.
(6) SSH into the server from the client, possibly using -C compression unless your network is nice and fast.
(7) In my case, mate-panel gives me my Linux desktop (you might not use MATE).
(8) And/or I just run applications as needed.
(9) Rather than logging out, at the end I shut down all my applications and sudo pm-suspend (or use another method to suspend it).
(10) Close the terminal program on the client.

Now, you may find tools like screen and tmux handy — they let you detach from a session (or sessions) on the server, logout and then reattach later when you log back in. In that case, you would detach before suspending.

bash aliases are your friend. In .bashrc (or wherever), something like this on the client:

alias wolmyserv="wakeonlan aa:bb:cc:dd:ee:11"
alias sshmyserv="ssh -C -X username@192.168.5.55"

And on the server:

alias mysuspend='sudo pm-suspend'
alias win7='VBoxManage startvm "Win7_32bit"'

Or whatever.

Author: Darren

I'm a scientist by training, currently working as a writer, trainer and editor.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.