In this tutorial,we’ll discuss the virtual memory and swap space concept in the operating system.We’ll also present the core differences between them.
2. Fundamentals of Virtual Memory
Modern operating systems are designed to execute multiple programs simultaneously and provide efficient and fast processing. Although, issues like lack of memory space,memory fragmentationcan degrade the efficiency of an OS. Usingvirtual memory, we can solve the issues that cause the processing of the OS to be slow in terms of time and consumed memory.
It’s a memory management concept that creates the illusion that the computer has a huge amount of memory.Moreover, virtual memory allows the OS to extend its existing physical memory. It can be located on a hard disk.
In virtual memory, we map the program addresses into the main memory addresses.In some cases, if we don’t have enough main memory available, we map them into the disk memory addresses:
In addition to increasing the performance of the OS,virtual memory providesmemory protectionfor the addresses that are translated to a physical address.
Any program that wants access to a certain area of memory executes a load function to specify a virtual address. Therefore, the computer will then translate this virtual address, transforming it into a physical address.
As soon as the physical address is available, the computer will look it up in the RAM. If the computer can’t find the physical address in RAM, it’ll search for it on the disk. Furthermore, the OS will also update the translation map. Finally, the computer reads the required case of memory and returns the data to the program.
Like virtual memory,swap spaceis a secondary memory. It’s used by the OS when there is no physical memory available for further execution of the processes.
If the OS faces a situation when it needs memory, but the RAM is full, it moves the inactive pages from RAM to swap memory.If these pages are needed in the future, the OS can move them again from swap space to RAM.
It offers a slower access time compared to RAM and located in the disk memory. Swap space is actually a part of the virtual memory.
There are several applications of swap space. It stores the applications which the OS doesn’t use frequently. Hence, if the OS has sufficient swap space, it always keeps the RAM free. Moreover, it helps in increasing the performance.
Another crucial use of swap space is that it can be used as a singlecontiguous memoryby the OS. Hence, it also reduces I/O operations to read or write a file.
Swap space is available in Windows and Linux-based operating systems by default. The amount of swap space generally equals twice the RAM of the system. Moreover, the user has the option to increase or decrease it based on the requirements.
4. Difference Between Virtual Memory and Swap Space
In this section, let’s discuss the core difference between virtual memory and swap space in OS:
In this tutorial, we discussed the fundamentals of virtual memory and swap space in the OS. We also highlighted the core differences between them.
This article may have been automatically translated. If you have any feedback regarding its quality, please let us know using the form at the bottom of this page.
In this article, I make clear how the various terms used in Ubuntu Linux for its structure can be described logically. Even though these terms can overlap and sometimes mean two different things simultaneously. This article is not meant to make you an expert in Linux. Only to clarify some terms and definitions. It helps you better understand, install, and use this operating system.
I recommend using the Clean Install or Dual Boot Install methods. They are largely automated and do not require this amount of knowledge to complete successfully or to use.
If your computer did not ship with Ubuntu, then the Dell support for your computer may include reverting it to the Windows Operating system (OS). This information is provided for your knowledge but is used at your discretion.
Linux users state that a filesystem is a programmatic scheme that is used to organize and find files on a partition. While the file system references all the files on your computer.
What this means is that the Filesystem is the structure that is used to see, find and use your files using Ubuntu. However, the File System is both all the separate files in that structure and those files format.
Note: Be that Ext2, Ext3, NTFS, or some other format.
Legacy File System that was universally adopted. Came in 12 FAT12, 16 FAT16, and 32 FAT32.
New Tech File System - replaced FAT on Windows computers. It is still required to read Windows partitions.
Second Extended filesystem - used by many Linux distributions' (distros).
Third Extended filesystem - default choice for Ubuntu distros. Journaling added.
Fourth Extended filesystem - used by many Linux distros. Extends storage limits.
Journaled File System - introduced by IBM, it is still supported but it is being replaced by Ext4.
64-bit option that is mostly supported now as an option in Red Hat.
This was a file format that was in use across several distros but is largely replaced by Ext3 now.
There are several types of files in Ubuntu Linux:
They contain data, for example, text files, executable files or programs, input in or output out from a program and such.
Are files/folders that are lists of other files.
This is the mechanism that is used for input and output. Most special files are in /dev.
→ Such as mounted Volume and partition in /dev
This is a system to make a file or directory visible in several parts of the computer's file tree.
This is a special file type, and it is similar to TCP/IP sockets in windows. It provides inter-process networking that the file system's access control protects.
These act more or less like sockets and are a way for processes to communicate with each other, without using network socket protocols. → We call it special pipe line.
For Ubuntu Linux, your / Partition must be a primary partition. While every other partition - Be it Primary or Logical, mounts to that partition. Each partition has a file format that you set and a purpose within the OS. The directories and files are searchable and used within this structure. This is explained in more detail below.
The First thing is to discard everything that you already know about windows partitions. Trying to match the two only confuses you. You are better to take them as two separate processes.
Windows Partition Description
Windows partitions come in two types: Primary and Logical. On older SATA IDE Hard Drives, you are limited to either four Primary partitions or a combination of some Primary and Logical partitions. Each receives a Drive letter, but you are only able to install the OS on a Primary partition.
Note: There are further things that can be done with windows partitions. Such as spanning or mounting and there are new types of Hard Drives that use larger sectors. Such as a GUID or GPT table rather than an MBR table to give larger Hard Drive sizes. However, they are not the subject of this article.
→ Windows also possible GUID or GPT table
Ubuntu Linux Partition Description
Ubuntu Linux partitions also come in Primary and Logical. You are limited to either four primary partitions or a combination of Primary and Logical partitions. However, that is where the similarities stop.
Your first partition is always your install partition on a primary partition. This partition can be called the root of the partition, or it is shown as a /. You make several partitions, depending on how you want to use and configure your Ubuntu install. Root is the most important one. While you can create these partitions and give them a size, a file format, and a purpose. They need to be mounted to the / of this partition to function.
Ubuntu Linux Partition Categories
Ubuntu Linux further separates these partitions into two categories:
These are partitions like the boot partition in that they hold directories and files or normal Linux system data. These are the files which start and run the computer.
These are partitions that expand the computer's physical memory by using the partition as a cache.
Partition types that are used in Ubuntu Linux Installs
There are several common partitions that are used for Ubuntu, I have listed them and some info for each below. Experienced Linux users use a combination of some of these partitions as a scheme. This is when they know they are using the custom Ubuntu install for a specific set of uses. These particular partitions make it easier and more efficient. I list what combination of partitions are required for the most common generic install. However, if you are going to use this scheme you would be better to use the auto-install guides above.
Note: Originally having different partitions was to achieve higher data security if there is a disaster. If an accident occurred, it would only affect the data in the partition that got affected. While the data on the other partitions would most likely survive. This still holds true to some extent after journaled file systems for power failure or sudden loss of storage. You can still get bad blocks and logical errors. The only way past this is a RAID solution, which is not something we are going into here.
The slash / alone stands for the root of the filesystem tree.
This stands for binaries and contains the fundamental utilities that all users need.
This contains all the files that are needed for the booting process.
This stands for devices, which contain files for peripheral devices and pseudo devices.
This contains configuration files for the computer and computer databases.
This holds all the home directories for the users.
This is the system libraries and has files like the kernel modules and device drivers.
This is the system libraries and has files like the kernel modules and device drivers for 64-bit computers.
This is the default mount point for removable devices like USB drives and media players.
This stands for a mount and contains filesystem mount points. Used for multiple hard drives, multiple partitions, network filesystems, and CD ROMs and such.
Contains add-on software. Larger programs may install here rather than in /usr.
This contains virtual filesystems describing the processes information as files.
This stands for System Binaries and contains the fundamental utilities that are needed to start, maintain, and recover the computer.
This is the home location for the computer's administrator root. This accounts home directory is usually the root of the first partition.
This is server data, which is data for services that are provided by the computer.
This contains a sysfs virtual filesystem which holds information that is related to the hardware operating system.
This is a place for temporary files. tmpfs that is mounted on it or scripts on startup usually clear this at boot.
This holds the executables and shared resources that are not system critical.
This stands for variable and is a place for files that are in a changeable state. Such as size going up and down.
The swap partition is where you extend the system memory by dedicating part of the hard drive to it.
Most Common Partition Scheme
Recommended Partition Space
Remaining Free Space after other partitions created or second drive.
20 GB at least
500 MB to 5 GB
Match this to the size of the Swap partition.
8 KB This is an empty partition that is used as a mount point for temporary files.
8 KB This contains subdirectories for mount points of removable media, such as CDs and USB flash drives.
Twice as large as the amount of RAM in the personal computer.
There are many other schemes and many reasons for not splitting off a directory as a partition. As there are many reasons for creating a specific partition to streamline a particular process. If you want to proceed with a custom install, then how you achieve this is going to be up to you. It all depends on the use that you plan to put the computer.
Note: Once the partitions are made, you should only add more. Changing the sizes or properties of existing partitions is possible but not recommended. The current default filesystem for these partitions is Ext4.
If you need aid from Dell Technical Support in setting these up, then I would have to advise contacting the Operating Systems manufacturer instead. This type of help is not going to be covered under our existing warranties. Only the operating systems (OS) developer can answer your questions on this subject. They are the acknowledged experts on their OS.
In simple terms, Directories in Ubuntu Linux are folders that contain files. There is a certain amount of overlap with the terms that are used for the partitions in the section above. The reason for this is that Linux split up the directories onto separate partitions. So that they could dedicate space to each of them and mostly to protect against data loss. This is so that if one partition was unresponsive or if it was lost it would not affect all the others. This is mostly a thing of the past thanks to Journaled file systems such as Ext3 and Ext4. Once the separate partition is mounted to /, it then shows as a directory thereof.
→ Journaled file systems such as Ext3 and Ext4 present.
The easiest way to think of the directories on an Ubuntu Linux computer is to think of them as branches on a tree. Where the Trunk of the tree is the root directory on your first partition. All the other directories mount to this Trunk as branches. Each branch has its purpose but may interact with others through the Trunk and have subdirectories branch off from those main branches.
Note: While this is not entirely accurate for Ubuntu. It works until you have a better understanding of the format and can determine for yourself when exceptions crop up.
Directory Name Content
Contains the common programs, which are shared by the computer, the system administrator, and the users.
This has the startup files and the kernel, vmlinuz. In some recent distributions, it also has grub data. GRUB is the Grand Unified Boot Loader.
Contains references to all the CPU peripheral hardware. They are represented as files with special properties.
This has the most important system configuration files; this directory is similar to the control panel in Windows.
This is the home directory for the common users.
This contains information for booting in some distributions. Do Not Remove.
This holds the library files; it includes files for all kinds of programs that the user needs.
Every partition has a lost + found in its upper directory. Files that were saved during failures reside here.
For miscellaneous uses.
The standard mount point for external files systems, such as media players, digital cameras, and CD ROMs.
The standard mount point for entire remote file systems.
Typically this has third-party software and any extra files required.
This is a virtual files system containing information about system resources. You can get more information about the meaning of the files in proc by entering the command man proc in a terminal window. The file proc.txt discusses the virtual file system in detail.
This is the system administrator user's home directory. Remember that there is a difference between / the root directory and /root the home directory of the root user.
This contains programs for use by the system administrator.
This is a temporary space for use by the computer. It is regularly wiped, so remember not to keep anything you want to retain here.
This has programs, libraries, and documentation for all the user-related programs.
This is the storage for all the variable files and the temporary files that the users create. Things like the log files, the mail queue, the print spooler area, space for the Internet cache. To keep an image of a CD/DVD before burning it.
You can find a guide on using these directories after you have finished the install on the link below.
Disk partitioning or disk slicing is the creation of one or more regions on secondary storage, so that each region can be managed separately. These regions are called partitions. It is typically the first step of preparing a newly installed disk, before any file system is created. The disk stores the information about the partitions' locations and sizes in an area known as the partition table that the operating system reads before any other part of the disk. Each partition then appears to the operating system as a distinct "logical" disk that uses part of the actual disk. System administrators use a program called a partition editor to create, resize, delete, and manipulate the partitions.
Partitioning allows the use of different filesystems to be installed for different kinds of files. Separating user data from system data can prevent the system partition from becoming full and rendering the system unusable. Partitioning can also make backing up easier. A disadvantage is that it can be difficult to properly size partitions, resulting in having one partition with too much free space and another nearly totally allocated.
allows the use of different file systems to be installed for different kinds of files.
Separating user data from system data can prevent the system partition from becoming full and rendering the system unusable.
can also make backing up easier.
it can be difficult to properly size partitions, resulting in having one partition with too much free space and another nearly totally allocated.
(Free Disk space or totally allocated → non effective)
IBM in its 1983 release of PC DOS version 2.0 was an early if not first use of the term partition to describe dividing a block storage device such as an HDD into physical segments. The term's usage is now ubiquitous. Other terms used in the art have included logical disk, minidisk, portions, pseudo-disk, section, slice and virtual drive.
IBM 1983 release of PC DOS version 2.0 was an early, to describe (Not First)
One of the earliest such segmentation of a disk drive was IBM's 1966 usage in its CP-67 operating system of minidisk as a separate segment of a hard disk drive.
DOS, Windows, and OS/2
With DOS, Microsoft Windows, and OS/2, a common practice is to use one primary partition for the active file system that will contain the operating system, the page/swap file, all utilities, applications, and user data. On most Windows consumer computers, the drive letter C: is routinely assigned to this primary partition. Other partitions may exist on the HDD that may or may not be visible as drives, such as recovery partitions or partitions with diagnostic tools or data. (Windows drive letters do not correspond to partitions in a one-to-one fashion, so there may be more or fewer drive letters than partitions.)
Common practice → One primary partition and Other partitions (recovery or diagnostic tools or data)
A runaway program that uses up all available space on a non-system filesystem does not fill up critical filesystems. (Preventing file system critical issue)
Keeping user data such as documents separate from system files allows the system to be updated with lessened risk of disturbing the data. (Data integrity)
A common minimal configuration for Linux systems is to use three partitions: one holding the system files mounted on "/" (the root directory), one holding user configuration files and data mounted on /home (home directory), and a swap partition.
By default, macOS systems also use a single partition for the entire filesystem and use a swap file inside the file system (like Windows) rather than a swap partition.
In Solaris, partitions are sometimes known as slices. This is a conceptual reference to the slicing of a cake into several pieces.
A GRUB startup menu showing Ubuntu Linux (with three different boot modes) and Windows Vista options
Multi-boot systems are computers where the user can boot into more than one distinct operating system (OS) stored in separate storage devices or in separate partitions of the same storage device. In such systems a menu at startup gives a choice of which OS to boot/start (and only one OS at a time is loaded).
This is distinct from virtual operating systems, in which one operating system is run as a self-contained virtual "program" within another already-running operating system. (An example is a Windows OS "virtual machine" running from within a Linux OS.)
Multi-boot systems recognize computers from each other operating systems.
Virtual Operating System recognize a self-contained virtual “program”
When a partition is deleted, its entry is removed from a table and the data is no longer accessible. The data remains on the disk until it is overwritten. Specialized recovery utilities may be able to locate lost file systems and recreate a partition table which includes entries for these recovered file systems. Some disk utilities may overwrite a number of beginning sectors of a partition they delete. For example, if Windows Disk Management (Windows 2000/XP, etc.) is used to delete a partition, it will overwrite the first sector (relative sector 0) of the partition before removing it. It still may be possible to restore a FAT or NTFS partition if a backup boot sector is available.
The data will be overwritten by time.
Overwritten First Sector | Data |
HDDs can be compressed to create additional space. In DOS and early Microsoft Windows, programs such as Stacker (DR-DOS except 6.0), SuperStor (DR DOS 6.0), DoubleSpace (MS-DOS 6.0–6.2), or DriveSpace (MS-DOS 6.22, Windows 9x) were used. This compression was done by creating a very large file on the partition, then storing the disk's data in this file. At startup, device drivers opened this file and assigned it a separate letter. Frequently, to avoid confusion, the original partition and the compressed drive had their letters swapped, so that the compressed disk is C:, and the uncompressed area (often containing system files) is given a higher name. → In early, Compressed disk give another higher name separated disk.
Versions of Windows using the NT kernel, including the most recent version, Windows 10, contain intrinsic disk compression capability. The use of separate disk compression utilities has declined sharply.
A partition table is a table maintained on a disk by the operating system that outlines and describes the partitions on that disk. The terms partition table and partition map are similar terms and can be used interchangeably. The term is most commonly associated with the MBR partition table of a Master Boot Record (MBR) in PCs, but it may be used generically to refer to other formats that divide a disk drive into partitions, such as: GUID Partition Table (GPT), Apple partition map (APM), or BSD disklabel.
The total data storage space of a PC HDD on which MBR partitioning is implemented can contain at most four primary partitions, or alternatively three primary partitions and an extended partition. The Partition Table, located in the master boot record, contains 16-byte entries, each of which describes a partition.
In MBR, Partition Table → contains 16 byte entries → each of which describes a partition.
The partition type is identified by a 1-byte code found in its partition table entry. Some of these codes (such as 0x05 and 0x0F) may be used to indicate the presence of an extended partition. Most are used by an operating system's bootloader (that examines partition tables) to decide if a partition contains a file system that can be mounted / accessed for reading or writing data.
1 byte code → an operating system’s bootloader to decide
A primary partition contains one file system. In DOS and all early versions of Microsoft Windows systems, Microsoft required what it called the system partition to be the first partition. All Windows operating systems from Windows 95 onwards can be located on (almost) any partition, but the boot files (io.sys, bootmgr, ntldr, etc.) must reside on a primary partition. However, other factors, such as a PC's BIOS (see Boot sequence on standard PC) may also impose specific requirements as to which partition must contain the primary OS.
DOS and all early version microsoft systems System partition → Only possible to be first partition
from Windoews 95 onwards don’t care where is located (almost), but Boot files → must reside a primary partition
The partition type code for a primary partition can either correspond to a file system contained within (e.g., 0x07 means either an NTFS or an OS/2 HPFS file system) or indicate that the partition has a special use (e.g., code 0x82 usually indicates a Linux swap partition). The FAT16 and FAT32 file systems have made use of a number of partition type codes due to the limits of various DOS and Windows OS versions. Though a Linux operating system may recognize a number of different file systems (ext4, ext3, ext2, ReiserFS, etc.), they have all consistently used the same partition type code: 0x83 (Linux native file system).
An HDD may contain only one extended partition, but that extended partition can be subdivided into multiple logical partitions. DOS/Windows systems may then assign a unique drive letter to each logical partition. GUID partition table (GPT) only has the primary partition, doesn't have the extended partition and the logical partition.
DOS/Windows → assign a unique drive letter
GPT only possible Primary partition → No! extended or logical partition
BIOS boot partition (BIOS BP) is a share of the storage device used to keep software that boots the operating system, a bootloader. It may be an operating system kernel image or bootloader or a completely separate piece of software.
When we power on, BIOS performs a Power-On Self-Test (POST) for all of the different hardware components in the system to make sure everything is working properly.
Also it checks for whether the computer is being started from an off position (cold boot) or from a restart (warm boot) is stored at this location.
Retrieves information from CMOS (Complementary Metal-Oxide Semiconductor), a battery operated memory chip on the motherboard that stores time, date, and critical system information.
Once BIOS sees everything is fine, it will begin searching for an operating system Boot Sector on a valid master boot sector on all available drives like hard disks, CD-ROM drive etc.
Once BIOS finds a valid MBR, it will give the instructions to boot and executes the first 512-byte boot sector that is the first sector (“Sector 0″) of a partitioned data storage device such as hard disk or CD-ROM etc. BIOS find a valid MBR → boot and executes MBR
2.MBR(Master Boot Record)
Normally we use multi-level boot loader. Here MBR means I am referencing to DOS MBR.
Afer BIOS executes a valid DOS MBR, the DOS MBR will search for a valid primary partition marked as bootable on the hard disk. MBR → valid primary partition (Bootable)
If MBR finds a valid bootable primary partition then it executes the first 512-bytes of that partition which is second level MBR. MBR → valid bootable primary partition → execute first 512 bytes (Boot Loader)
In linux we have two types of the above mentioned second level MBR known as LILO and GRUB
3.LILO or GRUB
LILO - LInux LOader
LILO is a linux boot loader which is too big to fit into single sector of 512-bytes.
so it is divided into two parts an installer and a runtime module.
The installer module places the runtime module on MBR. The runtime module has the info about all operating systems installed. (installer module → runtime module → MBR)
When the runtime module is executed, it selects the operating system to load and transfers the control to kernel. (runtime module → select operating system to load → transfer control → kernel)
LILO does not understand file systems and boot images to be loaded and treats them as raw disk offsets
GRUB - GRand Unified Bootloader
GRUB MBR consists of 446 bytes of primary boot loader code and 64 bytes of the partition table.
GRUB locates all the operating systems installed and gives a GUI to select the operating system need to be loaded.
Once user selects the operating system, GRUB will pass control to the kernel of that operating system.see below what is the difference between LILO and GRUB
Select operating system → grub will pass control → the kernel that operating system
Once GRUB or LILO transfers the control to Kernel, the Kernels does the following tasks
initializes devices and loads initrd module
mounts root file system
The kernel, once it is loaded, finds init in sbin(/sbin/init) and executes it.
Hence the first process which is started in linux is init process.
This init process reads /etc/inittab file and sets the path, starts swapping, checks the file systems, and so on.
it runs all the boot scripts(/etc/rc.d/*, /etc/rc.boot/*)
starts the system on specified run-level in the file /etc/inittab
There are 7 run levels in which the linux OS runs and different run levels serves for different purpose. The descriptions are given below.
0 – halt
1 – Single user mode
2 – Multi-user, without NFS (The same as 3, if you don’t have networking)
3 – Full multi-user mode
4 – unused
5 – X11
6 – Reboot
We can set in which run-level we want to run our operating system by defining it on /etc/inittab file.