I use UbuntuStudio 18.04.1 LTS into an HP 250 G5 laptop computer.
It has an internal SATA 1 TB hard disk, partitioned with the EFI, ROOT, and HOME partitions. EFI partition is formatted as FAT. ROOT and HOME partition are formatted as ext4. Of course, there is a SWAP partition too.
The issue is that the command: stat .bash_logout, tells me that the hard disk sector size is 4096. But, Gparted tells me that the hard disk sector size is only 512!
Why the difference?
If the real sector size is 512... Can I change it to 4096, without to lose data? How?
It is impossible to change the hard disk's sector size. It is a characteristic of the hard disk itself.
What you are probably witnessing is a hard disk whose sector size is 4096 internally, but which presents itself to your computer as having a sector size of 512, for compatibility with legacy mainboards and operating systems who may not yet support 4096 byte sector sizes natively. The disk translates the requests for the logical 512 byte sectors into requests for the actual 4096 byte sectors internally, and the computer does not have to know this is happening. Appropriate buffering ensures there are no slow-downs.
This does not represent a problem and shouldn't cause any performance issue assuming that your filesystem's cluster size is still 4096, or a multiple thereof, and your partitions start on a sector boundary, which they will if they use the modern convention of starting on a multiple of 1MiB.
To check filesystem cluster size you can use
stat -f .
(include the dot). This should list the block size of your current filesystem which will most likely be 4096. Note that if you have multiple partitions this can differ between them.To check the partition boundaries, use
sudo fdisk -l
. At the top it'll list the logical sector size which in your case is likely 512 bytes. Make sure all the partitions start on a multiple of 8 such sectors (they will most likely be a multiple of 2048, which is itself a multiple of 8).Note that all modern versions of Ubuntu will enforce the above for all new installations.
On some drives there is a procedure, using manufacturer-supplied software tools, for upgrading the drive itself from 512 byte logical sectors (512e mode) to 4096 byte logical sectors (4k native mode). What this will do is remove the translation layer in the drive which translates between emulated 512 byte sectors on the host side and the actual 4096 byte sectors on the drive. The physical sector size will stay at 4096 bytes. This procedure is usually accompanied by a low level fast format of the drive. The performance benefit is likely to be negligible assuming you were using a 4096 byte (or multiple) cluster size and partition alignment anyway as discussed.