HOWTO: Keeping Drupal on Your Keychain

I am sure it's a common problem. You are a rocking Drupal software engineer and you are talking to a particular cute guy or girl at a pretty awesome party. Naturally, the conversation turns to open source software projects and you boast that you work on Drupal - the coolest content management system out there. Since this boast is bound to be followed up with questions like "what is Drupal?" or "why is Drupal cool?" - wouldn't it be grand (instead of trying to explain just how cool the garland color picker is) to whip out a portable USB key, stick it in an available computer, and show them the wonders of Drupal right then and there?

Install Ubuntu onto a USB Key

  • Download Ubuntu and mount [mount -o loop ] the image
  • Use fdisk [fdisk /dev/sda] to delete any existing partitions [fdisk: d], add a new partition [fdisk: n,p,1,*enter*,+700M], set its type to FAT16 [fdisk: t,6], and make it active [fdisk: a, 1], add another partition [fdisk: n,p,2,*enter*,*enter*], and save all the changes [fdisk: w]
  • Install the FAT16 filesystem [mkfs.vfat -F 16 -n usb /dev/sda1] and the ext2 filesystem [mkfs.ext2 -b 4096 -L casper-rw /dev/sda2]
  • Install the Linux System Tools [syslinux -sf /dev/sda1]
  • Mount the USB Key [mount /dev/sda1 /mnt] and copy over Ubuntu [cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz install/mt86plus /mnt]
  • Copy this special file to the USB key [tar xf usyslinux.tar ; cp syslinux.cfg /mnt]
  • Run Lilo [lilo -M /dev/sda]

These instructions and system file are adapted from this tutorial. For the purposes of these directions the USB drive is assumed to be at /dev/sda.

Install and Configure the LAMP Stack

  • Install the stack [apt-get install php5-mysql mysql-server php5 apache2]
  • Enable Apache's mod-rewrite [ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load]
  • Allow .htaccess overrides in apache's configuration file [vim /etc/apache2/sites-available/default] by changing all "AllowOverride None" configurations to "AllowOverride All"
  • Edit your /etc/rc.local file [vim /etc/rc.local] to add the following line [mount /dev/sda2 /mnt], run the command on the command line [mount /dev/sda2 /mnt], and add a web root directory [mkdir /mnt/webroot]
  • Edit the Apache configuration file to point to your new webroot [vim /etc/apache2/sites-available/default] to change all references to /var/www to /mnt/webroot. ** Note - its important to setup a separate webroot on the ext2 system since apache is not a fan of the FAT16 filesystem **

Install and Configure Drupal

  • Create your MySQL database [mysql -u root], set the appropriate permissions, and copy over your Drupal database (or install a new one)
  • Copy over the Drupal code files to your webroot at /mnt/webroot
  • Do any other Drupal configuration needed

Set up "Kiosk Mode" in Linux

  • Create a shell script [vim /home/ubuntu/kiosk.sh] to execute [/usr/bin/firefox --fullscreen http://127.0.0.1] ** Note - sometimes it takes a second for apache to load and the script may need "sleep 30" at the beginning to give apache time to load **
  • Configure Ubuntu at (System --> Preferences --> Sessions) to run the kiosk.sh script at Startup
  • Install the AutoHide Firefox Extension
  • Add a line [rm /home/ubuntu/.ICE*] to your GDM runtime to remove ICE Authority File Locking Issues [vi /etc/gdm/PreSessions/Default]

To boot off of the USB key, insert the USB key into a computer and set its BIOS to boot from the USB key. Wait a couple of minutes for it to boot up and enjoy the Drupal.

Topics