mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-23 19:05:37 +00:00
swap: speed up preferring a 1MiB blocksize
If the swap disk is larger than 1MiB, then use a 1MiB blocksize in `dd` On my machine using a large block size speeds up swap file creation: ``` / # time dd if=/dev/zero of=output bs=1024 count=1048576 1048576+0 records in 1048576+0 records out real 0m 4.61s user 0m 0.79s sys 0m 3.77s / # time dd if=/dev/zero of=output bs=1048576 count=1024 1024+0 records in 1024+0 records out real 0m 1.06s user 0m 0.00s sys 0m 1.04s ``` Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
parent
4092a10063
commit
57dd4029c8
@ -123,7 +123,12 @@ fi
|
||||
|
||||
if [ ! -f $path ] || ! [ $(stat -c "%s" $path) == $(disksize_to_count 1 $size) ]; then
|
||||
## Allocate the file
|
||||
dd if=/dev/zero of=$path bs=1024 count=$(disksize_to_count 1024 $size)
|
||||
## If possible use a large blocksize:
|
||||
bs=1048576 # 1 MiB
|
||||
if [ "$size" -lt "$bs" ]; then
|
||||
bs=1024 # fall back to 1KiB
|
||||
fi
|
||||
dd if=/dev/zero of=$path bs=$bs count=$(disksize_to_count $bs $size)
|
||||
chmod 0600 $path
|
||||
|
||||
## was it encrypted? use cryptsetup and get the mapped device
|
||||
|
Loading…
Reference in New Issue
Block a user