Subscribe to RSS  |  Advertise on this Blog

  • HOME
  • ABOUT
    • RESUME
Alberto Matus
  • SERVICES
  • CONTACT
  • HOME
  • ABOUT
    • RESUME
  • SERVICES
  • CONTACT
December 29, 2017  |  By ajMatus In Linux Tips, Open Source, Technology, Ubuntu

Creating Linux Swap after Installation

Perhaps you’ve already installed your Ubuntu operating system, and for some reason or the other you forgot swap, or deleted it among other things that may happen. In my case I had it on a different drive which I needed. I simply didn’t want to reformat my installation, and certainly didn’t want to add another drive for a simple swap. Thus, one way to get around this without recreating a swap partion is to create a swap partition “file”. Keep in mind it will do the job just so as long as you don’t end up with a really full disk drive through which the swap file may be created fragmented. Below you’ll find how to accomplish this.

1. Firstly, you must create an empty file, I decided I wanted a 5GB swap file. (1K * 5M = 5GB). You can change the 5 to whatever number of gigs you want to create.

sudo mkdir -v /var/cache/swap
cd /var/cache/swap
sudo dd if=/dev/zero of=swapfile bs=1K count=4M
sudo chmod 600 swapfile

2. Second, we need to convert this newly created file into the swap space file.

sudo mkswap swapfile

3. This file needs to be enabled for paging and swaping by using the following command.

sudo swapon swapfile

Can be verified by using commands:

swapon -s or top

Or grep

top -bn1 | grep -i swap

We can disable swap by using command:

sudo swapoff swapfile

Results should be similar to the image below:

albertomatus swap

4. We need to make this remain on system by adding it to our fstab file, this enables it to remain upon reboots.

echo “/var/cache/swap/swapfile none swap sw 0 0” | sudo tee -a /etc/fstab

5. Finally, we need to make final checks after reboot. Retest swap file on startup by using the following commands:

sudo swapoff swapfile
sudo swapon -va
or check via the “top” command as in part 3.

Linux Swap Swap File ubuntu

Article by ajMatus

Related Articles

  • Ubuntu-20-04-LTS-new-features-Stackscale-blog
    Changing Login Display In Ubuntu 20.04
  • 22-108-682-V01
    Recovering Data from Synology Crashed Deivce

WELCOME

Hello, and welcome! I'm Alberto - a Cyber Security & Digital Forensics professional specializing in Digital forensics, Incident Response & Vulnerability Assessment. I hold a Master's degree in Cybersecurity with a concentration in Digital Forensics from the University of South Florida and a Bachelor degree in Information Technology from the University of Belize. Through this blog I hope to share tips, information about cybersecurity, cybercrime, digital forensics, open source technologies, business, and a bit of my amazing country. For those interested in any of my services please feel free to contact me using any of the associated contact details on this blog.

SEARCH

ARCHIVE

  • October 2022 (1)
  • July 2021 (2)
  • November 2020 (2)
  • October 2020 (1)
  • September 2020 (2)
  • August 2020 (2)
  • July 2020 (6)
  • June 2020 (6)
  • April 2020 (5)
  • February 2020 (1)
  • November 2019 (2)
  • October 2019 (1)
  • September 2019 (1)
  • June 2019 (1)
  • May 2019 (1)
  • November 2018 (6)
  • September 2018 (3)
  • August 2018 (4)
  • February 2018 (1)
  • January 2018 (3)
  • December 2017 (1)
  • October 2017 (5)
  • September 2017 (1)
  • December 2016 (2)
  • November 2016 (4)
  • October 2016 (1)
  • September 2016 (2)
  • August 2016 (5)
  • July 2016 (2)
  • June 2016 (2)

CALENDAR

March 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Oct    

RECENT POSTS

  • Capture
    WordPress Empty template: Index Friday, 7, Oct
  • Belize – Benque Viejo to San Ignacio Town Drive Tuesday, 6, Jul
  • alberto-matus-digital-piracy
    An Overview of Digital Piracy Thursday, 1, Jul

REMOTE WORK

Remote work is my preferred way or working as I have a home office set up where all the magic happens. This method allows me to work with businesses, organizations, and all brands across the globe. I can manage projects via my own management applications or your own internal project management app. Any calls and meetings can be done through whatever tools fits your business, and I’m flexible to work on your time zone.

ON-SITE

Not every job assignment can be done via remote working methods, and so if it requires me to be on-site for the duration of the work then this can be done based on agreements or contractual work. I prefer doing these types of consultancies or hands-on types of work on the weekends but I am flexible enough depending on the terms. I am also open to traveling outside of Belize. All further afield work requires accommodation and travel expenses.

RETAINER

Sometimes clients are looking for long term partners that share a closer connection to their visions and goals. As such I am open to retainers. A retainer hires me for a certain amount of hours per month at a discounted rate. These discounted rates are usually between 10%-20% off depending on the contractual agreements.

Alberto - open source | technology | belize -Matus

Copyright ©2020. All Rights Reserved

en_USEnglish
en_USEnglish