Solved Cannot change swap file size in Ubuntu 24.04

Solved issue
SO, reboot your pc and run ;
Code:
sudo swapon --show
Thanks, here is the output of sudo swapon --show:
NAME TYPE SIZE USED PRIO
/swapfile file 10G 2.6G -2
/swap.img file 4G 0B -3
 


It would be good to get an output from

Code:
cat /etc/fstab

Wiz
Thanks, here it is:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/nvme0n1p5 during curtin installation
/dev/disk/by-uuid/10ee13a5-bc35-42e8-88e2-a8e0c412c538 / ext4 defaults 0 1
# /boot/efi was on /dev/nvme0n1p1 during curtin installation
/dev/disk/by-uuid/FA4D-FBB0 /boot/efi vfat defaults 0 1
/swap.img none swap sw 0 0
/dev/disk/by-uuid/01DADA7CB9415F40 /media/lafenice/SSD2 auto nosuid,nodev,nofail,x-gvfs-show,noauto,x-gvfs-icon=SSD 0 0
/dev/disk/by-uuid/01DADA60D581CC60 /media/lafenice/MUSICA\040&\040VIDEO auto nosuid,nodev,nofail,x-gvfs-show,noauto,x-gvfs-icon=Multimedia 0 0
/dev/disk/by-uuid/01DAD9DA51E5BF00 /media/lafenice/DATA auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-icon=Data 0 0
/dev/disk/by-uuid/54BC56CBBC56A6F0 /media/lafenice/WINDOWS\04011 auto nosuid,nodev,nofail,x-gvfs-show,noauto,x-gvfs-icon=WindowsLogo 0 0
/dev/disk/by-uuid/01D29F1808F76C30 /media/lafenice/FENICE auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-icon=Phoenix1 0 0
/swapfile none swap sw 0 0
 
Last edited:
@lymphor

First of all, delete the older swap.img from your fstab if it doesn't exist. Second, either there are 2 swap files, or you might be using something like Zram or other memory compression thing which might be acting like a swap (idk if it works like that). Run the "sudo swapon --show" command as @Condobloke said.
Thanks, looking at the output of the "sudo swapon --show" it seems there is a swap.img file in my PC, therefore I suppose I don't have to delete its entry in fstab, correct?
 
I did, but whatever size I input for the new swap file the result is always 5GB more. I want 10GB, but I get 15GB.
I suspect I somehow have 2 swap files, because when I run sudo swapoff -v /swapfile my system has 4.3GB of swap memory. And if I run sudo swapon /swapfile the size increases to 15GB.
This is the content of my fstab file, maybe someone has some time to look into it and tell me what is wrong:
Code:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p5 during curtin installation
/dev/disk/by-uuid/10ee13a5-bc35-42e8-88e2-a8e0c412c538 / ext4 defaults 0 1
# /boot/efi was on /dev/nvme0n1p1 during curtin installation
/dev/disk/by-uuid/FA4D-FBB0 /boot/efi vfat defaults 0 1
/swap.img       none    swap    sw      0       0
/dev/disk/by-uuid/01DADA7CB9415F40 /media/lafenice/SSD2 auto nosuid,nodev,nofai>
/dev/disk/by-uuid/01DADA60D581CC60 /media/lafenice/MUSICA\040&\040VIDEO auto no>
/dev/disk/by-uuid/01DAD9DA51E5BF00 /media/lafenice/DATA auto nosuid,nodev,nofai>
/dev/disk/by-uuid/54BC56CBBC56A6F0 /media/lafenice/WINDOWS\04011 auto nosuid,no>
/dev/disk/by-uuid/01D29F1808F76C30 /media/lafenice/FENICE auto nosuid,nodev,nof>
/swapfile none swap sw 0 0
The current issue appears to be that the system is showing 5GB more swap than you believe you have allocated. Perhaps there is a left over swap file somewhere. In the first instance to investigate you could run the following commands to see if they all agree, or not, on the amount of swap allocated by the user. The results shown are those of a machine here with a swap partition rather than a file, but the significant point is that they all agree with the user's original allocation of swap:
Code:
[tom@min ~]$ grep -i swap /proc/meminfo
SwapCached:            0 kB
SwapTotal:      15625212 kB
SwapFree:       15625212 kB
Zswap:                 0 kB
Zswapped:              0 kB

[tom@min ~]$ cat /proc/swaps
Filename                                Type            Size    Used             Priority
/dev/nvme0n1p2                          partition       156252120-2

[tom@min ~]$ free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi       2.6Gi        10Gi       168Mi       2.4Gi        12Gi
Swap:           14Gi          0B        14Gi

[tom@min ~]$ swapon -s
Filename                                Type            Size    Used             Priority
/dev/nvme0n1p2                          partition       156252120-2

If extra swap you can't account for is reported, then there are ways to find a errant file of it.
 
Last edited:
@lymphor, it would seem the dreaded time zone differences are going to get you !....both wizardfromoz and opsprey are in Australia....wizard from oz will not appear here for another 13 hours, minimum, and osprey probably much the same....although he was still online up until 10 minutes ago
gators fan is much closer to your timezone, so you may get advice from him in the meantime.
 
Thanks, here is the output of sudo swapon --show:
NAME TYPE SIZE USED PRIO
/swapfile file 10G 2.6G -2
/swap.img file 4G 0B -3
That literally means you have 2 swap files in your root directory. The swap.img is where you are getting the extra swap space from. If you don't want that (I mean yeah, why would you want 2 swap files?), then delete it and also delete the entry from /etc/fstab.
 
Ladies and gentlemen: VICTORY! The problem was the swap.img file that was adding 5GB more to the total swap size. I deleted it from root, then I deleted its corresponding line in etc/fstab and now is all good. I did a restart of the PC to be sure, all good. Thank you all guys, you rule! ;)
 
It's generally best to use a swap partition rather than a swap file. If you must use a swap file you can use dd to make one.

/usr/bin/dd if=/dev/zero of=/swapfile bs=4M count=HoweverMuchYouNeed status=progress

This will create a file of 4M blocks * count blocks. Then use mkswap /swapfile to set it up. Copy the UUID from the output of mkswap and add it to your /etc/fstab to make sure it gets activated when your system boots up. Make sure the UUID is unique. Each UUID must be unique.

Using swapping for extra memory will really slow things down. I have 16 GB on my Linux desktop and only use about half of that. I have to wonder why you need so much. I use kdenlive too. If your hard drive or the connection to it is less than reliable it could corrupt your system's memory and cause a crash. Don't connect your hard drive to a USB hub. Make a direct connection and if possible use a separate USB bus for your hard drive. A USB bus can and does fill up. The network capacity can get used up.

Signed,

Matthew Campbell
 
It's generally not a good idea to list so much information about your system hardware and/or software unless you are asking a question and such information is needed in order to answer that question. Bad hackers really appreciate it when people do that as it can make information gathering so much easier. I am referring to your signature on your posts.

Signed,

Matthew Campbell
 
Using swapping for extra memory will really slow things down. I have 16 GB on my Linux desktop and only use about half of that. I have to wonder why you need so much. I use kdenlive too. If your hard drive or the connection to it is less than reliable it could corrupt your system's memory and cause a crash. Don't connect your hard drive to a USB hub. Make a direct connection and if possible use a separate USB bus for your hard drive. A USB bus can and does fill up. The network capacity can get used up.

Signed,

Matthew Campbell
Hi Matthew, thank you for your intervention. I need more swap size than default because rendering in Kdenlive consumes all of my regular 8GB RAM plus another 8GB swap memory. I find it very suspicious because last month I was rendering the same exact project using Ubuntu 22.04 and a less powerful CPU, a Ryzen 5 1500X, and I did not have this issue. The video is also not so impressive: 4min 30sec in lenght, Full HD, H.264 codec. So nothing special, really.

If your hard drive or the connection to it is less than reliable it could corrupt your system's memory and cause a crash. Don't connect your hard drive to a USB hub. Make a direct connection and if possible use a separate USB bus for your hard drive. A USB bus can and does fill up. The network capacity can get used up.
Thank you, all my drives are internal ones. I have a PCIe 3.0 x4 M.2 SSD which I use for OSs and some data storing, and there's where the swap file is located. The rest of drives are regular SATA3 HDDs/SSDs.
 
It's generally not a good idea to list so much information about your system hardware and/or software unless you are asking a question and such information is needed in order to answer that question. Bad hackers really appreciate it when people do that as it can make information gathering so much easier. I am referring to your signature on your posts.
Thank you, I deleted the info from my signature. I was not aware of the risks, I thought I make life easier for those willing to help me. Gracias! ;)
 
Short answer: no.
Long answer (sorry but there's no medium lenght answer :p) : first of all, I'm not sure I need a dedicated GPU. As far as I know, in my case, the CPU is much more important, because it takes care of the rendering (that is the process of making a new video file from the original footage). If I'm correctly informed, for video editing the GPU must only be capable of outputting a 4k resolution video image.
For the sake of correct information I must say I was wrong about the GPU. Here's what a more experienced user, @MikeWalsh, shared in another thread:
"I don't have a dedicated GPU" - Mm-hm. Again, many of them are also written nowadays to 'offload' rendering & other related processor-intensive stuff TO your dedicated GPU (if you have one). Simple reason is that a GPU is far better suited to what's termed "massively parallel processing" than a CPU is; it's all to do with the architectures used by the two different types of hardware. GPUs are designed specifically for parallel processing of large numbers of threads simultaneously (this is ideal for video-rendering); CPUs, on the other, are optimized to be "general workhorses".....able to handle all sorts of stuff.
 

Staff online

Members online


Top