My development server is a remote Vserver image running under VirtualServer or OpenVZ or anything else. I don't know because I don't care because other people do. I'm used to develop over SSH a lot, this is not problem, but I'm limited to CIFS as a Vserver can't provide NFS. NFS with cachefilesd was fast enough to work on the sources, at least most of the time, but CIFS is a complete fail. Browsing a small directory in my editor may easily take two or three minutes and saving files takes up to 30 seconds.
I decided to download the Vserver to my local Ubuntu laptop some time ago but things got worse this week and forced me to finally start with it tonight. I won't run the Vserver as real Vserver because Ubuntu removed OpenVZ support some time ago and I want to keep the distribution kernel packages. The Vserver will run as a chroot environment locally.
I simply mounted the remote server using sshfs as root to a local directory and copied (downloaded) all the stuff to a local, crypted path during the night:
sshfs firstname.lastname@example.org:/ /mnt -o allow_rootsudo cp -avu /mnt /crypted/development-vsTime-consuming, but easy.
It turned out, that sshfs killed the special modes for /dev files but resetting them is easy:
cd /crypted/development-vs/devfor f in *; do test -e /dev/$f && sudo cp -avu /dev/$f $f; doneThis will search through all files in the copied dev directory, check if they exist in the system dev dir (simple safty check) and copy them with full file attributes to the new dev.
Another special directory is /proc which is required for most tools to work. Host and chroot environment are being used by the same person (me) and so I don't need to care about security.
The development system has some (few) local services, like a webserver. I checked the running runlevel on the remote server using the "runlevel" command (the result was 3) and looked at /etc/rc3.d to find the services which should be started. Check each one if you really need it, some may collide with your host system - this is why I don't show my list here.
We're using cfagent which depends on the hostname - and my laptop's hostname differs from the development system hostname. A little tool called chname promised to solve this issue. Downloading and compiling was easy - and the first test was successful as well:
$ wget http://chname.googlecode.com/files/chname-1.0.tar.gz--2012-11-16 08:31:16-- http://chname.googlecode.com/files/chname-1.0.tar.gzAuflösen des Hostnamen »chname.googlecode.com (chname.googlecode.com)«... 18.104.22.168, 2a00:1450:400c:c06::52Verbindungsaufbau zu chname.googlecode.com (chname.googlecode.com)|22.214.171.124|:80... verbunden.HTTP-Anforderung gesendet, warte auf Antwort... 200 OKLänge: 998 [application/x-gzip]In »»chname-1.0.tar.gz«« speichern.One thing left: A startup script for my pseudo-Vserver chroot environment. I need a script to enter the chroot environment and run all the services I need. My shell window is open all the day and the services won't start twice - no need to check them manually:
100%[=========================================================================>] 998 --.-K/s in 0,07s
2012-11-16 08:31:17 (14,0 KB/s) - »»chname-1.0.tar.gz«« gespeichert [998/998]
$ tar -xzvf chname-1.0.tar.gz chname-1.0/chname-1.0/Makefilechname-1.0/chname.1chname-1.0/chname.c$ cd chname-1.0/$ makecc -Wall -o chname chname.c$ ls -linsgesamt 24-rwxrwxr-x 1 sewi sewi 8835 Nov 16 08:31 chname-rw-r--r-- 1 sewi sewi 590 Feb 3 2007 chname.1-rw-r--r-- 1 sewi sewi 823 Feb 3 2007 chname.c-rw-r--r-- 1 sewi sewi 103 Feb 3 2007 Makefile$ ./chname Usage: chname <hostname> <program> [args]$ sudo ./chname test hostnametest
#!/bin/bashMy start script is called "vs" and I could enter the chroot environment from any shell by running it after less than two hours of work.
# Init environmentgrep /crypted/development-vs/proc /etc/mtab >/dev/null || sudo mount proc /crypted/development-vs/proc -t proc -o rw,noexec,nosuid,nodevfor script in webserver other_service other_service2; do sudo chname my-development-vs.intranet chroot /crypted/development-vs /etc/init.d/$script start;done
sudo chname my-development-vs.intranet sudo chroot /crypted/development-vs su develuser -l
My editor will run in the host environment but could access the files directly because the chroot environment has no image but a simple directory - great and faster than LAN.