EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Moderator: BarryK

Post Reply
Caramel
Posts: 532
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 106 times
Been thanked: 95 times

EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Post by Caramel »

A file .easyos-bootcnt (with a number that increases by 1 every boot) is appeared in the directory /mnt/wkg.

This file is created or modified by init at boot when the variable TRIMflg is defined (lines 1547 to 1555)

The initialization or not depends of a test on the result of cat /sys/block/${WKG_DRV}/queue/discard_granularity ( lines 1087 to 1092)

In my PC there is no SSD but TRIMflg is initialized to 1.

If the boot count reaches 20 the command fstrim is called by init.

I do not know what would be the effect on a HDD (nor even if the command is executed) but by precaution i will delete .easyos-bootcnt at each boot.

User avatar
BarryK
Posts: 2871
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 149 times
Been thanked: 788 times

Re: EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Post by BarryK »

Way back when I implemented that, it was a recommended way to differentiate between a hdd and a ssd.

Testing on my computer, with 6.12.10 kernel:

Code: Select all

# cat /sys/block/[ns]*/queue/discard_granularity
512
512
4096
512
512
# ls -1 /sys/block/[ns]*/queue/discard_granularity
/sys/block/nvme0n1/queue/discard_granularity
/sys/block/nvme1n1/queue/discard_granularity
/sys/block/sda/queue/discard_granularity
/sys/block/sdb/queue/discard_granularity
/sys/block/sr0/queue/discard_granularity

sda is a hdd
nvme0n1, nvme1n1, sdb are ssds -- the last is usb ssd.

OK, this needs to be revised. The init script tests discard_granularity and if not zero then sets TRIMflg to 1.

User avatar
BarryK
Posts: 2871
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 149 times
Been thanked: 788 times

Re: EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Post by BarryK »

I checked with the 6.6.73 kernel, discard_granularity works as expected, with value 0 for drives not supporting trim.

Arch Linux:
https://wiki.archlinux.org/title/Solid_state_drive

And check the values of DISC-GRAN (discard granularity) and DISC-MAX (discard max bytes) columns. Non-zero values indicate TRIM support.

Unfortunately, for the 6.12.x kernel that is no longer completely true.
However, discard_max_bytes is still OK:

Code: Select all

# cat /sys/block/[ns]*/queue/discard_max_bytes
2199023255040
2199023255040
0
0
0
0
# ls -1 /sys/block/[ns]*/queue/discard_max_bytes
/sys/block/nvme0n1/queue/discard_max_bytes
/sys/block/nvme1n1/queue/discard_max_bytes
/sys/block/sda/queue/discard_max_bytes
/sys/block/sdb/queue/discard_max_bytes
/sys/block/sdc/queue/discard_max_bytes
/sys/block/sr0/queue/discard_max_bytes

I will change the init script in the initrd to test discard_max_bytes

User avatar
BarryK
Posts: 2871
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 149 times
Been thanked: 788 times

Re: EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Post by BarryK »

There is still a problem. sdb is my usb ssd, which is a samsung sata 870 evo, which should support trim.

This is an interesting read:
https://kb.plugable.com/data-storage/tr ... d-in-linux

And this:
https://en.wikipedia.org/wiki/USB_Attached_SCSI

USB attached scsi prorotol (uasp):

Enables TRIM (UNMAP in SCSI terminology) operation for SSDs

I will recompile the 6.12.x kernel with this enabled:

https://www.kernelconfig.io/config_usb_uas

Caramel
Posts: 532
Joined: Sun Oct 02, 2022 6:25 pm
Location: France
Has thanked: 106 times
Been thanked: 95 times

Re: EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Post by Caramel »

Other links :

https://wiki.gentoo.org/wiki/SSD#Discar ... 29_support
https://wiki.gentoo.org/wiki/Discard_over_USB

On the last page :

Prerequsites

A USB3 link to the FLASH device. USB2 cannot support trim.
A USB3 to FLASH bridge that actually supports trim

Edit : the change in the kernel has taken place in version 6.8
https://kernelnewbies.org/Linux_6.8
https://git.kernel.org/pub/scm/linux/ke ... 65b411a50c

User avatar
BarryK
Posts: 2871
Joined: Tue Dec 24, 2019 1:04 pm
Has thanked: 149 times
Been thanked: 788 times

Re: EasyOS 6.5.6 - Internal HDD seen as a SSD in init

Post by BarryK »

I have implemented what is hopefully a fix:

https://bkhome.org/news/202501/hopeful- ... b-ssd.html

EDIT:
This is a good read:

https://www.jeffgeerling.com/blog/2020/ ... spberry-pi

Post Reply

Return to “EasyOS”