Site icon JetsonHacks

Creating a Swapfile in Ubuntu for the NVIDIA Jetson TK1

The NVIDIA Jetson TK1 has a relatively small main memory for running memory hungry applications like Chromium and compiling large programs. By creating a Swapfile, the Jetson will seem much snappier when a bunch of memory is being consumed. Here’s the video on how to create a Swapfile:

You can read more about Swap Files here: Ubuntu SwapFaq.

I’ve created a Gist which is a Shell file that will create the swapfile for you. First, navigate to the directory where you want to place the swapfile, and then run the script.

The Gist is here: gist

Make sure you set the permission for (Properties->Permissions->Execute: Allow executing file a programON) to execute. Then in a Terminal window run:

sudo ./

This should create a file named swapfile that is 4GB. 4GB is a good size for the 2GB of main memory on the Jetson. You should place the swapfile on a fast device, such as a SATA SSD if available. The main benefit that you will notice is that the system will run much more smoothly when there are a bunch of windows open, especially web browsers.

If you are compiling really big programs, like ROS (Robot Operating System) you’ll need swap memory just to get the programs to compile. The stock 2GB is not enough memory for compiling the beast.

In order to have the swapfile available immediately after booting, you will have to edit the file /etc/fstab. You can edit the file like this:

$ sudo gedit /etc/fstab

Here’s a sample line like you would add:

/media/ubuntu/JetsonSSD/swapfile none swap sw 0 0

where first entry is the full path to the swapfile. Make sure that you save the file after editing. In this example, swapfile is on the root directory of the volume JetsonSSD. You must make sure that the volume is mounted before setting the swapfile. Look here for some hints on how to do that if you’re using an external drive.

I’ve found that having an SSD and a Swapfile makes the entire development experience much more pleasant and is highly recommended.

Exit mobile version
Skip to toolbar