diff --git a/content/docs/latest/setup/storage/adding-swap.md b/content/docs/latest/setup/storage/adding-swap.md index 26878d8d..4c9ce191 100644 --- a/content/docs/latest/setup/storage/adding-swap.md +++ b/content/docs/latest/setup/storage/adding-swap.md @@ -62,11 +62,12 @@ systemd provides a specialized `.swap` unit file type which may be used to activ The following commands, run as root, will make a 1GiB file suitable for use as swap. +> From Flatcar 4186, one can directly use mkswap to create a swap file as follow. For older Flatcar versions, you still need to create a swap file with `dd if=/dev/zero of=/var/vm/swapfile1`, `chmod 600 /var/vm/swapfile1` and `mkswap /var/vm/swapfile1` + + ```shell mkdir -p /var/vm -fallocate -l 1024m /var/vm/swapfile1 -chmod 600 /var/vm/swapfile1 -mkswap /var/vm/swapfile1 +mkswap --size 1024m --file /var/vm/swapfile1 ``` ### Creating the systemd unit file @@ -169,9 +170,7 @@ systemd: [Service] Type=oneshot ExecStart=/usr/bin/mkdir -p /var/vm - ExecStart=/usr/bin/fallocate -l 1024m /var/vm/swapfile1 - ExecStart=/usr/bin/chmod 600 /var/vm/swapfile1 - ExecStart=/usr/sbin/mkswap /var/vm/swapfile1 + ExecStart=/usr/bin/mkswap --size 1024m --file /var/vm/swapfile1 RemainAfterExit=true ```