SOHAIL
ASGHER
Linux Disk Management
This session provides an in-depth overview of Linux disk
management.
It covers essential tools, systems, commands, and partition
management practices.
Following are key topics to focus on:
a) The fdisk Command
b) Common fdisk Options
c) Viewing All Disk Partitions
d) Viewing a Partition on a Specific Disk
e) Viewing All fdisk Commands
f) Creating a Hard Disk Partition
g) Deleting a Hard Disk Partitio
SOHAIL
ASGHER
Linux Disk Management
a) The fdisk Command
The fdisk command is essential when adding new storage or
reorganizing existing space.
It allows for clear partitioning, which helps to separate
different file systems.
Syntax:
fdisk [options] device Or fdisk -l [device...]
b) Common fdisk Options
Using fdisk options allows for more efficient disk
management and each option is for a specific use case.
Uses:
-l: Quickly see a summary of all disk partitions.
-s: Check partition sizes to ensure allocation.
-d: Back up partition tables for disaster recovery.
-u: Gain precise information about sector allocations.
-b: Modify the sector size for compatibility with hardware.
SOHAIL
ASGHER
Linux Disk Management
c) Viewing All Disk Partitions
Listing all partitions helps you get a complete overview of the
disk structure and space allocation.
It’s crucial before making any disk changes to avoid data loss
or corruption.
Command:
$ sudo fdisk -l
d) Viewing a Partition on a Specific Disk
Viewing partitions for a specific disk narrows down the focus
to a single device.
This makes it easier to manage large systems with multiple
disks.
Command:
$ sudo fdisk -l /dev/sda
SOHAIL
ASGHER
Linux Disk Management
e) Viewing All fdisk Commands
Being able to see all available commands under fdisk
enhances your control over disk management.
It helps users quickly discover less-known commands and
functionalities for better efficiency.
Command:
$ sudo fdisk /dev/sda
f) Creating a Hard Disk Partition
Partitioning allows the flexibility to dedicate different
partitions for system files, personal data, backups, etc.
This improves both performance and organizational
structure.
Steps:
i) Open the disk with fdisk:
$ sudo fdisk /dev/sda
ii) Type n to create a new partition.
iii) Type p to create a primary or e for an extended partition.
iv) Once done, use the w command to write changes and reboot.
SOHAIL
ASGHER
Linux Disk Management
g) Deleting a Hard Disk Partition
Deleting partitions frees up space that can be reallocated for
other uses.
It is crucial when reorganizing disk space or preparing a disk
for new installations.
Steps:
i) Open the disk with fdisk:
$ sudo fdisk /dev/sda
ii) Type d to enter the delete partition menu.
iii) Specify the partition number to delete.