Disk Management on Linux
In this article, I resume some bash commands to check up or manage partitions on a linux system. The commands would check what partitions there are on each disk and other details like the total size, used up space and file system etc.
List block devices lsblk
lsblk
lists the different partitions and block devices in the system with their ids. The command prints all block devices (except RAM disks) in a tree-like format.
lsblk
Mount a disk
We have to create a directory which will be the mount point for the device. The command mount
mounts the device to the mount point.
sudo mkdir /{your directory name here}
sudo mount /dev/{specific device id} /{your directory name here that is already created}
unmount a disk
umount
command unmounts any mounted filesystem on your system. It requires disk name or mount point name to unmount currently mounted disk.
sudo umount /dev/sdb
Permanently mount a disk
Set the system so that your devices will be automatically mounted. All information about device, format and mountpoint can be checked on /etc/fstab
cat /etc/fstab
To add a new drive to the mounted devices, edit /etc/fstab
sudo vi /etc/fstab
This file is a table of 6 columns, each row describes a mounted devices.
- Device specifies the mount device. These are usually device filenames. Most distributions now specify partitions by their labels or UUIDs.
- Mount point specifies the mount point, the directory where the partition or disk will be mounted. This should usually be an empty directory in another file system.
- File system type specifies the file system type i.e. ext4
- Options specifies the mount options. Most file systems support several mount options, which modify how the kernel treats the file system. You may specify multiple mount options, separated by commas.
- Backup operation contains a 1 if
dump
should back up a partition or a 0 if it shouldn’t. If you never usedump
you can ignore this option. - File system check order specifies the order in which
fsck
checks the device/partition for errors at boot time. A 0 means that fsck should not check a file system. Higher numbers represent the check order. The root partition should have a value of 1 , and all others that need to be checked should have a value of 2.
Once, fstab is filled, we have to test it.
sudo mount -a
If this command works, then we can reboot the system. By experience, errors returned by mount
is often due to a bad file system type.
sudo reboot
References
Learning the bash Shell: Unix Shell Programming
Cameron Newham and Bill Rosenblatt
O'Reilly Media, 1995. ISBN‑13: 978-0596009656
Relevant Tags
About the Author
Latest Articles
-
Turing Complete: From Logical Gates to CPU Architecture
In 2021, LevelHead published Turing Complete, a game about computer science. My friend Christophe Georgescu recommended me to play it. Unfortunately, I took his advice and now I can not stop to play this game! The game challenges you to design an entire computer from scratch. You start with basic logic gates, then move on to components, memory, CPU architecture, and finally assembly programming. By the way, the game is neat and present all these concepts in a playful and intuitive way.SEP 2025 · PIERRE-EDOUARD GUERIN -
How to Manage a Project?
In any company, every task is part of a project. I am responsible for managing multiple projects each year. I have to present deliverables to stakeholders, meet deadlines, allocate mandays and coordinate everyone’s actions. This is a meticulous work that requires a strong methodology.JUN 2025 · PIERRE-EDOUARD GUERIN -
Gantt Chart Excel for Project Management
A Gantt chart visualizes the scheduling of tasks over the project timeline. My colleague Daphne Verdelet shared with me the Excel template her team at INRAE uses to keep track of their tasks over the year.MAY 2025 · PIERRE-EDOUARD GUERIN