Saturday, March 05, 2011

FreeBSD on my iPad -- the miracle of VNC

I posted yesterday about my attempts to get a vnc-server working in FreeBSD just as it does on all of the other OSes that I've been able to link to through the iTeleport vnc client on my iPad.
As I mentioned yesterday, I was surprised to find that I didn't see the exact Desktop I have in FreeBSD on the iPad. With KDE as WM, the icons on my Desktop showed up but NOT the google-gadgets, the gnome-panel nor the AWN dock.
But I wanted Gnome.
So, I posted to the FreeBSD forums and got some quality help which is not unusual on that forum.
To summarize what I learnt and did:

1. By simply creating a ~/.xinitrc file which contains just this line


and then modifying my ~/.vnc/xstartup file to look like this
xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
/usr/home/paul/.xinitrc &

the iTeleport client on my iPad connected (port 5901) to a Gnome session of FreeBSD.
Of course, it did NOT show the Desktop that I have on my FreeBSD computer (Dell E520) but instead displayed a completely featureless page -- no icons, no dock, no gnome-panel, nothing.
The only nthing I could get to work was the Yakuake terminal which allowed me to launch Midori and browse.
Incidentally, when the client forst opens the FreeBSD Desktop, it displays an error message
Could not acquire name on session bus

Just closing this message left a workable Desktop as I describe above. I'll talk later about some adventures I had trying to get rid of this error message

2.As the forum thread suggested, it seemed that I needed to use x11vnc as my vncserver in order to allow the iTeleport client to connect to my actual FreeBSD Desktop.
So, I deinstalled tightvnc and installed x11vnc.
First, I had to give it a password using this command on the Desktop:
x11vnc -storepasswd

which places the password in ~/.vnc/passwd.
Next, to start x11vnc, I used this command
x11vnc -rfbauth /usr/home/paul/.vnc/passwd

When I launched x11vnc with this command, iTeleport quickly connected (port 5900 this time) and I was able to see and manipulate the FreeBSD Desktop as if I was working on the other computer.

3. The fourth post in the forum thread gives a good explanation of the difference in server behaviour between Tightvnc and vncserver on the one hand and x11vnc on the other.
Tightvnc allows you to share a computer with several people where each one has his/her own session going.
x11vnc, on the other hand, allows session-sharing where all users see the very same session that's in progress on the server.
It seems that the former behaviour is the most usual for Unix systems. For this reason, I'm surprised that I had never seen it before despite having run vnc servers in OS X, Linix, Windows XP, Windows 7 and Haiku.

4. OK, I'm going to tell you what happened when I tried to eliminate the error message I mentioned in section 1 above. This post to the Ubuntu forums claims to have solved the very same error message by adding this line

to the ~/.vnc/xstartup file immediately after the line

As I didn't have this latter line in my xstartup file, I added both it and the other line to xstartup.
My experience showed that this falls into a "DON'T DO THAT" category as not only did it not work but it messed up my FreeBSD install.
First when I booted, many messages appeared in the dmesg about "kern.maxfiles limit exceeded by uid .........".
Not only that but when it eventually got to the Desktop, it proceeded at a snail's pace. CPU usage was very high and essentially nothing would open (not a terminal, not gedit).
There are many references to this error such as this but it's always best to read the Handbook.
Nevertheless, I knew the problem arose from adding those two lines to xstartup so it was just a matter of deleting them and rebooting.
Well, yes, but as I couldn't open anything, I couldn't modify this file where I was.
So, I rebooted in to single user mode, mounted the /dev/ad4s3f to /usr and proceeded to make to necessary modification using nano.
On reboot, nearly everything was normal other than the AWN dock having it's configuration changed (Flat dock rather than 3D) and Yakuake also lost its configuration and gave a First Run message on reboot.
Luckily, both were very easy to fix.

5. To get x11vnc to launch on boot, it was merely a case of adding this command to System>>Preferences>>Startup Applications:
x11vnc -rfbauth /usr/home/paul/.vnc/passwd

and then I can very easily connect from the iTeleport client.

No comments:

Post a Comment