CS150: USB Flash Drive Configuration

John C. Lusth

Revision Date: January 19, 2012

Printable Version


Some of the configurations listed below are aimed at reducing the number of disk writes on a Ubuntu full-install USB stick: Others are to make a nice looking and acting environment for programming in Sway and Python.

Start by installing Ubuntu on a usb flash drive: usb-install.html.

Once installed, boot your computer from the USB stick.

Modify fstab to use noatime options

The first tweak is to modify /etc/fstab. The first change to fstab is to add the option noatime to the ext4 (or ext2, ext3) file system you created. You need root privileges to do this:

    sudo vim /etc/fstab

Use whatever editor you are comfortable with if you do not use vim as your editor.

Change the line that reads something like this:

    UUID=xxxxxx    /	ext4   errors=remount-ro    0  1

to this:

    UUID=xxxxxx    /	ext4   defaults,noatime,errors=remount-ro  0  1

Continue on to the next step.

Disable swap

Find the line in /etc/fstab that looks like:

    UUID=xxxxxx none  swap  sw   0   0

Comment that line out by adding a # in front:

    #UUID=xxxxxx none  swap  sw   0   0

Continue on to the next step.

Use a RAM disk for logging and caching

Use a RAM disk for /tmp and log files. Add to /etc/fstab:

    tmpfs      /tmp                    tmpfs        defaults      0 0

Save your changes to /etc/fstab and reboot.

Firefox caching

Have firefox save its cache in the RAM disk. Type in 'about:config' in the address bar and then click right on the list of attribute-value pairs and select New -> String. Enter the attribute:

    browser.cache.disk.parent_directory

and then enter the value:

    /tmp

Now firefox will cache to the RAM disk.

Reduce synching to the flash drive

To reduce the number of syncs to the flash drive, add to /etc/sysctl.conf:

    vm.dirty_ratio = 40
    vm.dirty_background_ratio = 1
    vm.dirty_writeback_centisecs = 12000

Add important packages

Add the following packages:

    sudo apt-get install vim \
        network-manager-pptp sshfs \
        build-essential manpages-dev \
        alsa-utils mpg123 \
        python-tk python3-minimal python3-tk

Next, go to adobe.com and download and install the latest version of flash.

Install the cs150 package

Get the latest package of programs and scripts for cs150:

    wget beastie.cs.ua.edu/cs150/cs150-2.7_i386.deb

and install it:

    sudo dpkg -i cs150-2.7_i386.deb

Perform the additional "cp" commands as instructed. These commands adds a local bin directory and updates the path to include the bin and allow execution of the local programs.

Install the Sway Programming Language

Install the Sway deb package:

    wget sway.cs.ua.edu/sway_1.0.6e-1_i386.deb
    sudo dpkg -i sway_1.0.6e-1_i386.deb

Look and feel

Add sophisticated window decorations and an elegant look-and-feel. In Start -> Settings -> Settings Manager -> Window Manager -> Style, select Today. In ... -> Settings Manager -> User interface -> Theme, select Xfce-kolors.

Spring 2010 uses the Gorilla window manager style and the Crux theme.

Fall 2010 uses Gnome and the Graphite theme.

Spring 2011 use Gnome and the AgingGorilla theme.

Fall 2011 uses Unity with the Graphite theme.

Remote graphical logins

Install the NoMachine client software for graphical logins to nixie.cs.ua.edu:

http://www.nomachine.com/download-package.php?Prod_Id=1048

Installing ubuntu updates

To have an updated linux image, do the following command in the terminal:

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade

After the first command, you will be asked to enter the adminstrative password. For USB sticks, the password is

    ubuntu

Press the Enter key, when asked if you wish to continue. This will install the most recent updates on the system.

Remove old kernels

To remove old kernels residing on the USB, first find the name of the current kernel:

    uname -r

You should see something like:

    2.6.38-10-generic

Note the number: 2.6.38-10. Next, do a listing of the /boot directory:

    ls /boot

You will see something like:

    abi-2.6.38-8-generic
    abi-2.6.38-10-generic
    config-2.6.38-8-generic
    config-2.6.38-10-generic
    grub
    initrd.img-2.6.38-8-generic
    initrd.img-2.6.38-10-generic
    memtest86+.bin
    System.map-2.6.38-8-generic
    System.map-2.6.38-10-generic
    vmcoreinfo-2.6.38-8-generic
    vmcoreinfo-2.6.38-10-generic
    vmlinuz-2.6.38-8-generic
    vmlinuz-2.6.38-10-generic

Find any lower kernel numbers and remove them with:

    sudo apt-get remove --purge linux-image-x.x.xx-xx-generic

where x.x.xx-xx represents the old kernel version number.

Clean up other unnecessary files

Install localepurge:

    sudo apt-get install localepurge

and select your locale (en for english). Then run localepurge from the command-line:

    localepurge

Finally, remove localepurge:

    sudo apt-get remove localepurge

Next, run the apt-get cleaning commands:

    sudo apt-get autoremove
    sudo apt-get autoclean
    sudo apt-get clean

Reduce boot time

Reduce the GRUB_TIMEOUT option in the /etc/default/grub/ to 2 seconds. This will start booting the default image after the configured timeout seconds.

Rebuilb the grub config file by running the command:

    sudo update-grub

Final steps

Now boot the usb drive and, in the home directory, run the command:

    sudo find . -exec chown ubuntu.ubuntu {} \; -print

Again, the password is ubuntu. The drive should be ready for imaging. For bulk imaging of the drives, see imaging.html.

If you have tested the cs150 scripts by setting your email, make sure you removing your imprinting before saving the master image. You can get the current master image (4G, Lucid Lynx) with the following command:

    wget beastie.cs.ua.edu/images/lucid.img

lusth@cs.ua.edu