Fix swap on linux+btrfs
This commit is contained in:
parent
0f8f8486f0
commit
09138174d4
1 changed files with 49 additions and 0 deletions
|
@ -1,6 +1,55 @@
|
|||
- name: Enable multiarch
|
||||
command: dpkg --add-architecture i386
|
||||
|
||||
- name: Create swap btrfs subvolume
|
||||
command: btrfs subvolume create /swap
|
||||
ignore_errors: True
|
||||
|
||||
- name: Create swap directory if it does not exist
|
||||
file:
|
||||
path: /swap
|
||||
state: directory
|
||||
|
||||
- name: Create btrfs swap
|
||||
command: btrfs filesystem mkswapfile --size 4g /swap/swap.img
|
||||
ignore_errors: True
|
||||
|
||||
- name: Create swap image if it does not exist
|
||||
shell: fallocate -l 4G /swap/swap.img && mkswap /swap/swap.img
|
||||
args:
|
||||
creates: /swap/swap.img
|
||||
ignore_errors: True
|
||||
|
||||
- name: Change swap file permissions
|
||||
file: path="/swap/swap.img"
|
||||
owner=root
|
||||
group=root
|
||||
mode=0600
|
||||
|
||||
- name: Write swap entry in fstab
|
||||
mount: name=none
|
||||
src=/swap/swap.img
|
||||
fstype=swap
|
||||
opts=sw
|
||||
passno=0
|
||||
dump=0
|
||||
state=present
|
||||
|
||||
- name: Activate swap
|
||||
command: "swapon /swap/swap.img"
|
||||
ignore_errors: True
|
||||
|
||||
- name: Make sure default swap entry does not exist
|
||||
mount:
|
||||
path: none
|
||||
src: /swap.img
|
||||
fstype: swap
|
||||
state: absent
|
||||
|
||||
- name: Make sure default swap is not used
|
||||
command: swapoff /swap/swap.img
|
||||
ignore_errors: True
|
||||
|
||||
- name: Install generally useful packages
|
||||
apt:
|
||||
name:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue