 I don't typically create swap partitions or swap files on my main production machines. And the reason I don't do that on my main production machines is because they have so much RAM in them. My current main production machine has 64 gigs of RAM. So even if I created a swap, I'm never going to use it because I'm never going to use up all 64 gigs of RAM on this machine. It's never going to happen. But I try to remember to create swap partitions on video when I do my Linux installation guides. And the other day I did an Arch Linux installation guide. And I created a swap partition on that video just to show you guys how it was done. But people pointed out, hey, you've never shown us how to create a swap file. What if we prefer to create a swap file rather than a swap partition? Can you show us how to do that? And that's a great idea. Because I currently don't have a swap partition or a swap file on my main production machine, I'm going to show you guys how to create one. It's actually very easy. So let me switch over to the desktop here. I'm going to launch a terminal and let me zoom way in so you guys can see exactly what's going on here. Now, the first thing we need to do is create our swap file. And the program you need to use to create the swap file is the dd command. So with root privileges, of course, we need to sudo ddspace. And then set these values if equals if is the input file. So where are we taking input from and where are we writing it to, which of course will be the output file. So if input file equals slash dev slash zero space, OF equals for the output file is going to equals slash swap file, all one word, because the swap file needs to be in the root directory. The root directory, of course, is the slash symbol. So it's going to be at slash swap file space. And then set a value for BS equals BS is bite size. And for me, I'm going to set BS equals one capital M for one megabyte space and then count equals and I'm going to do 1024 because I want to create a one gigabyte swap file. How does that equal one gigabyte? Well, the dd command, we told it to use one megabyte chunks here. That's what BS equals one megabyte is. How many one megabyte chunks should DD use? They should use 1024 of them, 1024 one megabyte chunks equals one gigabyte. Hope that makes sense. Then, of course, it's going to ask for your root password and it was created successfully there. Now, swap files are very particular about their permissions. They have to be set to file permission 600. How do you do that? Well, you do sudo space chmod space 600 space slash swap file. And that sets the swap file to 600 for the permissions. If you don't do that, the swap file will complain and it will actually tell you this in the terminal. It will be like, hey, set the swap file to permission 600. So it's best to go ahead and take care of it right now. Now, just because we use the DD command to make that slash swap file, it's not really a swap until we make it a swap. How do you do that? sudo space MK swap for make swap space slash swap file. And you see, we get some output there. It gives us a UUID number, which we typically use UUID numbers to add something to the file system table. The F stab. You don't actually have to use UUID numbers with swap files. So we actually don't need this number. The next thing we need to do is turn the swap on. So do a su space swap on space slash swap file. And we don't get any output. But that's a good because no output means it worked correctly. We could verify it with swap on space dash dash show. And you see, we have a slash swap file and it is one gigabyte in size. Finally, we need to add our swap file to our F stab, our file system table. So I'm going to use VIM for this. But if you want to use nano or whatever editor you're comfortable with, it doesn't matter, but you need to be root or have root privileges. So I'm going to do sudo space VIM space slash Etsy slash FS tab and I hit enter. And I'm going to go to the last line and I'm going to hit O on the keyboard to create a new line and put me into insert mode. And then the first value you see is usually a UUID. But that's only for partitions. Remember the swap file is really just a file UUID numbers are not used for files. So this the file system column actually just needs to be the path to the swap file. So do slash swap file space and then I'm going to space over to this value here, which is the mount point for the mount point. I'm just going to write the word none and then I'm going to space over and then this is the type. It needs to be swapped. I'm going to space over and then this next options category. I'm just going to put defaults and I'm going to space over and where you see the two numbers here, it can just be zero space zero. And that should be all I need to do. I'm going to do an escape here in VM and then colon WQ for write and quit. And if everything worked out, all right, I should have swap when I reboot. So it was very easy to add a swap file. It's very easy to add a swap file when you're installing your Linux distribution. But even after the fact, you know, I've had this instance of Rco running for several weeks on my machine. I didn't create a swap partition or swap file when I did the installations. But you can see going back and adding a swap files very easy. In contrast, going back after the fact and trying to add a swap partition is a real nightmare. It's a headache because you don't want to go back after the fact and try to partition a drive because you can lose all your data. It's not worth it. I wouldn't try that. But when you're dealing with files, it's very easy to go back after the fact and just create a file or delete a file. Same thing with deleting a swap file. It's very easy to go back after the fact and delete one. As a matter of fact, I can show you how to delete that swap file I just created. The first thing you need to do is turn swap off because you can't delete a swap file if the swap is turned on. Well, let me show you. If I tried to do this, sudo rm for remove space slash swap file, it's going to give me an error. It says operation not permitted. The reason it's not permitted, you can't remove the swap file while swap is turned on. So let's turn swap off. I'm going to do a sudo swap off all one word space dash v. Give it the v flag space and then slash swap file. So we turn to swap off and now if I up arrow a couple of times to get back to that remove command sudo rm slash swap file. That actually works. If I do a ls on root, you will see in my root directory, I actually don't have a swap file. So we deleted that. And that's really all you need to do. Well, there's one other thing you should do. Go back into your fstab and delete that line we added. So I need to do a sudo vm space slash etsy slash fstab. I'm going to go back down to that last line and I'm going to do dd for delete line escape colon wq to write and quit. And just like that, that swap file that we had created and activated, we just deactivated it and removed it from our system. So swap files. I love them. They're much easier to work with than swap partitions. Now before I go, I need to think a few special people. I need to think Michael, Gabe, Corbinian, Mitchell, Devin Fran, Arch 5530, Akami Channel Chuck, Claudio, Dylan, George, Kelly Devils, Louis Paul, Scott and Willie, these guys. They are my highest tiered patrons over on Patreon. They are the producers of this episode without these guys, I wouldn't have been able to create and delete a swap file on camera. Well, I could have done it without them, but these guys are a big help. I also want to thank each and every one of these ladies and gentlemen, all these names you're seeing on the screen. These are all my supporters over on Patreon because this channel is supported by you guys, the community. You would like to support my work. I hope you considered doing so. Look for DistroTube over on Patreon. All right, guys. Peace.