4

This post gives this command to resize swap

sudo dd if=/dev/zero of=/swapfile bs=1G count=8

Does the blocksize (bs) value in swap settings matter? If yes, is there a command to show current settings about swap block size?

If swap block size really affect something, I would like to know what it would be before I modify the settings.

If not, please explain a little bit why swap block size would not actually affect the performance of swap.

Some additional reference would be better.

4
  • I don't think the blocksize (bs) value that you pass to dd has any effect on the properties of the swapfile that's generated - it just tells dd what sized blocks of zero bytes to read and write when initializing the file. (A file doesn't really have a blocksize - that's a property of the filesystem on which it resides.) Sep 8, 2019 at 0:29
  • @steeldriver Thanks a lot! Please move your comments to answer, I'll accept it.
    – czlsws
    Sep 8, 2019 at 0:39
  • I'll wait a bit in case anyone who understands it better provides an answer... Sep 8, 2019 at 0:50
  • What makes the file a swap area is the mkswap-command which is issued after the dd-command.
    – mook765
    Sep 8, 2019 at 1:49

2 Answers 2

2

According to the following link, this is the way to read the NUL bytes in /dev/zero (using blocks), only the bs x count value matters.

https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

1

According to https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/ the block size is the number of bytes to read and write at a time. Most places recommend 1k (1024). The following article shows a way to determine the best block size.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .