Is there any program to check swap filesystem?

D

Deleted member 143446

Guest
I have a seperate USB drive(/dev/sdd). I formatted it as swap-linux partition & I used it as swap partition. Today Debian warns that read-write error occured in swap partition but I could not find a way to check(like fsck) whether there is a bad sector on device /dev/sdd? Is there any program to check swap filesystem? Any help is appreciated.
 


Try
Bash:
$ sudo smartctl -a /dev/sdd
$ sudo smartctl -a /dev/sdd | grep -i error
This will give you hardware level errors, independent of any filesystem issues.
The first line will give all output. Second line will only show output that includes "error", cleaning up the output.

You might need to install smartmontools to use this command.
 
Try
Bash:
$ sudo smartctl -a /dev/sdd
$ sudo smartctl -a /dev/sdd | grep -i error
This will give you hardware level errors, independent of any filesystem issues.
The first line will give all output. Second line will only show output that includes "error", cleaning up the output.

You might need to install smartmontools to use this command.
Thanks @SlowCoder. Do I need to deactivate swap partition before doing that?
 
You should also check if the usb connection was lost at some point.

Code:
sudo dmesg | grep sdd

[ 9766.005786]  sdd: sdd1
[ 9766.009791] sd 8:0:0:0: [sdd] Attached SCSI removable disk

this only works if the system was not restarted after the error occured. In any case, i would not recommend using a removable drive as swapspace unless you absolutely need it.
 
How much ram does your system have.

If your system has 8.0GB or more ram I wouldn't really be concerned with swap.

With 8.0GB or more ram your system ain't going to be swapping unless you are using memory intensive programs and are running out of ram.
 
@SlowCoder I used :
$ sudo smartctl -a /dev/sdd
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-8-amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sdd: Unknown USB bridge [0x0011:0x7788 (0x103)]
Please specify device type with the -d option.

Use smartctl -h to get a usage summary
@Bartman , I have 2 GB RAM so I used 8 GB wap space with USB.
[Edit] Even with that configuration, I have some memory problems like Eclipse, GIMP or Blender etc.
[Edit#2] I tried using -d but I can not use it with -a, gives error too [Edit#3] :

$ sudo smartctl -d auto -a /dev/sdd
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-8-amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sdd: Unknown USB bridge [0x0011:0x7788 (0x103)]
Please specify device type with the -d option.

Use smartctl -h to get a usage summary
 
Last edited by a moderator:
In any case, i would not recommend using a removable drive as swapspace unless you absolutely need it.
[Edited]@SlowCoder @dobeshow do you mean USB swap will be slower than hard disk? Or does it cause other more serious problems? Thanks.
[Edited] I am sorry dobeshow.
 
Last edited by a moderator:
Until recently all of my computers were at 4.0GB of ram so I understand needing a swap partition.

What is your level of swappiness set at.

You can check with this command.
Code:
cat /proc/sys/vm/swappiness

You can change the swappiness level with this command.
Code:
sudo sysctl vm.swappiness=10

You can make it permanent with this command.
Code:
sudo sed -i '$ a\vm.swappiness = 10' /etc/sysctl.conf

When finished a reboot is needed to complete changes.

You may or may not see a slight boost in speed by lowering level of swappiness.
 
cat /proc/sys/vm/swappiness
After your post, I search what is the swapiness and found in RedHat's page here. It also mentioned about distress level etc. I found it is very useful :) I'm learning new terms : distress - swap tendency etc. However, as I read. It is like a computer program or a algorithm chart having lots of "if-else" structures but it seems a little more complicated since everywhere is full of new terms and concepts which are not so easy to understand in minutes...

You suggested that :

sudo sysctl vm.swappiness=10

That means according to RedHat page :
Users who would like to never see application memory swapped out can set swappiness to a low value, say 5 or 10, causing the kernel to ignore process memory until the distress value gets quite high.
What does that mean? What is process memory then? And which ones has the variable value distress or mapped-ratio? Swap tendency is calculated by kernel itself, so can I adjust distress and mapped-ratio?
So, according to your suggestion what should be the distress and mapped-ratio for me?... : ‍ ‍ ‍:eek: who am i ...where am i?...
 
A high level of swappiness 60 is way to much and writes to the swap partition on the hard drive a lot.

Lowing the level of swappiness to a lower more reasonable level 10 cuts down on the amount writes to the swap partition on the hard drive.

If using a SSD than the lower amount of writes to the SSD increases the longevity of the SSD.
 
You can also use..

swapon -s -v
 
@SlowCoder do you mean USB swap will be slower than hard disk? Or does it cause other more serious problems? Thanks.
It wasn't me that said that, but I'll try to answer your question: It depends on the architecture. Internal SATA II max transfer rate is about 3GB/s. SATA III max transfer rate is 6GB/s. But that's not the actual rate, because it further depends on the speed of the device connected to the SATA interface, which is typically a lot slower. A traditional 5400rpm platter drive tops out around 90MB/s, but SSD is a lot faster, often at least twice as fast.

NVME SSD drives are even faster.

Now, moving on to USB interface speeds: USB 2 is rated at 480MB/s. USB 3 is rated at 5GB/s. Just like with SATA, the actual maximum speed is usually limited by the connected device.

So take the lowest combination of values and that is close to the best you'll get from that interface, and usually a bit less.

A high level of swappiness 60 is way to much and writes to the swap partition on the hard drive a lot.

Lowing the level of swappiness to a lower more reasonable level 10 cuts down on the amount writes to the swap partition on the hard drive.

If using a SSD than the lower amount of writes to the SSD increases the longevity of the SSD.
Yep. My swappiness is 10, saving my SSD. But I have 20GB RAM, and hardly ever hit swap anyway.
 
I use Gnome Disk Utility to check disks.

1658252443457.png


1658252490651.png
 
@SlowCoder, I am still trying to work with smartctl but no result, do you mind if you help a little bit more about smartctl? I am stil have the same error.
 
@Bartman , I installed gnome disk utility but the option "check file system" option in settings for the swap formatted drive is disabled, so I can not use it.
 
I don't check for swap errors using gnome disk utility I use that for checking for the drive errors like bad sectors and such.

If your swap partition is on an external usb connected drive I'll lay ya odds that's is the reason you have errors although I may be wrong.

Being it's a usb connected device it's going to be slower to access when needed than an internal connected sata drive / device.

Anyway I'll leave it to the wiser than I as I'm just a Linux user and really am out a my Linux knowledge.

Oh don't try and learn to much to quick as you can become confused and get discouraged.

Learn little bits at a time.
 
It wasn't me that said that, but I'll try to answer your question: It depends on the architecture. Internal SATA II max transfer rate is about 3GB/s. SATA III max transfer rate is 6GB/s. But that's not the actual rate, because it further depends on the speed of the device connected to the SATA interface, which is typically a lot slower. A traditional 5400rpm platter drive tops out around 90MB/s, but SSD is a lot faster, often at least twice as fast.

NVME SSD drives are even faster.

Now, moving on to USB interface speeds: USB 2 is rated at 480MB/s. USB 3 is rated at 5GB/s. Just like with SATA, the actual maximum speed is usually limited by the connected device.

So take the lowest combination of values and that is close to the best you'll get from that interface, and usually a bit less.


Yep. My swappiness is 10, saving my SSD. But I have 20GB RAM, and hardly ever hit swap anyway.
Yes, and it's even less since this is in megabit. USB2 does around 20MB/s.
edit: If you suspect the disk itself is the problem and you can't live without swapspace on that disk, use a swapfile on an ext4 partition. But again, anything you have in the machine itself will most likely be faster even if it's on the system disk.
 
Last edited:

Members online


Top