dd if=/dev/zero of=/var/tmp/.swapfile.bin bs=1MiB count=1024
chmod 600 /var/tmp/.swapfile.bin
mkswap /var/tmp/.swapfile.bin
parted -l
swapon --show
swapon /var/tmp/.swapfile.bin
swapon --show
top -b -n 1 | grep Swap:
(RESULT)
root:~# dd if=/dev/zero of=/var/tmp/.swapfile.bin bs=1MiB count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.907157 s, 1.2 GB/s
root:~# chmod 600 /var/tmp/.swapfile.bin
root:~# mkswap /var/tmp/.swapfile.bin
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=29597c83-46a7-4454-a57d-0da84850a8b3
root:~# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 257MB 256MB primary linux-swap(v1)
2 257MB 68.7GB 68.5GB primary ext4 boot
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 257MB 256MB primary linux-swap(v1)
2 257MB 68.7GB 68.5GB primary ext4
root:~# swapon --show
NAME TYPE SIZE USED PRIO
/dev/sdb1 partition 244M 0B -3
/dev/sda1 partition 244M 0B -2
root:~# swapon /var/tmp/.swapfile.bin
root:~# swapon --show
NAME TYPE SIZE USED PRIO
/dev/sdb1 partition 244M 0B -3
/dev/sda1 partition 244M 0B -2
/var/tmp/.swapfile.bin file 1024M 0B -4
root:~# top -b -n 1 | grep Swap:
MiB Swap: 1512.0 total, 1512.0 free, 0.0 used. 7560.1 avail Mem
root:~#
/var/tmp/.swapfile.bin none swap sw 0 0