Adding And Removing Swap Files Is Easy In Linux

preview_player
Показать описание
In this quick tutorial, I am going to create a swap file on my Linux desktop. I'm also going to show you how to remove a swap file. Below are the commands that I used in this video:
 
ADDING SWAP FILE
► sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
► sudo chmod 600 /swapfile
► sudo mkswap /swapfile
► sudo swapon /swapfile
► swapon --show
Edit /etc/fstab and add:
► /swapfile none swap defaults 0 0

REMOVING SWAP FILE
► sudo swapoff -v /swapfile
► sudo rm /swapfile
Edit /etc/fstab and remove the entry for the swapfile.

WANT TO SUPPORT THE CHANNEL?

SOCIAL PLATFORMS:
💬 IRC: irc://freenode #distrotube

DT ON THE WEB:

FREE AND OPEN SOURCE SOFTWARE THAT I USE:

Your support is very much appreciated. Thanks, guys!
Рекомендации по теме
Комментарии
Автор

bs=block size. Not byte size. Also, for years, I've been told you must place the swap file in /. When asked why, the most common response is "because". Me being me, I challenged that on my own system. I have a 10 year old laptop with 4G of RAM. My swap file exists at /home/swapfile, just because. And it works without issue.

JamesWoodard
Автор

Derek, do not know if someone already told you but you are a great teacher!
Please keep continuing to create videos like this where you explain your actions ("you do that with this command which means that...") as this approach is so easy to follow, especially for Win->Linux converts like myself.
Cheers!

deliriumcode
Автор

I usually use LVM for that, makes the root dir cleaner and getting rid off a logical volume is much easier than a partition on the disk. Good Video

thebrokendeck
Автор

Excellent!! Just deleted the swapfile that Linux Mint installed. With 16GB of RAM, only using about 20%. I've never seen swapfile used. Easy. Thanks!!

MarkDavidMcCoskey
Автор

I loved the way you explained the instructions just clear and right to the point with no annoying music in the background. I wish there were more techs that would copy from you when they create their videos. Like you said, you didn't do it by yourself. You have a professional team assisting you and that's awesome. Kudos to your backup team and to you also for caring for others. Thank you so much and please continue to help the community in need of your expertise.

hesmerciful
Автор

Whattya know. I just bought a new laptop and had forgotten how I set up the swap files

kubo
Автор

Thank you, Derek. I have huge ram but also huge storage (6 extra internal drives with a tera each) so I just let the installer do what it wants. But I'll save this for reference.

AnzanHoshinRoshi
Автор

Needed info on creating swapfiles (never had to before, thought I knew but wanted to verify). Searched YouTube, this was the first relevant result... "Oh, hey, I'm subscribed to that guy." 👍

eriksiers
Автор

Hello DistroTube! One thing to consider. Having a swap file (or swap partition) can be beneficial from performance point of view even if you do not expect to exceed your RAM i any way. Generally speaking Linux kernel is pretty smart with regardst to managing memory and it can move currently unused memory pages to swap and then use regained ram for caching IO etc. There are many sources about that mechanism, I recommend diving a little bit deeper when it comes to the role of swap in mordern OSes.

bartoszmackiewicz
Автор

Now I'm always going to pronounce SuDu instead of Sudo😂😂

ashutoshmourya
Автор

best video. super easy how you explain it!
It works. now I am running 12 swap on a 4gb mac.

diazdev
Автор

Before I go, you can use a safer alternative by setting the EDITOR env var and issuing "sudoedit <file>" which uses a temp file like visudo for security purposes and when you save your changes tells you how many likes were changed or if you made any changes at all. That way if you made no changes but still try to save on exit you don't affect the mod timestamp. I feel safer using sudoedit.

OctaviusPelagius
Автор

DT: I’m never going to use up 64GB of ram
Chrome: *Challenge Accepted*

serratedwarstep
Автор

Thanks dt! Today I installed Linux for the first time in my main laptop and this video was very helpful!

lorenzomelotto
Автор

Thank you very much!!

Awesome video🔥

Deegan_Prashanth
Автор

It's a little bit trickier to set up hibernation with swap files tho. But don't worry, the Wiki has a very well explained section.

juxuanu
Автор

i keep getting a invalid argument when i try running swapon, im running on manjaro xfce

i followed all your instructions but when i tried the swapon /swapfile it said invalid argument

Purpbatboi
Автор

Hey DT, how did you get that network thingy in your bar? (Like what script in your gitlab? I can't see to find it there)

millankumar
Автор

Hey DT, why do we call the GNU/Linux system GNU *slash* Linux when slash is usually used for substitution? Should we not say GNU *on* Linux, since it’s the GNU system on the Linux kernel?

enderger
Автор

Try running Android studio, with flutter and Genymotion emulator, 30+ tabs open in Brave.
Suddenly 40GB of RAM starts looking small

chigozie
join shbcf.ru