Wednesday, September 21, 2011

Creating a bootable USB drive for use with ROS

And now for something altogether more practical.  Creating a bootable USB drive is likely to be a common task for anyone using ROS on a mobile robot.  Hard drives installations will also work, but they contain moving parts which may be vulnerable to failure on a platform which is subject to vibrations and jolts.  USB drives are cheap and easily available, difficult to destroy, consume little energy, are easy to create backups from and take up minimal physical space inside the robot.  Once you have your system set up on a USB drive you can then easily create a copy on a second drive so that you can have a "stable" version for quick demonstration purposes and a separate development version for all other occasions.

These instructions assume that you're installing some version of Ubuntu, and in this case I was using 11.04.  For ROS installation, Ubuntu seems to be the most supported distro.  Other distros may work, but sometimes have issues with dependencies when using the --rosdep-install option.  It's also a good idea not to use the very latest version, since it typically takes a while before new versions are fully supported by ROS.

One thing to be aware of from the outset is that not all USB flash drives are created equal.  There are a variety of storage sizes, but more importantly there are also different access speeds.  Try to use a drive which has the highest access speed possible in order to avoid excessive latencies.  I used a 16GB Sandisk Cruzer Blade, which seems quite adequate for the task.

1.  Download the latest version of Unetbootin.

2.  Format a USB drive as fat32.  You can do this easily with Gparted.

3.  Using Unetbootin, create a USB install, specifying some non-zero storage space size.

4.  Using Gparted unmount the USB drive, then resize the partition so that it's close in size to the amount of data installed.  Create a new partition, formatted as ext4, called casper-rw.

    Why create this extra partition?  Without this the maximum amount of storage is only a couple of gigabytes.  ROS is quite a large installation and without the additional partition won't fit onto the drive.

5.  Boot from the USB drive.

6.  Click on the wireless network icon, select "wireless", pick the current connection then click "Edit".  Make sure that "connect automatically" and "available to all users" are selected.

    This assumes that you're on an IPv4 network.  Click on IPv4 settings, select "manual" as the method then click on "Add".  Enter a fixed IP address for the robot, with a netmask of and with the gateway being the IP address of the wireless router.  Enter the DNS server IP addresses, which are usually visible from the router's administration page.  "Search domains" can be left blank.

    Click on "Save".

    It makes sense to have the robot on a fixed local IP address, since you can then assign a name to it within the /etc/hosts file and therefore be able to connect to it in a reliable way.  It makes even more sense if you have multiple robots.

7.  Run synaptic and under "repositories" make sure that other software sources (community, multiverse) are enabled.

8.  Open a terminal and enter the following:

      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get install build-essential openssh-server

    Install whatever command line text editor you prefer, such as:

      sudo apt-get install emacs

    This will be used later during ssh logins.  You may also want to install version control software.

      sudo apt-get install bzr subversion git mercurial

9.  Ensure that you're not prompted to press Enter when shutting down or restarting.

      sudo emacs /cdrom/syslinux.cfg

    Then add the options noeject and noprompt to the append entries.  For example:

      append initrd=/ubninit file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash noeject noprompt -- persistent

10. Create a user that will be used for ssh logins.

      sudo adduser <username>

11. Add this user to the sudoers

      sudo visudo -f /etc/sudoers

Under the line:

      root ALL=(ALL:ALL) ALL

add the line:

      user ALL=(ALL:ALL) ALL

Then save with CTRL-X then Y

12. Under "Users and Groups" select the user you made earlier, then click on "Advanced" and make sure that they can use video and audio devices.

13. You may wish to enable remote desktop sharing so that you can use a VNC client to view the robot desktop.  If so make sure that "confirm each access" and "enter password" are unticked.

14. Follow the instructions for installing ROS from

     This may take a while, since the full installation is quite a large download.

15. If you're using a Kinect sensor then install the drivers.

16. You may wish to update the package path within:


    In order to include any additional packages which you are using.  It's also a good idea to keep a copy of the file elsewhere, since subsequent updates can overwrite it.

17. When you've tweaked and tested the installation to your satisfaction you can easily create a backup of it using the dd command line program.


Win said...


I followed your instructions for creating the bootable USB drive with ROS...well done. A couple quick questions. I also have a 16 gig drive. How large did you make the persistent area for Ubuntu and how large is the casper-rw partition? What is the casper-rw used for? I didn't see it mentioned anywhere after creating it. It ROS supposed to be installed to it?


Bob Mottram said...

The persistent area doesn't change - it's just the disk image - so you should reduce the partition size to something close to the amount of data. Any changes you make, such as installed programs or data, occur in the casper-rw partition and are overlayed onto the fixed disk image. You should make the casper-rw partition fill the rest of the disk.

Augustus said...


I was able to boot from USB and open up ubuntu. However it would complain that there's no enough space when I try to install any new software, not mentioning ROS. I followed all instructions in this tutorial. Do you know what might be the problem? I'm using a 8GB usb, and I installed Ubuntu 11.10.