Skip to main content

Understanding Linux Partitions, Fdisk, and Mounting

 

 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.

Popular posts from this blog

Cockpit vs. Webmin: A Detailed Comparison for Linux Administration

  Introduction In the realm of Linux system administration, having efficient tools for managing and monitoring servers is crucial. Two popular tools that system administrators often use are  Cockpit  and  Webmin . Both of these tools provide a graphical interface accessible via a web browser, simplifying the management of Linux systems. This blog post will explore what Cockpit and Webmin are, their purposes, a comparison table, and additional information to help you choose the right tool for your needs. What is Cockpit? Overview Cockpit is a web-based graphical interface for managing Linux systems. It is designed to be easy to use, enabling both experienced and novice administrators to manage their systems effectively. Cockpit integrates seamlessly with the system’s existing infrastructure, providing real-time monitoring and management capabilities. Purpose Cockpit is primarily used for: Monitoring system performance and resource usage Managing system services Handli...

How to Set Up Custom Screen Resolution on Fedora 38 Permanently

  If you are using Fedora 38 as your operating system, you may have encountered some issues with the screen resolution. The default resolution may not be suitable for your monitor or your preferences, and you may want to change it to a higher or lower value. However, changing the resolution from the Settings menu may not work properly, or it may not persist after a reboot. In this blog post, I will show you how to set up a custom screen resolution on Fedora 38 permanently using some simple commands and configuration files. The first step is to disable the Wayland display server, which is the default display server for Fedora 38. Wayland is a modern and secure display server, but it may not support some custom resolutions or drivers. To disable Wayland, you need to edit the /etc/gdm/custom.conf file as root. You can use any text editor of your choice, such as nano, vim, or gedit. To open the file with nano, for example, you can type the following command in the terminal: sudo nano ...

Understanding Linux Log Files

  Introduction In Linux, log files are critical for system administrators to monitor, troubleshoot, and optimize the system. These log files record various events, messages, and errors generated by the operating system, applications, and services. This blog post will delve into the different types of log files in Linux, categorizing them and explaining their purposes with examples and commands to view them. Categories of Log Files Log files in Linux can be categorized into the following types: System Logs Application Logs Service Logs Security Logs Boot Logs Kernel Logs User Logs Let’s break down each category and provide examples and commands to view these log files. 1. System Logs System logs contain messages about the system’s hardware, kernel, and various system processes. Log File Description Command to View /var/log/syslog Contains system-wide messages and information. cat /var/log/syslog /var/log/messages General system activity logs. cat /var/log/messages Example: cat /var/...