Skip to main content

Partitioning Disks for Linux: A Comprehensive Guide

Partitioning Disks for Linux: A Comprehensive Guide Partitioning Disks for Linux: A Comprehensive Guide

Partitioning Disks for Linux: A Comprehensive Guide

Understanding Disk Partitioning

Disk partitioning is the process of dividing a hard disk into multiple logical sections, called partitions. Each partition functions as a separate disk, allowing you to organize data, manage resources, and install multiple operating systems on a single physical disk.

Types of Partitions

  • Primary Partitions: You can create up to four primary partitions on a single disk. Each primary partition can host a file system or an operating system.
  • Extended Partitions: An extended partition acts as a container for logical partitions. You can create one extended partition per disk, and within it, multiple logical partitions.
  • Logical Partitions: These reside within an extended partition and allow for more flexible disk organization. They function similarly to primary partitions but do not have the same limitations.

Common File Systems for Linux

  • ext4: The most widely used file system for Linux, known for its stability, performance, and support for large files.
  • XFS: A high-performance file system suitable for large volumes and parallel I/O operations.
  • Btrfs: Offers advanced features like snapshots, subvolumes, and RAID support, making it ideal for complex storage setups.

Tools for Disk Partitioning

  • GParted: A graphical partition editor that allows you to create, resize, and manage partitions using a user-friendly interface.
  • fdisk: A command-line utility for creating and managing disk partitions. It is suitable for MBR (Master Boot Record) disks.
  • parted: A versatile command-line tool that supports both MBR and GPT (GUID Partition Table) disks.

Steps for Partitioning Disks

Using GParted

  1. Install GParted: sudo apt-get install gparted
  2. Launch GParted: sudo gparted
  3. Select the Target Disk: Choose the disk you want to partition from the drop-down menu.
  4. Create a New Partition Table: Go to Device > Create Partition Table and select the partition table type (MBR or GPT).
  5. Create Partitions: Right-click on the unallocated space and select New. Configure the partition size, file system, and label. Repeat this step for additional partitions.
  6. Apply Changes: Click the green checkmark to apply the changes.

Using fdisk

  1. Launch fdisk: sudo fdisk /dev/sdX (Replace /dev/sdX with the target disk, e.g., /dev/sda).
  2. Create a New Partition:
    • Type n and press Enter.
    • Select the partition type (primary or extended).
    • Specify the partition number, starting sector, and size.
  3. Write Changes: Type w and press Enter to write the changes to the disk.

Using parted

  1. Launch parted: sudo parted /dev/sdX (Replace /dev/sdX with the target disk, e.g., /dev/sda).
  2. Create a New Partition Table: mklabel gpt
  3. Create Partitions:
    • mkpart primary ext4 1MiB 20GiB
    • mkpart primary linux-swap 20GiB 22GiB
    • mkpart primary ext4 22GiB 100%
  4. Quit parted: quit

Post-Partitioning Steps

  1. Format the Partitions:
    • sudo mkfs.ext4 /dev/sdX1
    • sudo mkfs.ext4 /dev/sdX3
    • sudo mkswap /dev/sdX2
  2. Mount the Partitions:
    • sudo mount /dev/sdX1 /mnt
    • sudo mkdir /mnt/home
    • sudo mount /dev/sdX3 /mnt/home
    • sudo swapon /dev/sdX2

© 2025 Linux Playground. All rights reserved.

Comments

Popular posts from this blog

Configuring Network Interfaces

Configuring Network Interfaces Configuring Network Interfaces Configuring network interfaces is a critical task for both system administrators and enthusiasts looking to optimize the performance and security of their networked devices. Network interfaces are the gateways that connect a device to a network, whether it's a local area network (LAN), wide area network (WAN), or the internet. This article will delve into the essential steps and considerations for configuring network interfaces across various operating systems and environments. Understanding Network Interfaces A network interface can be either physical, like an Ethernet port, or virtual, like those used in virtual machines or containers. Each network interface has a unique Media Access Control (MAC) address and can be assigned an IP address. Proper configuration ensures efficient data transmission, network security, and optimal performance. Steps to Config...

ACLs: Access Control Lists

ACLs: Access Control Lists ACLs: Access Control Lists Introduction Access Control Lists (ACLs) are a fundamental aspect of network security and management, crucial for ensuring that only authorized users have access to specific resources within a network. As networks become more complex, ACLs serve as a vital tool for administrators to control the flow of traffic and enforce security policies. What Are ACLs? An Access Control List is a set of rules that dictate what kind of traffic is allowed to enter or exit a network. These rules are applied to network devices such as routers and switches to control the movement of data packets. Each rule within an ACL specifies whether to permit or deny traffic based on criteria such as source and destination IP addresses, protocol types, and port numbers. Types of ACLs Standard ACLs These ACLs filter traffic based only on the source IP address. They are simpler bu...

Understanding sudo and su: A Comprehensive Guide

Understanding sudo and su: A Comprehensive Guide Understanding sudo and su : A Comprehensive Guide What is sudo ? The sudo (superuser do) command allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. Essentially, sudo grants temporary administrative privileges to perform a specific task. Key Features of sudo : Granular Control: sudo allows system administrators to delegate limited root access to users, specifying exactly which commands they are permitted to run. Auditability: Every use of sudo is logged, providing a clear trail of who used sudo , what commands were executed, and when. Temporary Elevation: sudo grants elevated privileges for the duration of a single command, reducing the risk of accidental system-wide changes. Sec...