I have a pretty old pc that I havent used in a few years. Currently runs windows xp but Ive been thinking of putting linux on it to squeeze more life out of. it is a Thinkpad TT520 that it has 4gb of ram,
hmm all i know untill now - is to go and create a swap-file:
well - Swap files are a form of virtual memory management and serve as a fallback mechanism. The swap space has significantly slower access times than RAM. Heavy reliance on swap files leads to performance losses.
my problem is - that i went through the whole process _ but believe it or not - after switching off and on again - all is lost!??!
question: why does this happen!?
here is what i have done: The free command with the -h tag shows the total, available, and used swap space in a human-readable format. For example:
The /proc/meminfo file shows the total, free, and used swap space in kilobytes:
cat /proc/meminfo | grep Swap
The /proc/swaps file shows active swap devices:
cat /proc/swaps
The swapon command with the --show tag displays swap information:
swapon --show
How to View a Swap File on Linux
To view the contents of a swap file, use the strings command and save the contents to another file. For example:
sudo strings <swap file path> > <output file path>.txt
How can i create a new Swap File on my Linux notebook?
well i think that creating a swap file on Linux is a pretty simple process.
That said i think i have to do like so: to make a new swap file on a Linux system.
1. i have to create some kind of Storage File
therefore i have to make use the dd tool to create a new storage file. For example:
like so:
sudo dd if=/dev/zero of=/swapfile bs=2MB count=1024
The command contains the following parameters:
if=/dev/zero is the input file.
The /dev/zero file is a kind of a very special file that returns as many (awful many) null characters as a read operation requests.
of=/swapfile
is the output swap storage file. The common practice is to place the file in the root directory.
The bs parameter is the block size.: it is damned important
The count parameter determines how many blocks to copy. I often use this command.
The total data size is bs*count, which in this case is 2GB.
and now its pretty important to set the Swap Permissions; but how!?
can i set the swap file permissions for the swap file to the user root read and write.
well can i do make use the following command:
sudo chmod 600 /swapfile
The command shows - afaik no output. Check the permissions with the following:
ls / | grep swapfile
swap file permissions
how to do this!? well how to changing the permissions to root helps avoid accidental overwriting.
- Set Up Swap Area
The swap file requires formatting the reserved file size into a swap area. Use the mkswap command to format the swap file:
sudo mkswap /swapfile
The command formats the swap file into a swap space and outputs the size, label, and UUID.
4. Enable Swap
To enable the swap area for use, run the following command:
sudo swapon /swapfile
Verify the swap is active with the following command:
swapon --show
well - my big big problem is - that this is not pesisten - if i switch off the notebook and on again
all is lost - the swap file is not active any more
Question; why is this so!? this behaviour is crazy
btw: can anybody tell me the difference between the swap-concepts - the swapfile and the ZRAM as SWAP-Device - i never have used it