swap:enabling_swap
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
swap:enabling_swap [2016/11/16 16:51] – peter | swap:enabling_swap [2019/12/04 21:44] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Swap - Enabling swap ====== | ||
- | |||
- | check to see if you have swap partitions defined by consulting **/ | ||
- | |||
- | <code bash> | ||
- | grep swap / | ||
- | </ | ||
- | |||
- | Returns something like this. | ||
- | |||
- | < | ||
- | UUID=14a0f7b9-dabb-4296-b0e7-013527a7d82d none swap sw 0 0 | ||
- | </ | ||
- | |||
- | If one is defined you can check that it is being used by the system: | ||
- | |||
- | <code bash> | ||
- | swapon -s | ||
- | </ | ||
- | |||
- | Returns | ||
- | |||
- | < | ||
- | Filename Type Size Used Priority | ||
- | /dev/sda6 partition 1004020 215532 -1 | ||
- | </ | ||
- | |||
- | If one is defined but not in use the obvious thing to do is check that it is formatted as a swap partition: | ||
- | |||
- | <code bash> | ||
- | sudo fdisk -l /dev/sda | ||
- | </ | ||
- | |||
- | Returns | ||
- | |||
- | < | ||
- | [..snipped..] | ||
- | /dev/sda5 3842 6595 22121473+ 83 Linux | ||
- | /dev/sda6 6596 6720 1004031 82 Linux swap / Solaris | ||
- | </ | ||
- | |||
- | If it is a swap partition, ready it for use and turn it on. At this point, you might see any errors that prevented its use. | ||
- | |||
- | <code bash> | ||
- | su - | ||
- | mkswap /dev/sda6 | ||
- | swapon /dev/sda6 | ||
- | </ | ||
- | |||
- | You can now check that the partition is being used using the " | ||
- | |||
- | Add an entry to /etc/fstab to have this swap partition loaded at bootup. You can replace the " | ||
- | |||
- | < | ||
- | /dev/sda6 none swap sw 0 0 | ||
- | </ | ||
- | |||
- | If you didn't define a swap partition earlier, then you'd have to create one, or point swap to a regular file (which is a little less efficient, but probably sufficient). | ||
- | |||
- | |||
- | ===== Using a file for swap ===== | ||
- | |||
- | Using a static partition for swap is wasteful - so I tend to configure my systems with LVM, and allocate a swap partition in that. | ||
- | |||
- | If I'm not using LVM then a simple file is sufficient, since a system actually using swap is probably already broken. | ||
- | |||
- | <code bash> | ||
- | su - | ||
- | dd if=/ | ||
- | mkswap -f /swap.file | ||
- | echo "/ | ||
- | swapon -a | ||
- | </ | ||
swap/enabling_swap.1479315115.txt.gz · Last modified: 2020/07/15 09:30 (external edit)