Hard Disk Partitioning
What is a disk partition?
A partition is a set of contiguous blocks that are treated as an independent disk. A hard disk can be divided into several partitions, and each partition can act as if it were a separate hard disk. In this article, I will be telling you about how to hard disk partition.
Why do we have multiple partitions?
You encapsulate your data to a specific region of the disk. If the file system is on a separate partition, you will only lose some of your data in the event of a crash.
It increases the expected efficiency of disk space.
You can format partitions to varying block sizes based on your usage. If your data consists of many files of small size (less than 1k) and your partition uses 4k blocks, you are wasting 3k for each file. Typically you will waste, on average, half a block per file, so if you have many files it is very important to match the block size with the average file size.
It prevents data growth. Out of control processes or crazy users can consume so much disk space that there is no longer room for the processes that the operating system is keeping track of. This could turn into a disaster.
By allocating disk space, you guarantee that even if the allocated disk space is exhausted, the jobs there will die without affecting the operating system.
What are the partition types?
A partition is labeled to have a specific file system. Such a file system can be the standard linux ext2 file system or the linux swap space or even foreign file systems like (Microsoft) NTFS or (Sun) UFS. Each volume has a numeric code associated with its type. For example, code 0x83 for ext2 and code 0x82 for linux swap space. /sbin/sfdisk –T to see partition types and corresponding codes
We can run the command.
What are the types of foreign partitions?
Partition type numbers are randomly selected and assigned specifically to the operating system under consideration. So if you are using two operating systems on the same disk, the same code can be used to identify two different disk types. OS/2 and Windows NT’s NTFS mark partitions with 0x07. MS-DOS has assigned different codes for different types of FAT file systems: 0x01, 0x04 and 0x06 are the known ones. DR-DOS used to use the then conflicting 0x81 with Linux/Minix to designate protected FAT partitions, but neither Linux/Minix nor DR-DOS are widely used anymore.
What are primary partitions?
On an Intel-based system, the number of partitions is limited at the outset. The actual partition table is loaded as part of the bootloader partition and there is only room for 4 partition entries. These partitions are called primary partitions.
What is a logical partition?
One of the primary partitions of the disk can be subdivided. These are called logical partitions. This allows us to efficiently exceed the limit of four partitions.
The primary partition that hosts the logical partitions is called an additional partition and has its own file system type (0x05). Unlike primary partitions, logical partitions must be consecutive. Each logical partition contains a pointer to the next logical partition, denoting the conclusion that the number of logical partitions will be unlimited. However, Linux has imposed a certain limit on the number of possible partitions on the disk, which consequently limits the number of logical partitions. This number is 15 partitions for SCSI disks and 63 for IDE disks.
What are swap partitions?
Each process running on your computer uses a number of blocks in RAM. These blocks are called pages. The pages in the memory that will be used by the processor in a very short time are called the working set. Linux tries to predict these accesses to memory (assuming that the most recently used pages will be used again soon) so that these pages are kept in RAM, if possible.
If you have many processes running on your machine, the kernel will free up RAM by writing pages to disk. This is where swap space comes into play. It efficiently increases your available available memory space. However, disk I/O is very slow compared to reading and writing from RAM. Think of it as emergency memory, not additional memory. If you have a memory shortage, which means the kernel is removing pages from a running process for another process, your machine is starting to spill. Some readers may have unintentionally encountered this situation: the disk is running like crazy, but the computer is too slow to be used. Swap space is a must-have, but not a replacement for RAM.
What are Disk Partitioning Requirements?
Which partitions are needed?
Bootloader Drive: If you are going to boot your operating system from the disk you are going to partition, these are the partitions you should have:
- A primary partition
- One or more swap spaces
- Zero or more primary or logical partitions If you’re booting from another disc:
- One or more primary or logical partitions
- Zero or more swap spaces
What is a Bootloader Partition?
Your bootloader partition must be a primary partition, not a logical partition. This allows for disaster recovery, but is not technically necessary. 0x83 must be of “Linux native” file type. If you are using a lilo(B23) prior to version 21–3 (eg, from the 1990s), your bootloader partition should be within the first 1024 cylinders of the disk. (Typically, all the bootloader needs is to contain the kernel image.) If you have multiple bootloader partitions (maybe from other operating systems), keep them all within the first 1024 cylinders (All DOS partitions must be within the first 1024 cylinders). If you are using a modern version of lilo or other tools to load your kernel (for example, a bootloader floppy or an MS-DOS-based LOADLIN.EXE Linux installer), the partition can be anywhere.
What is a Swap Partition?
Unless you can swap files you will need a dedicated swap partition. This partition must be of type 0x82 “Linux swap”. It can be positioned anywhere on the disc.
Any of the primary or logical partitions can be used as swap space. There can be more than one swap space on a disk. A total of 8 (within the drivers) are allowed.
Logical Partitions
A single primary partition must be used to contain logical partitions (additional partition). The additional partition can be anywhere on the disk. Logical partitions must be consecutive, but do not need to fill the additional partition.
Source:
- http://www.belgeler.org/sag/sag_disks-partiton.html
- http://www.koraykey.com/?p=2246
- https://linuxbasvurukilavuzu.files.wordpress.com/2012/03/partition-howto-linux-disk-bc3b6lc3bcmleme.pdf
- http://ciscotr.wdfiles.com/local–files/can-simidi/sabir_diskler.pdf
- https://mediatrend.mediamarkt.com.tr/amp/bilgisayarda-disk-bolumleme-nedir-nasil-calisir/