
Managing
the disk storage is a critical task for every Linux user and the system
administrator. Whether you manage a personal Linux workstation or the
production servers, you must regularly monitor the disk usage, check partitions
and troubleshoot the storage issues.
Linux provides the several powerful commands that allow you to inspect
the disks, analyze the storage usage, manage the partitions and mount the file
systems efficiently.
Before working with the disk and storage commands in the Linux, it is important to understand the basics of the operating system. If you are new to the Linux read our complete guide on What is Linux? An Introduction to Linux and Its Popular Distributions.
In this guide, you will know the most appropriate disk and storage
commands in the Linux using practical examples. These commands help you:
- Monitor
disk space usage
- Identification
of the storage devices and partitions
- Analyze
directory sizes
- Manage
disk partitions
- Mount
and unmount storage devices
- Troubleshoot
the disk related problems
By mastering these commands you can maintain the system stability and
avoid the disk space issues.
Why
Disk and Storage Management is Important in the Linux
The administration of your disk is a good practice that allows your
system to run smoothly and without the sudden failure. The services and applications
can crash down when there is a lack of storage or when partitions are
configured improperly.
The efficient disk management can assist you in the following:
- Prevent
disk space exhaustion
- Monitor
server storage usage
- Management
of the partitions and file systems
- Troubleshoot
performance issues
- Maintain
system reliability
Linux provides several built-in tools that allow the administrators to
manage the disk storage efficiently.
Disk
& Storage Commands
1. lsblk
Command – List Block Devices
The lsblk command displays the information about all the available block
devices such as hard drives, SSDs and partitions. It gives a clear tree like
view of the storage devices and their mount points. This command is extremely
useful when you want to identify all the disks, partitions and the mounted filesystems.
Basic
Syntax
lsblk
This output
shows:
·
Disk
name
·
Partition
structure
·
Mount
points
·
Disk
size
1.2 Display file system
information
This command can be used to display the types of file system e.g. ext4,
xfs or swap.
lsblk -f
1.3
Display specific columns
This command is used to fetch the information about specific columns.
lsblk -o NAME, SIZE, FSTYPE, MOUNTPOINT
This helps the administrators to quickly analyze the storage devices.
2. df
Command – Check Disk Space Usage
The
df command gives the current statistics of the free and used disk space on the
mounted file systems.It is one of the most commonly used commands for
monitoring the usage of storage.
Basic Syntax
df
This command shows the following information:
·
File
system
·
1K-blocks
·
Used
blocks
·
Available
blocks
·
Use
Percent
·
Mount
on
2.1 Human-Readable Output
df -h
This output shows:
·
Total
disk size
·
Used
space
·
Available
space
·
Percentage
usage
2.2 Check Specific
Directory
df -h /home
this command shows the file system, size, used space, available space and mount point of the specific directory.
2.3
Show File System Type
This can be handy when you want to check the file system type such as
the ext4, xfs or btrfs.
df -T
2.4
list Inode Information
This command used to list inode information instead of the block usage.
df -i
2. du
Command – Check the Disk Usage
du command approximates the space occupied by files and directories. It
is also very useful when a disk is full and you have to find huge directories.
Basic Syntax
du
2.1 Check Folder Size
This command shows the information about size of the specific folder or
directory.
du -sh /var
The total size of the /var directory.
2.2 Check All
Directories
This command shows size of all the directories.
du -h 
2.3 Find Largest
Directories
This command will list the directories and their sizes allowing one to
quickly locate the space taken by the folders.
du -h --max-depth=1
3. blkid
Command- File system and UUID
The blkid command is used to show the attributes of a block device such
as types of the file system and UUID. This command is very common in the setup
of storage by system administrators in the /etc/fstab file.
Basic Syntax
blkid
This output shows:
·
Device
name
·
File
system type
·
Unique
UUID identifier
The UUID system is also better because the device names may change
during a reboot, and the UUID system does not lose stability.
4. fdisk
Command - disk partitions
fdisk is an effective disk partitioning utility that is applicable in
creating, erasing, and updating partitions. It is commonly used when preparing
new disks for use.
4.1
List Available Disks
sudo fdisk -l
This command displays:
·
All
connected disks
·
Partition
tables
·
Disk
sizes
·
File
system types
4.2 Manage a Disk
sudo fdisk /dev/sda
After running this command an interactive interface is appeared to you
where you can:
·
Create
partitions
·
Delete
partitions
·
Modify
partition types
·
Write
changes to disk
4.3
Create Partition
Caution: This may erase the
data in case it is done improperly. Always take backup and verify the disk name
before the proceeding.
4.3.1 List Available
Disks
First, identify your disk (e.g., /dev/sdb).
sudo fdisk -l
Look for:
·
Disk
name (/dev/sdb, /dev/sdc)
·
Disk
size
·
Existing
partitions
4.3.2 Open Disk in
fdisk
Here disk name is /dev/sdb. You have to change the name of the disk
accordingly. Check the disk name with fdisk -l command as shown above.
sudo fdisk /dev/sdb
This command brings you into an interactive interface for the creation
of partition.
4.3.3 See the Current
Partitions Table (Optional)
Press p
So that we can see the current partition table.
4.3.4 Create New
Partition
To create new a partition press n
You will be prompted for:
Choose partition type
·
p
for primary
·
e
for extended
Press Enter (default primary).
4.3.5 Select
Partition Number
Press Enter for the default option.
4.3.6 Set First
Sector
Press Enter for the default option.
4.3.7 Set Last Sector
(Size)
·
+5G
to create 5GB partition
·
+500M
to create 500MB partition
·
Press
enter to use full disk
Full disk option is selected to create this partition.
4.3.8 Verify
Partition
Press p so that you can check that new partition is created.
4.3.9 Write Changes
to the Disk
This saves changes and exits fdisk.
Formatting is the process of setup of a file system on a disk or a
partition that Linux can use to store and manipulate the information on it. This
is one of most important command for system administrators because they use
this on daily basis.
4.4.1 Identify the
Partition
Before formatting identify the right partition. Use lsblk command
4.4.2 Format Using
mkfs
The main format command in the Linux is mkfs that is used to make file system.
mkfs.ext4 /dev/sdb1
You can replace
ext4 with:
·
xfs
·
ntfs
·
fat32
5. mount
Command – Mount File System
The mount command attaches a file system to the Linux directory tree for
the convenience of the system to access it. Without the mounting, the operating
system cannot read or write the data on the disk.
5.1
Show Mounted File systems
This command is used to show all the mounted storage devices.
Mount
5.2
Mount a Disk
This command is used to mount the partitions or external drive such as
/dev/sdb1 to a mount point directory /mnt. Upon mounting, users can access
files in the disk.
sudo mkdir /mnt/mydisk
sudo mount /dev/sdb1 /mnt/mydisk
5.3
umount Command – Unattach the File Systems
Umount command is a safe way of unattaching a mounted file system. It is
important to ensure that you unmount a device prior to removal so as to avoid
the corruption of data.
sudo umount /mnt/mydisk 
This command is used to unattach the mounted disk contents from the
directory. In case the device is busy, Linux cannot unmount it until all the
running processes are shut down.
Troubleshooting
Workflow of the Disk
Step 1 – Check Disk
Usage
df -h
This command is used to show that which file system is full.
Step 2 – Find Large
Directories
du -h --max-depth=1 /
This helps to locate the directories which are consuming the most space.
Step 3 – Check Disk
Devices
lsblk
This
helps to verify the disks and mount points. These commands together allow the
administrators to quickly diagnose the storage issues.
Managing disk usage is closely related to the controlling running processes that consume the system resources. Learn how to manage the processes in the Linux in our tutorial on Linux Process Management for Beginners – Complete Guide 2025.
Best
Practices for Disk Management in the Linux
The below storage management practices are used to preserve a healthy
Linux system.
·
Monitor
disk usage regularly
·
Clean
unnecessary files and logs
·
Use
UUIDs in /etc/fstab
·
Create
proper partition layouts
·
Monitor
storage growth on servers
Implementing these practices prevent the unexpected storage failures.
Frequently Asked Questions (FAQs)
1.How do I check disk space in Linux?
Use the
following command:
df -h
It displays
disk usage in a human readable format.
2.How to check the directory size in the
Linux?
Use the du
command:
du -sh
directory_name
3.How do I list disks in Linux?
Use the lsblk
command:
lsblk
4.How do I find disk UUID in Linux?
Use:
blkid
This is the command
that is used to show the file system information and UUID.
📚 Related Articles
Conclusion
Linux
provides a powerful set of commands for the management of the disk storage and
file systems. Tools like lsblk, df, du, blkid, fdisk, mount and umount allow
the administrators to monitor the storage usage, manage partitions and
troubleshoot disk related problems effectively.
These commands
improves your ability to maintain the system performance, prevent the disk
space issues and manage the storage resources efficiently. If you work
regularly with the Linux systems than mastering these disk and storage commands
will significantly improve your system administration skills.
The most recent Linux guides and tutorials can be found on the SeekLinux. You are welcome to give us your feedback and suggestions.
Post a Comment