1. Partitions in Linux
A partition is a segment of a storage device that has been logically separated from the rest of the device. All the partitions can be managed as if they are separate storage devices.
Types of Partitions
There are three different types of partitions in Linux:
- **Primary**: Holds the operating system files. Only four primary partitions can be created.
- **Extended**: A special type of partition in which more than the four primary partitions can be created.
- **Logical**: Subdivisions of an extended partition.
Examples
A standard partition scheme for a home Linux install is as follows:
- A 12-20 GB partition for the OS, mounted as `/` (called "root").
- A smaller partition used to augment your RAM, referred to as swap.
- A larger partition for personal use, mounted as `/home`.
2. Fdisk Utility
Fdisk stands for "fixed disk or format disk and is a command-line based disk manipulation utility for Linux/Unix systems⁶. With the help of fdisk, you can view, create, resize, delete, change, copy, and move partitions on a hard drive⁶.
Utility Options
Here are some frequently used fdisk options:
- `-l` or `--list`: List all partitions on the specified device.
- `-n` or `--new`: Create a new partition.
- `-d` or `--delete`: Delete an existing partition.
- `-p` or `--print`: Print detailed information about a partition.
- `-t` or `--type`: Change the partition type.
3. Mounting in Linux
Mounting is the act of associating a storage device to a particular location in the directory tree. For example, when the system boots, a particular storage device (commonly called the root partition) is associated with the root of the directory tree, i.e., that storage device is mounted on `/` (the root directory).
Details and Examples
The standard mount command syntax is: `mount -t [type] [device] [dir]. The command instructs the kernel to attach the file system found on `[device]` at the `[dir]` directory. The `-t [type]` option is optional, and it describes the file system type (EXT3, EXT4, BTRFS, XFS, HPFS, VFAT, etc.)
For example, to mount the `/dev/sdb1` file system to the `/mnt/media` directory you would use: `sudo mount /dev/sdb1 /mnt/media`
I hope this blog post helps you understand Linux partitions, the fdisk utility, and mounting in Linux.