0

I'm trying to add more memory (RAM) on my Ubuntu Desktop 24.04, as my memory is running low for my Django project.

I'm also implementing Elasticsearch. I plugged in an empty 8GB USB drive to swap out the memory for this flash drive.

But I keep getting an error in my local terminal. Here is the error message I get

corey-james@corey-james-HP-Laptop-14-dq0xxx:~$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0     4K  1 loop /snap/bare/5
loop1          7:1    0  73.9M  1 loop /snap/core22/1802
loop2          7:2    0  74.2M  1 loop /snap/core22/1621
loop3          7:3    0  11.7M  1 loop /snap/desktop-security-center/32
loop4          7:4    0  11.7M  1 loop /snap/desktop-security-center/51
loop5          7:5    0  10.7M  1 loop /snap/firmware-updater/127
loop6          7:6    0   272M  1 loop /snap/firefox/5091
loop7          7:7    0  11.1M  1 loop /snap/firmware-updater/167
loop8          7:8    0 505.1M  1 loop /snap/gnome-42-2204/176
loop9          7:9    0   516M  1 loop /snap/gnome-42-2204/202
loop10         7:10   0     1G  1 loop /snap/intellij-idea-community/588
loop11         7:11   0  91.7M  1 loop /snap/gtk-common-themes/1535
loop12         7:12   0  89.7M  1 loop /snap/gtk-common-themes/1536
loop13         7:13   0  14.4M  1 loop /snap/prompting-client/87
loop14         7:14   0    14M  1 loop /snap/prompting-client/51
loop15         7:15   0 822.3M  1 loop /snap/pycharm-community/465
loop16         7:16   0  38.8M  1 loop /snap/snapd/21759
loop17         7:17   0  10.8M  1 loop /snap/snap-store/1248
loop19         7:19   0   564K  1 loop /snap/snapd-desktop-integration/247
loop20         7:20   0  44.4M  1 loop /snap/snapd/23771
loop21         7:21   0   568K  1 loop /snap/snapd-desktop-integration/253
loop22         7:22   0  10.8M  1 loop /snap/snap-store/1270
sda            8:0    0 465.8G  0 disk 
└─sda1         8:1    0 465.8G  0 part /media/corey-james/Backup
sdb            8:16   1   7.5G  0 disk 
└─sdb1         8:17   1   7.5G  0 part /media/corey-james/94A9-586A
mmcblk0      179:0    0 116.5G  0 disk 
├─mmcblk0p1  179:1    0   260M  0 part /boot/efi
├─mmcblk0p2  179:2    0    16M  0 part 
├─mmcblk0p3  179:3    0  57.4G  0 part 
├─mmcblk0p4  179:4    0   874M  0 part 
└─mmcblk0p5  179:5    0  57.9G  0 part /
mmcblk0boot0 179:8    0     4M  1 disk 
mmcblk0boot1 179:16   0     4M  1 disk 
corey-james@corey-james-HP-Laptop-14-dq0xxx:~$ cd /media/corey-james/94A9-586A
corey-james@corey-james-HP-Laptop-14-dq0xxx:/media/corey-james/94A9-586A$ ls
corey-james@corey-james-HP-Laptop-14-dq0xxx:/media/corey-james/94A9-586A$ sudo swapoff -a
[sudo] password for corey-james: 
corey-james@corey-james-HP-Laptop-14-dq0xxx:/media/corey-james/94A9-586A$ sudo swapoff -a
corey-james@corey-james-HP-Laptop-14-dq0xxx:/media/corey-james/94A9-586A$ sudo swapon /dev/sdb1
swapon: /dev/sdb1: read swap header failed

/etc/fstap/

  GNU nano 8.1                       /etc/fstab *                               
# /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/mmcblk0p5 during curtin installation
/dev/disk/by-uuid/651c2f97-8d81-4f57-9e09-7e100e72ae78 / ext4 defaults 0 1
# /boot/efi was on /dev/mmcblk0p1 during curtin installation
/dev/disk/by-uuid/682A-BDA1 /boot/efi vfat defaults 0 1
/swap.img       none    swap    sw      0       0
tmpfs  /opt/omd/sites/arborhub/tmp tmpfs noauto,user,mode=751,uid=arborhub,gid=>
/swapfile none swap defaults 0 0

Output from free -h

               total        used        free      shared  buff/cache   available
Mem:            14Gi       8.8Gi       4.3Gi       696Mi       2.8Gi       6.1Gi
Swap:          4.0Gi          0B       4.0Gi

sudo swapoff -a' & 'sudo swapon are the commands I wrote for the partition. I guess I'm trying to mount the USB drive.

Please I need help

1 Answers1

4

The error read swap header failed implies you haven't formatted the partition as swap. You'd need to sudo mkswap /dev/sdb1 before you may be able to use it as swap.

That said, I don't think using an external flash drive as swap device is a good idea, because they're typically pretty slow. I'd rather recommend you to use your system disk by either using a swap-file or by simply reducing the partition size to make room for swap partition.

If you really have to use slow device as swap, you may also be interested in creating compressed swap device.

Hi-Angel
  • 4,810