/tmpfs for /tmp
Tuesday, 21 April 2009
To use memory (ramdisk) for /tmp storage, edit
sudo nano /etc/default/tmpfs
Set your default limit in bytes (here 548MB)
shm=573741824
Then add to the startup routine
sudo nano /etc/fstab
...add this line to the end of the file, save & reboot
tmpfs /tmp tmpfs defaults,noexec,nosuid 0 0
On reboot, when you run df -h to see your disk allocations you'll see /tmp mounted into a ramdisk tmpfs partition. More here
Or more comprehensively
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
Deployment Recipes + GIT on Accelerators + more
Friday, 03 April 2009
Deployment Recipes
on Joyent
Really like this one,
This is a little useful too if your messing with Joyent Shared Accelerators,
Glad to see deprec is still alive & well, was a major help in building slices, playing with the new release on a vm now,
sudo gem install deprec
...and
How-To ?
so in a nutshell
on your server
ssh joe@mygithub.com
Then create somewhere to host all your git repositories,
mkdir git && cd git
And create your remote repository directory and bare git setup
mkdir awesomeapp.git && cd awesomeapp.git
git --bare init
chmod -x ~/git/*/hooks/*
The last line is really important, without it you'll get these kind of errors when pushing an update from the client to the server.
hooks/update: syntax error at line 40: `allowunannotated=$' unexpected
error: hooks/update exited with error code 2
error: hook declined to update refs/heads/master
on your client
Now on your client, create you git repository, add & commit it.
cd awesomeapp
git init
git add .
git commit -m 'init'
Now create the link to your remote repository,
git remote add origin ssh://joe@mygithub.com/users/home/joe/git/awesomeapp.git
And push your update
git push origin master
...now a word from our sponsor
Add SSH key to Strongspace
Saturday, 28 March 2009
Thanks Nick Carroll for posting that guide....
First generate keyfile
ssh-keygen -d
Then copy your current authorized keyfile from Strongspace
scp joe@joe.strongspace.com:.ssh/authorized_keys ~/
Concat / Add your keyfile to to the end of it
cat .ssh/id_dsa.pub >> authorized_keys
And copy it back
scp ~/authorized_keys joe@joe.strongspace.com:.ssh/authorized_keys
XEN Notes
Saturday, 28 March 2009
Building VM's with XEN on my server, example commands below...
XEN Commands
start
xm create /etc/xen/xen01.mybox.com.cfg
start on boot
ln -s /etc/xen/xen01.mybox.com.cfg /etc/xen/auto --force
list running xen machines (dom0 is host)
xm list
list all virtual images created by xen-create-image
xen-list-images
shutdown
xm shutdown xen01.mybox.com
shutdown immediately (as if you pulled the plug out)
xm destroy xen01.mybox.com
login
xm console xen01.mybox.com
to log in on that virtual machine (type CTRL+] if you are at the console,
or CTRL+5 if you're using PuTTY to go back to dom0),
or use an SSH client to connect to it (192.168.1.2).
ctrl+] to get back to host
show kernel
file /bin/ls
help
xm help
XEN VM Creation Examples
xen-create-image --hostname=xen01.mybox.com --size=10Gb --noswap --ip=192.168.1.2 --memory=256Mb --arch=i386 --role=udev
(debian lenny, 10gb hdd, no swap, 256mb ram, 32-bit kernel)
xen-create-image --hostname=xen01.mybox.com --size=10Gb --swap=128Mb --ip=192.168.1.2 --memory=256Mb --arch=amd64 --role=udev
(debian lenny, 10gb hdd, 128mb swap, 256mb ram, 64-bit kernel)
xen-create-image --hostname=xen01.mybox.com --size=10Gb --noswap --ip=192.168.1.2 --memory=256Mb --arch=i386 --dist fedora-core-8 --install-method rinse --role=udev
(fedora core 8, 10gb hdd, no swap, 256mb ram, 32-bit kernel)
XEN Customizations
Make VM use both processor cores...
nano /etc/xen/xen01.mybox.com.cfg
...and add this to the config
vcpus = '2'
Store vm's in /home/xen
mkdir /home/xen
nano /etc/xen-tools/xen-tools.conf
...find dir = ...
...and change to
dir = /home/xen
Practical Programming + RSpec
Thursday, 26 March 2009
Bought some more pragmatic guides, do enjoy those books; they're really well-written and thoughtfully laid out. The first is a beta book focusing on Computer Science using Python to demonstrate applications. The second is on testing which I'm gonna read thru today, kettle's on so chat later.
Practical Programming: An Introduction to Computer Science Using Python by Jennifer Campbell, Paul Gries, Jason Montojo, Greg Wilson
The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends by David Chelimsky, Dave Astels, Zach Dennis, Aslak Hellesøy, Bryan Helmkamp, Dan North
XEN-side I requested the IP addresses for the virtual machines & got them approved via RIPE, so I'll start creating them later today to provide as test boxes for client apps.
P.P.S. Ubuntu 9.04 looks to have reached a stable point, today is it's first beta release according to the roadmap. Interface is a major cosmetic improvement, plus it comes bundled with ext4 from the get-go. Good work.
All the best,
Installing XEN on Debian Lenny
Monday, 23 March 2009
Really needed to virtualize the server as I can't waste all those resources, so first tried vmware which was ok but I'm not that big a fan; I really wanted to go the XEN route.
So, after some experimenting with a dev machine I finally bit the bullet & installed it.
Check Support
The server processor is an AMD with an ASUS board, so first check you can support virtualization
grep "vmx" /proc/cpuinfo
For AMD, look for SVM, for Intel look for VMX.
Install Xen
Next install xen, 'from here on in, it gets scary fast'
aptitude install xen-linux-system-2.6.26-1-xen-amd64 xen-utils-3.2-1 xenstore-utils xenwatch xen-shell xen-tools
Setup
You're not out of the woods yet, edit /etc/modules if you're after image-based virtual machines; skip otherwise.
nano /etc/modules
...change
loop
...to
loop max_loop=64
Save then edit /etc/xen/xend-config.sxp
nano /etc/xen/xend-config.sxp
- Find (network-script network-bridge) and uncomment
- Make sure (network-script network-dummy) is commented
- Make sure (vif-script vif-bridge) is uncommented
e.g.
(network-script network-bridge)
#(network-script network-dummy)
(vif-script vif-bridge)
Checking
Now reboot
reboot
And check which o/s you've got
uname -r
Mine returns...
2.6.26-1-xen-amd64
more here
One less thing...
Saturday, 31 January 2009
Spent a little bit cleaning up this blogging engine, integrated Sphinx into the core, moved the themes into their own folders and got the assets all in one place.
Runs well, now if I could have a page accessible for seeing the results of certain portions of the logs, or even memory usage of the server that'd be awesome.
Think of it, a blog that don't just hold your notes & thoughts but also manages your server. hmm....
Nameservers + Tracing
Sunday, 18 January 2009
To do a trace from you to your webserver do:
dig mysite.com +trace
Recently had some problems with my nameserver supplier freedns, would suggest avoiding them.
Using Slicehost's Nameserver services until I've finished building my own, have used GoDaddy's but it's outaged on me before.
New Splash
Saturday, 17 January 2009
As much as I like the blog, it really needs some kinda intro to introduce the user and welcome them in; so tonight I sat down determined to put together a new design.
Work in progress
Bazaar - Python-based VCS
Monday, 22 December 2008

Bazaar is a Python-based distributed versioning system, really simple lightweight and works under and with pretty much anything.
More here but to get it installed on your mac with macports just run...
sudo port selfupdate
sudo port install bzr
After it's installed and activated tell it who you are so it knows where all these changes are coming from in the future.
bzr whoami "John Doe <john.doe@gmail.com>"
You can check that's worked via
bzr whoami
Which should output who you told it you were,
Putting things under Bazaar
Next up it's real simple to start getting things stored under Bazaar, if you've used things like Mercurial or GIT then this should be a walk in the park,
First off navigate to the project you want to put under it then init a new Bazaar repository.
bzr init
Next up add all the files you want into the repos via,
bzr add .
...this'll add everything in the current directory you're in into the repository
Next up commit your files,
bzr commit -m 'initial code'
Should go smoothly listing all that you've done and give you a revision number (in this case 1).
You can then check the log for what's occured via,
bzr log
Which will show you the history, timestamps, user names & emails and messages posted so you can quickly see how things are evolving; and being Python it's pretty fast.
More here
Like most others, your repository is kept under a hidden system directory .bzr, find it easily with,
ls -a
However unlike others it doesn't mind what you put in it and will pack them tightly so it doesn't consume too much space, plus you can use it against any storage medium, current version at time of writing 1.1
MAMP + Symfony
Sunday, 21 December 2008

Playing around with the Symfony framework for an interesting idea I have, sort of a Google Maps mashup.
Anyway, on OSX Leopard I'm using MAMP to handle the lamp environment and so need to supplement it's support with Symfony; which isn't too big a challenge to add.
Install MAMP on Leopard
First off download MAMP free here it's a 130mb download so you'll have to wait a while on a slow connection (we've got fibre so it's super quick). Once downloaded open & drag the MAMP folder into your Applications directory.
Next run up the MAMP application from within your /Applications/MAMP dir, this should give you MySQL running with these settings,
...location
Host: localhost
[Port: 8889]
User: root
Password: root
...via php
$link = mysql_connect('localhost', 'root', 'root');
...via sockets
Socket: /Applications/MAMP/tmp/mysql/mysql.sock
User: root
Password: root
...via php + sockets
$link = mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'root');
Add to PATH
Next using Terminal, add your PHP directory to your path by adding it to your .bash_profile file (need to reopen Terminal to read the new variable)
mate .bash_profile
Add this to the end of the file & save it,
export PATH=$PATH:/Applications/MAMP/bin/php5/bin
Check you've got PHP5 up and running by typing this at the Terminal, you should see PHP 5.2,
php -v
Install Symfony
Run these commands thru Terminal to install the Symfony framework into your PHP install,
/Applications/MAMP/bin/php5/bin/peardev channel-discover pear.symfony-project.com
/Applications/MAMP/bin/php5/bin/peardev install symfony/symfony
Now check you've got Symfony installed by typing this into the Terminal,
symfony -V
Next grab the Sandbox application to start with via here and extract it into the default root dir of your PHP install; being MAMP this will be:
/Applications/MAMP/htdocs
Afterwhich via your web browser you should be able to test the sandbox app at:
http://localhost:8888/sf_sandbox/web/frontend_dev.php/
Create your First Project
The Symfony framework provides an excellent starter for your application, with the data, app code, cache and logs all stored within a design much like Rails and it's MVC pattern so you can get up & running fast.
So to create your application do,
mkdir ~/myproject
cd ~/myproject
symfony init-project myproject
Note the symfony command must be run within the directory you want your app put together so create a directory for it first, move into it then run the line above.
And within MAMP,
mkdir /Applications/MAMP/htdocs/myproject
cd /Applications/MAMP/htdocs/myproject
symfony init-project myproject
Add your Application
Now you won't able to see anything until you've created your first app within myproject via,
symfony init-app myapp
This will create some files to get you up & started along with a simple index.php file within the /web dir to show things went ok,
http://localhost:8888/myproject/web/index.php
You'll probably get a message saying it can't find your application's web/sf directory for the images, as you've already got the sandbox app installed, copy it from there.
cp -R /Applications/MAMP/htdocs/sf_sandbox/web/sf /Applications/MAMP/htdocs/myproject/web/sf
Or from your original PEAR install,
cp -R /Applications/MAMP/bin/php5/lib/php/data/symfony/web/sf /Applications/MAMP/htdocs/myproject/web/sf
Your project should be much happier now.
Obviously you shouldn't be sticking your projects entire framework inside your /htdocs directory for production as it'll make the whole thing visible to the outside world but for this simple example it'll do for now.
But if you really want to you can edit your Apache's document root directory via the Apache config file:
mate /Applications/MAMP/conf/apache/httpd.conf
And change,
DocumentRoot "/Applications/MAMP/htdocs"
...to
DocumentRoot "/Applications/MAMP/htdocs/myproject/web"
Simple for now but you can expand on it later with virtual server configs and the like later.
More on this via Symfony's official documentation here
MATE ?
...please note i've got TextMate installed along with the path integration so I can access it via Terminal with mate so if you don't have TextMate, substitute mate for nano or vi if you're old-school ;-)
Linux Package Commands + Wajig
Saturday, 20 December 2008
Aptitude or Apt-Get
Was asked this recently, as far as I know the only core difference is Aptitude has a better way of handling dependencies when you remove a package; cleans up better. In all you should try to switch to Aptitude where possible, if you've installed a package with Aptitude then when you remove it via Aptitude it'll know about any dependencies it has to check for or orphaned packages.
Update and Upgrade
apt-get update
apt-get -u upgrade
aptitude update
aptitude safe-upgrade
Install Package
apt-get install gedit
aptitude install gedit
Remove Package (keep config files)
apt-get remove gedit
aptitude remove gedit
Remove Package Completely
apt-get --purge remove gedit
aptitude purge gedit
Upgrade Package
apt-get install gedit
List Possible Upgrades
apt-get upgrade gedit
Show Package Info
dpkg --info gedit*.deb | less
List All Packages
dpkg -l
Check if Package install plus Info
dpkg -l | grep -i 'gedit'
List files owned by package
dpkg -L gedit
List files inside Package
dpkg --contents gedit*.deb
Find out who owns this Package
dpkg -S /bin/netstat
Check if Package installed and it's Status
dpkg -s gedit| grep Status
Show Dependencies for a Package
apt-cache depends mysql-server
Wajig
Wajig is a Linux tool that combines a lot of the abilities within apt-*, aptitude and dpkg into one command. Written in Python it handles normal users and super-user privileges & can be installed with...
apt-get install wajig
aptitude install wajig
More info here









