Re: Initdb-time block size specification

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>, Andres Freund <andres(at)anarazel(dot)de>
Cc: David Christensen <david(dot)christensen(at)crunchydata(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>
Subject: Re: Initdb-time block size specification
Date: 2023-06-30 23:18:34
Message-ID: 1189bf95-8709-e689-6816-c2d3a86276a3@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/1/23 01:16, Bruce Momjian wrote:
> On Fri, Jun 30, 2023 at 04:04:57PM -0700, Andres Freund wrote:
>> Hi,
>>
>> On 2023-06-30 18:58:20 -0400, Bruce Momjian wrote:
>>>> [1] On linux I think you need to use stat() to figure out the st_dev for a
>>>> file, then look in /proc/self/mountinfo for the block device, use the name
>>>> of the file to look in /sys/block/$d/queue/physical_block_size.
>>>
>>> I just got a new server:
>>>
>>> https://momjian.us/main/blogs/blog/2023.html#June_28_2023
>>>
>>> so tested this on my new M.2 NVME storage device:
>>>
>>> $ /sys/block/nvme0n1/queue/physical_block_size
>>> 262144
>>
>> Ah, I got the relevant filename wrong. I think it's logical_block_size, not
>> physical one (that's the size of addressing). I didn't realize because the
>> devices I looked at have the same...
>
> That one reports 512 _bytes_ for me:
>
> $ cat /sys/block/nvme0n1/queue/logical_block_size
> 512
>

What does "smartctl -a /dev/nvme0n1" say? There should be something like
this:

Supported LBA Sizes (NSID 0x1)
Id Fmt Data Metadt Rel_Perf
0 - 4096 0 0
1 + 512 0 0

which says the drive supports 4k and 512B sectors, and is currently
configures to use 512B sectors.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2023-06-30 23:26:12 Re: Initdb-time block size specification
Previous Message Bruce Momjian 2023-06-30 23:16:18 Re: Initdb-time block size specification