1
0
mirror of https://github.com/mbirth/wiki.git synced 2024-11-09 13:16:45 +00:00
wiki.mbirth.de/know-how/software/linux/_posts/2009-08-24-swapfile.md

31 lines
932 B
Markdown
Raw Permalink Normal View History

2015-04-13 20:20:11 +01:00
---
created: 2009-08-24 22:13:58 +0200
2022-01-23 17:14:59 +00:00
layout: redirect
layout_old: default
redirect_to: https://blog.mbirth.de/archives/2009/08/24/swapfile-instead-of-partition.html
2015-04-13 20:20:11 +01:00
tags:
2022-01-23 17:14:59 +00:00
- know-how
- software
- linux
title: Swapfile instead of partition
toc: false
updated: 2009-08-24 22:13:58 +0200
2015-04-13 20:20:11 +01:00
---
2022-01-23 17:14:59 +00:00
2015-04-13 20:20:11 +01:00
If you don't want to create a designated swap partition (e.g. if you plan to downsize it later) and don't want to play
around with *GPartEd*, you can create a swap**file** instead.
To create a 512 MiB swapfile, do the following:
dd if=/dev/zero of=/swapfile bs=1024K count=512
mkswap /swapfile
swapon /swapfile
To automatically add the swapfile upon boot, add this line to the `/etc/fstab`:
/swapfile swap swap defaults 0 0
You can later easily change the size of the swapfile by re-creating a smaller or larger one.
2022-01-23 17:14:59 +00:00
You only have to make sure the file is contiguous or `swapon` might give an error.