Overview

Okay, I’m going to fabricate a hypothetical situation here with the following assumptions:

  • You’re a graduate student who needs to work from "home", i.e. someplace that isn’t your cozy office with its hardline to the servers, during the "holidays," i.e. a time where you’re forced to talk to people about why you haven’t gradated yet and why you’re still in school.

  • Let’s say this "home" is far enough away from the office, or your 'net connection is slow enough that SSH/VNC aren’t going to cut it and you’re going to need to run your stuff locally.

  • Let’s further assume that your servers are UNIX/Linux and you’re stuck with a Macbook or a Windows machine (if you’re on a Windows machine you really should reconsider some of your life choices).

Alright. Well, this may or may not have happened to me more than once, and I’m here to talk to you about how one might address some of these problems.

Gearing Up

You’re going to need to either A) be the sysadmin, B) be really good friends with the sysadmin, or C) know what kind of beer the sysadmin likes. You’re going to want to replicate your environment as much as possible, and you’re going to need the approval/cooperation of your sysadmin to do this.

Step 01 — Server Prep

VPN

You’re going to want a VPN. If you’re going to be doing any sort of heavy remote access to servers, make your sysadmin setup a VPN. Or, if you’re the sysadmin already, you probably did this. You can see my howto for that here.

NAT

If you’re using NFS, you’re going to need to handle some NAT-related shenanigans. Let’s say your server subnet is 192.168.1.0/24, and the VPN server is 192.168.1.100. If you want to share the directory /folder, you’d have a line that read in your /etc/exports file.

/folder 192.168.1.0/255.255.255.0(rw,async,no_subtree_check)

When mounting an NFS volume, the NFS server expects you to open on the client side a protected port, i.e. something less than 1024. Only root (or someone with the right privileges) can do this. However, if you’re behind a NAT, and you are if you’re reading this, the client side port will be way up in the nosebleed section near 65535. NFS thinks this is a security hole (and it’s certainly not a good thing) and will reject you. You can look at /var/log/syslog or /var/log/daemon.log (or whatever it is) to see if this is the case on the server side.

To solve this problem, you need to an another ruleset for your VPN ID. If the original IP/Subnet Mask(options) is <ORIG>, your new /etc/exports should look like the one below:

/folder 192.168.1.100/255.255.255.255(rw,async,no_subtree_check,insecure) <ORIG>

Then all you’ve got to do is (as root) run exportfs -r on the server and you should be home free.

Step 02 — Prepping your Machine

This part is pretty simple. Make enough space for VirtualBox and your virtual machine. If you need to lug along a lot of data, make space for it. Then download and install VirtualBox.

You’re going to watch to grab some barebones distro that’s got the basics only, like Ubuntu Server LTS or something.

Warning
VirtualBox and Macs

If you’ve got a multi-monitor setup (and you should), for some reason VirtualBox doesn’t like being on the non-primary monitor. Expect to see weird screen refresh issues if you’re trying on a non-primary monitor (anything without the Mac bar at the top).

VirtualBox

Overview

The assumption here is that you know what you’re doing enough to install Ubuntu on VirtualBox. You could do something really silly like compile everything from scratch including the compiler (I’m looking at you, Stage 1 Gentoo people) but don’t. Just install a binary distro. Currently, the least offensive to me is Ubuntu so I’m going to be writing from that standpoint. There’s a ton of stuff on the VirtualBox wiki about the details of this or that, so I’m not going to replicate that.

Tip
Crap, VirtualBox Stole Focus

Yeah, that happened to me too. On a Mac, left option then CTRL+CMD gets you out. You’re welcome.

Okay, so now that we’ve got a working Ubuntu 64-bit install, and you’ve turned on 3D acceleration in the VirtualBox settings (and turned off useless things like sound, what are you trying to do, watch YouTube in your virtual machine? Are you nuts? Also, you clicked on that link to the 'tube, didn’t you.) you should have a nice prompt asking for your username. I’m assuming you were clever and installed the server distro to get away from all the useless JUNK that Ubuntu bundles with its Desktop environment. You’re here to work, not to have fun! Also, more things means more nonsense in your VM.

You’re probably going to want some sort of XWindows environment. If you were in CLI-only land, well, SSH would’ve probably worked so stop reading this and get back to work. I started toying with xmonad, and I’m resisting the urge to spend all day playing with optimizations. Twm is too lightweight for me. I’m a Mac user. That should tell you all you need to know about my UI preferences.

Tip
UI Soapbox

Well, actually, it doesn’t tell you everything. It tells you that I like shiny UI’s, sure. I’m just tired of Windoze (eh, eh?) and it’s annoyances, the most glaring of which is that PuTTY, while functional, is FUGLY. I’m just a huge fan of iTerm2. That’s why I use OSX. Well, that and I get native MS Office stuff for the times I have to do that. Some people just can’t get away from Word, PowerPoint, and Excel, and as much as I love LaTeX and Beamer, PowerPoint is pretty fast to make a presentation. I have to give it that. Ok I’m done. For now. Also, if you read this, have a cookie.

Base Setup

Here’s the basics that you’ll need, as a package list:

sudo apt-get install dkms build-essential xmonad lsb ia32-libs

What are all of these things? Well:

  • dkms - For building the VirtualBox Guest Additions (proper mouse support, treating your VM like a window that won’t eat your cursor and steal focus, etc)

  • build-essential - I think this one is fairly obvious. You need the stuff in here to, well, build (i.e. compile) things.

  • xmonad - Insert your favorite window manager here.

  • lsb - The Linux Standard Base. You’re a good person if you do this.

  • ia32-libs - You want this to solve 32-bit vs 64-bit problems. There’s some talk of this disappearing, but 12.04 LTS was live at this time of this writing.

You’ll also want to grab all the packages that are installed on your servers. This is much easier if your distro is the same as the one on your servers, so if you can do that, do that. Don’t forget to install your version management stuff like CVS, SVN, or git.

Important
Getting Shells!

Make sure you install all the shells you need! Ubuntu uses bash by default, but some tools may require ksh or tcsh or something, especially if they use shell scripts to configure the tool for the environment.

It’s at this point that you’ll want to copy whatever programs/data from the servers that you need. rsync -av --progress is your friend.

Gravy

If you’re a super boss, you can use autofs to really make everything look super the same. I leave it to you to install that and get your /etc/auto.ufs and /etc/auto.master looking right, but make sure you put the FQDN of all your NFS servers in those files (or otherwise) so your VPN/router know what’s up.

The same goes for license servers. For that, you can just jury-rig a patch in /etc/hosts and just fight that another day. Again, this is why a VPN is super duper important. If your sysadmin is worth anything they won’t have left giant gaping holes in the firewall to the license server and the NFS servers (or other fileservers).

The last thing you need to do is copy all of your config files, set up your shell preferences, etc. That’s a simple matter of scp or rsync, and I’ll leave that to you. You can check out my tmux and vim notes if you want more details on how I run my rig.

Observant readers will have noticed I suggested turning on 3D acceleration. Add the following to your /etc/xorg.conf file:

Section "Module"
        Load "glx"
EndSection

This will enable the glx extensions. Surprise surprise!

VNC

In some cases, it’s better to run your graphical apps over a VNC connection to your VirtualBox machine. Your mileage will of course vary, but I’ve found XVnc4 does the trick nicely, as it comes with glx support.

sudo apt-get install vnc4server

Random Packages

If you want glxinfo or lspci you need this:

sudo apt-get install mesa-utils pciutils
sudo ln -s /usr/bin/lspci /sbin/lspci