2

I couldn't find any explicit references to this: if I change the block size on a device, will existing data be destroyed?

Please note that this is a different question from "is there a risk of losing data". As one always should, I do have a backup. I'm just wondering if there's a point trying to do this, or if the data will be destroyed for sure and, therefore, I should plan for a different process for the operation.

Ratler
  • 133

1 Answers1

1

If you mean changing the (filesystem) block size with the mkfs command there (mkfs -t ext4 -b 4096 /dev/vdb1), then yes, that will destroy the filesystem and make your data inaccessible. (Not strictly gone, you could still read the blocks from the device and find most of the data.)

But, there's no need to run that. The default block size for your usual ext4 filesystem is 4096. Smaller blocksizes would lead to more filesystem overhead (unless you have a really large set of small files), and won't match the block size of modern disks. Larger block sizes might be useful for filesystems with mostly (only) large files, but Linux on x86 systems can't use bigger ones, since the block size is tied to the system page size.

ilkkachu
  • 138,973
  • Thanks, that answers the question. I asked how to do that because I discovered that a disk has block size of 512 (not sure how that happened in the first place), so I wanted to change it to 4096. – Ratler Jul 06 '18 at 16:06
  • Hard drives have physical block sizes of either 512 or 4096. 512 was the custom for decades, but current drives have 4096. (At least larger ones, I haven't checked what smaller drives use.) So 512 is totally normal. – ilkkachu Jul 06 '18 at 16:11