Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Creating Swap Space on a Linux System

Swap space is used by the system to store memory pages or blocks that are used less frequently to free up space in the physical RAM. In this hands-on lab, you will be tasked with creating and enabling a swap partition and a swap file and ensuring that they persist through a reboot.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Jul 19, 2025
Duration
15m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Create and enable a swap partition using /dev/xvdg1.
    1. Use the mkswap command to create swap space on /dev/xvdg1:

    mkswap /dev/xvdg1

    1. Use the swapon command to enable the swap partition:

    swapon /dev/xvdg1

  2. Challenge

    Add an entry to /etc/fstab to ensure that the swap partition persists though a reboot (use the UUID).

    Obtain the UUID for the partition using the blkid command:

    1. Use the editor of your choosing (i.e., vim, nano, etc.) to add an entry to /etc/fstab for the swap partition:

    vim /etc/fstab

    1. At the bottom of the file add the following entry:

    UUID=partition_UUID swap swap sw 0 0

  3. Challenge

    Create and enable a 1 GB swap file in the root directory called "extraswap".
    1. Use the dd command to create a 1 GB file called extraswap:

    dd if=/dev/zero of=/extraswap bs=1M count=1024

    1. Update the permissions on the swap file to be read right only for the root user:

    chmod 600 /extraswap

    1. Use the mkswap command to turn extraswap into a swap file:

    mkswap /extraswap

    1. Use the swapon command to enable the swap file:

    swapon /extraswap

  4. Challenge

    Add an entry to /etc/fstab to ensure that the swap file persists through a reboot (use the full path to the file name).
    1. Use the editor of your choosing (i.e., vim, nano, etc) to add an entry to /etc/fstab for the swap file:

    vim /etc/fstab

    1. At the bottom of the file add the following entry:

    /extraswap swap swap sw 0 0

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight