Udgivet den

Swap area in OpenSUSE

First create an 1Gigabyte file.

opensuse:~# dd if=/dev/zero of=/swap   bs=1024 count=1000000
1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB) copied, 28.7256 s, 35.6 MB/s

DD command to create the 1G file basically writing “0” into the file swap_1 in the “/” file system.

Create SWAP area

opensuse:~ # mkswap /swap
Setting up swapspace version 1, size = 999996 KiB
no label, UUID=4aada58e-d6f7-4053-adf1-8d4c79122d36

That sets up the file as a swap area.

Now, we’ll simply enable the swapfile, so that the system can start paging physical memory pages onto it.

opensuse:~ # swapon /swap

The system should now have an additional 1Gigabyte of swap area. Check it.

opensuse:~ # free -tom
total       used       free     shared    buffers     cached
Mem:           998        973         24          0         20        795
Swap:         1716          0       1716
Total:        2714        973       1741

We now have 1.7Gigabytes of swap area.

To confirm the swap areas we have

opensuse:~ # swapon -s
Filename                                Type            Size    Used    Priority
/dev/mapper/system-swap                 partition       757752  0       -1
/swap                                      file            999992  0       -2

To make it permanent, we need to add an entry to the /etc/fstab file.:

/swap       swap                 swap       defaults              0 0

Where /swap is our new swap file and it instructs the system to mount it at system startup as a swap area.