From 146653128dc18bda772e649f5546f76d858548cf Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Sat, 30 Jul 2022 14:00:04 +0100 Subject: [PATCH] Last Sync: 2022-07-30 14:00:04 --- Operating_Systems/Basic_Model.md | 2 +- Operating_Systems/Disks/Filesystems.md | 2 ++ Operating_Systems/Disks/Swap_space.md | 34 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Operating_Systems/Disks/Swap_space.md diff --git a/Operating_Systems/Basic_Model.md b/Operating_Systems/Basic_Model.md index 985ecc5..9d3b760 100644 --- a/Operating_Systems/Basic_Model.md +++ b/Operating_Systems/Basic_Model.md @@ -4,7 +4,7 @@ tags: - Linux --- -# Basic model of a (*nix) operating system +# Basic model of a *nix operating system We can abstract the Linux OS into three operational levels or tiers, from the bottom up: diff --git a/Operating_Systems/Disks/Filesystems.md b/Operating_Systems/Disks/Filesystems.md index 3245d50..8ea5d86 100644 --- a/Operating_Systems/Disks/Filesystems.md +++ b/Operating_Systems/Disks/Filesystems.md @@ -51,3 +51,5 @@ touch test.txt Our `sda1` partition is now mounted at `mountpoint`. We can go ahead and create files. If we now look within the graphical file manager when we click on the `sda1` volume, we will see the new file we have created in `mountpoint`. ![](/img/mount-directory.png) + +## `fstab` diff --git a/Operating_Systems/Disks/Swap_space.md b/Operating_Systems/Disks/Swap_space.md new file mode 100644 index 0000000..84eec8e --- /dev/null +++ b/Operating_Systems/Disks/Swap_space.md @@ -0,0 +1,34 @@ +--- +tags: + - Linux + - Operating_Systems + - disks + - devices + - disk-partions +--- + +# Swap space + +A swap partition is a partition on a disk that is not intended to be used as a filesystem. Instead, it is a part of the disk that is used to augment the main memory. + +If you run out of memory and have set up a swap partition, the OS will be able to move pieces of memory to and from disk storage. This is called _swapping_ because pieces of idle programs are swapped to the disk in exchange for active pieces residing on the disk. + +## View current swap usage +If you have a swap space established, the command `free` will show current usage: + +```bash +free + total used free shared buff/cache available +Mem: 16099420 3031572 10157652 1153144 2910196 11605820 +Swap: 3145724 0 3145724 +``` + +## Create a swap partition +To use an existing disk partition as a swap you can run the command `mkswap [device]` and then `swapon [device]` to register the space with the [kernel](/Operating_Systems/The_Kernel.md). + +### Add to `fstab` +You will want the swap to be activated every time the OS boots so add the following line to the [fstab](/Operating_Systems/Disks/Filesystems.md#fstab), where `/sda3` is used as the example partition: + +```bash +/dev/sda3e none swap sw 0 0 +``` \ No newline at end of file