Thursday, July 21, 2011

Standalone flash disk install

Techy almost no image blogpost alert!

These are really just notes to remind me of how I did it but it may be useful to someone. I apologise in advance for the vague bits. Also too this recipe only works for people who run Ubuntu :D.

I am looking for a way to run an openframeworks project on a machine in an easy non final way which will allow me to borrow PCs from people and give them back without changing anything. Since my dev environment is ubuntu I chose lubuntu a lightweight ubuntu with a smaller memory map. Using the lubuntu live disk iso, I modified the iso to have everything I need to run my project. The result a flashdisk which will autorun my project when the pc boots from the disk. In my case my projects need the kinect so the installation is as simple as plug usb stick and kinect into pc and boot.

In recipe style here is what it took to get the disk:
Ingredients:

  • 1 Flash disk 1Gig is enough
  • lbuntu iso file
  • your compiled openframeworks project, the bin directory and the lib directory no source needed
  • if you openframeworks project needs other libraries make a list of those that can be installed and make a tarball of those you need to install by hand. This is usually not necessary if you use openframeworks extension which include the libraries.
  • A list of other package your project needs.
  • a start.desktop file (see further down the post for an example)
  • a start.sh script  (see further down the post for an example)
  • Ubuntu Customisation Kit or UCK you can get it by searching for uck in the software centre or typing sudo apt-get install uck


Method:
Remastering of the iso:

  1. start uck
  2. choose only the language packs you need
  3. when asked if you want to customise more say yes
  4. follow the prompts and at some point you'll get three options. choose option 1: start package manager


Modifying packages:

  1. At this point you are root on the filesystem that will be squashed in the iso. see chroot for more info if you need to know how this works. So adding packages and removing packages with the package manager started by uck will not change your computer but only the packages in your iso. 
  2. Remove Ubiquity (ubiquity provides install icon on desktop and more)
  3. Add whatever packages you need e.g. build-essential if you are planning on building anything.
  4. Close the package manager when you are finished.
  5. At the three options prompt choose 2: open a terminal


Terminal edits:

  1. Now a terminal opens and you are again dropped into the file system in the iso as root. You can see this by typing whoami it should say root. Now you can do any modifications you need.
  2. Get the files you need by typing sftp username@localhost You need to use your username. If it asks security questions say yes and type in your password.
  3. Navigate to the place where the tarball is in you ingredients using pwd, cd and ls
  4. get the file by typing get filename.tar.gz
  5. exit to leave sftp
  6. Do whatever else you need. I moved the tarball to /tmp extracted it using tar -xvf filename.tar.gz then I moved my openframeworks project folder into /usr/share e.g. /usr/share/myapp
  7. Make a start.sh file in the /usr/shar/myapp which contains the following two lines: cd /usr/share/myapp/bin and ./myapp
  8. make the start.sh executable chmod 755 /usr/share/myapp/start.sh
  9. Make a .desktop file in  /etc/xdg/autostart see this example where it says /root/test.sh replace /usr/share/myapp/start.sh
  10. remove all unsused files you copied in or unpacked with sftp to make the final image smaller
  11. clean up the unused packages by typing : apt-get autoremove
  12. leave the terminal by typing: exit
  13. Again you see the 3 options choose option 3: continue
  14. uck will now make a new .iso file for you.


Testing:
You can test the iso in virtual box or make a usb disk using the usb creator which comes with ubuntu

Final tweaks:

  1. Once you have the usb disk plug it in and look for the syslinux.cfg file in syslinux on the disk.
  2. Edit it and change the timeout to say 10 which means 10 1/10ths of a second which makes it jump over the menu quickly.
  3. remove disk and plug into unsuspecting pc and boot up. 
  4. After the first run remember to switch the screensaver off, I still have to figure out how to do this in the default settings.


Tada!


Some notes:

  • Some PCs have problems with live disk booting of 11.04 notably Acers which have a backlighting issue.
  • It would be good to figure out how to do the screensaver changes as default.
  • Works better if you make your project run fullscreen.
  • I can run the uck process multiple times on the built iso in this way incrementally changing things.
  • I still need to figure out how to remove other unneeded things such as bluetooth detecion and wifi detection which slows down the startup.
  • When removing packages make sure it isn't going to remove lubuntu-desktop. 


More info:
uck tutorial
uck documentation