Jetson TX1 Swap File and Development Preparation

Adding a swapfile and doing some preparation for development is one of the first things to do after flashing a NVIDIA Jetson Development Kit. Looky here:


Over the last couple of years, the software capabilities of the Jetson Development Kits have increased dramatically. JetPack does a great job of keeping track and installing the many software libraries and Jetson specific software packages and demos. However, this does come at a cost. Because the Jetson Development Kit has a relatively small “hard drive” and a limited amount of memory, sometimes development can get bogged down a bit because of lack of system resources.

Fortunately, there are work arounds. Some of the larger programs and applications out there, such as TensorFlow and ROS to name just a couple, require more memory to build than the Jetson has available. A good work around for this is to use what is called a swap file, which allows the Jetson to use disk space as virtual memory. We talked about this in an earlier article.

Also, sometimes we would like to reclaim some of that disk space used by the installed software and demos, and repurpose it for development. In the video, we show how to get rid of some of the low hanging fruit.

Getting to Work

The video was performed directly after flashing the Jetson using JetPack 2.3.1. JetPack installed:

  • L4T 24.2.1
  • CUDA 8.0
  • cuDNN 5.1

which is need for the project that I’m currently working on. Other libraries and demos were also installed such as VisionWorks.

On the JetsonHacks account on Github, there is a repository named postFlashTX1 which contains some convenience scripts for creating a swap file and reclaiming some of the disk space from some applications that sometimes are not used on development machines.


In the video, a 250GB Samsung EVO 850 SSD is connected to the Jetson TX1. The SSD is formatted as ext4. In order to create a swap file:

$ sudo ./ -d [directory location] -s [size in gigabytes] -a

All of the arguments are optional. The default is for a 8GB swapfile to be created in the current directory. The -a flag indicates whether the swapfile should be automatically be loaded on boot. If the swapfile is to be loaded at boot time, make sure to set up the media that it is on so that it is available when the machine boots.

For the 4 GB Jetson TX1, a 8 GB swapfile is a good size. The rule of thumb for the swap file size is about 2X real memory size. Also, try to place the swapfile on external media that is as fast as possible. While you can place the swapfile on a USB stick or SD card, note that there will be a real performance hit when compared to placing it on a SSD.

Important Note

Setting up a swapfile on a SSD or other flash type memory can lead to wear of the device. Most current flash memory has a lifetime number of reads and writes it can perform, a busy swap file can consume a good chunk of those. Note that this is also true of hard drives. Newer SSDs have built in mechanisms to help distribute the “write wear”. As always, make backups of your drives and store them away.

In the video, the swap file is auto mounted when the machine boots. This is great for development, but afterwards you may want to disable that feature. To do so:

$ sudo gedit /etc/fstab

and comment out the line that does the ‘swapon’. Make sure to save the file, reboot and check to make sure that swap is off.

Also, you may want to be a little more hard core about your swap area. You can set aside a ‘swap partition’ and use that instead of a swap file. This approach may be faster because the swap area is set aside contiguously. This route is similar to setting up a swap file, but is beyond the scope of this article.

More stuff

The other convenience files in the repository do some more cleanup work.

$ ./

Will remove the Libre Office suite from the machine. While these are useful tools, they may not be needed for a development machine.

$ ./

Will remove a lot of the links which support desktop like activities, such as shopping.


This is just a general purpose rough cut to get started on getting the machine ready for development. Obviously the development environment needs to reflect the applications that are being built. However, more memory and some more disk space is a real fine way to start.


    • There are below folders and files in home dir
      – cuda-l4t
      – cudnn_samples_v5
      – libvisionworks-nvxio-
      – NVIDIA_CUDA-8.0_Samples
      – OpenCV4Tegra
      – PerfKit
      – tegra_multimedia_api
      – VisionWorks-SFM-0.88-Samples
      – libvisionworks-nvxio_1.5.3.71n.debian.tar.gz
      – libvisionworks-nvxio_1.5.3.71n.dsc
      – libvisionworks-nvxio_1.5.3.71n.orig.tar.gz
      – libvisionworks-nvxio_1.5.3.71n_arm64.changes
      – libvisionworks-nvxio_1.5.3.71n_arm64.deb
      – libvisionworks-nvxio-dev_1.5.3.71n_all.deb
      – libvisionworks-repo_1.5.3.71n_arm64_l4t-r24.deb
      – libvisionworks-sfm-repo_0.88.0_arm64_l4t-r24.deb
      – libvisionworks-tracking-repo_0.84.0_arm64_l4t-r24.deb
      – nv-gie-repo-ubuntu1604-6-rc-cuda8.0_1.0.2-1_arm64.deb
      – tegrastats

      I think some of them are only needed for installation just after flashing, but I’m not sure. Which of them can be deleted?

    • Can’t comment on each file, it depends on how you are using your machine. In general, folders that have ‘Samples’ in the name contain samples development code. The .deb files are the files used for installation; they may or may not be needed depending on what you are building. The remains folders tend to hold libraries and development tools. The other files tend to be executables or shell files that are used for development purposes.

      You might want to make a backup of the files you are going to delete on a flash drive or SD card in case you need them later. Thanks for reading!

  1. Hi Jim

    I did tired to follow this but instead of using a SSD I’m using an industrial SD card, but the OS is not mounting the SD card.

    also I had noticed that once you create the swapfile did delete all the SD contents.

    to reduce the risk of this deletion, I did create three partitions of my SD card

    one for swap -> to have only one file for swap

  2. hi, thanks for the great tutorials ! I have mounted an SSD as the root dir thanks to your other video. Is it a good idea to use the internal sd card as a swap file ? Otherwise, if I use the SSD what should I do differently from your tutorial ?
    Thanks !

  3. Hi Kangalow,

    Firstly, thanks for the great videos. I’m switching from a Rasperry Pi as companion computer on my Groundhog hexacopter to a TX2, and from Dronekit to ROS. These videos have been great to get me off, the ground, so to speak.

    I would value your opinion as to whether a swap file is necessary for the TX2 as I think it has twice the capacity of the TX1. I am implementing the full ROS desktop gui and also full Tensorflow, as in your video.

    Many thanks!

    • Thank you for the kind words. This sounds like a fun project!
      If you are trying to compile Tensorflow on the device itself, you will more than likely need a swap file, it’s a little piggy when building. If instead you decide to install Tensorflow from a .whl file, you may not need one. Thanks for reading!

Leave a Reply

Your email address will not be published.