Machine Vision, Part 2: SSD Drive

Set Up SSD Drive

With so many disk intensive activities on the horizon, it makes sense to do as many of those as possible on a true SSD.

After you have physically mounted/installed the NVMe stick, perform the following steps:

  1. Figure out the device: “ls /dev/nvmen*”. In my case (and probably yours), “/dev/nvme0”. We don’t need to partition our SSD drive into separate “sub-drives”: one big drive is what we want. So:
    $ sudo mkfs.ext4 /dev/nvme0n1
    
  2. Create an empty folder where we’ll mount our new drive. I’m using /mnt/ssd — use what makes sense to you:
    $ mkdir -p /mnt/ssd
    
  3. Edit /etc/fstab to add a line (so your OS can auto-mount the new drive on boot):
    /dev/nvme0n1 /mnt/ssd ext4 defaults 0 0
    
  4. Test your work:
    $ sudo mount -a
    
    This manually mounts your drive. You should get no error messages.
    $ df -h
    
    Produces a list. You should see a line listing your new drive and mount folder.

Swapfile

Let’s also set up a swap file on our SSD. Opinions vary how large it should be. Here is a good article. For Ubuntu systems with more than 1G of memory, the recommended swap size is the square root of RAM. If you’re going to use hibernation, add the size of RAM. I’m not interested in hibernation, so I’m going with 3G of swap space.

  1. Create a file that will be used for swap:
    $ sudo fallocate -l 3G /mnt/ssd/swapfile
    
  2. Only root should be able to write and read the swap file:
    $ sudo chmod 600 /mnt/ssd/swapfile
    
  3. Use mkswap to set up the file as Linux swap area:
    $ sudo mkswap /mnt/ssd/swapfile
    
  4. Enable the swap:
    $ sudo swapon /mnt/ssd/swapfile
    
  5. To make the change permanent open /etc/fstab file and append the following line:
    /mnt/ssd/swapfile swap swap defaults 0 0
    
  6. o verify that the swap is active:
    sudo swapon --show