Disk Management

Command
Description
Example

lsblk

List information about block devices (disks, partitions).

lsblk → Displays block devices and their mount points.

fdisk

Partition table manipulator for Linux.

sudo fdisk -l → Lists all partitions on all devices.

mount [device] [mount_point]

Mount a file system to a directory.

sudo mount /dev/sda1 /mnt → Mounts /dev/sda1 to * /mnt*.

umount [mount_point]

Unmount a file system.

sudo umount /mnt → Unmounts * /mnt*.

chroot

Change the root directory for the current process.

sudo chroot /mnt → Changes root to * /mnt*.

resize2fs

Resize ext2/ext3/ext4 file systems.

sudo resize2fs /dev/sda1 → Resizes the file system on * /dev/sda1*.

fsck

File system consistency check.

sudo fsck /dev/sda1 → Checks and repairs file system on * /dev/sda1*.

swapoff

Disable swapping on devices.

sudo swapoff /dev/sda2 → Disables swapping on * /dev/sda2*.

swapon

Enable swapping on devices.

sudo swapon /dev/sda2 → Enables swapping on * /dev/sda2*.

mount -o loop [iso] [dir]

Mount an ISO file as a loop device.

sudo mount -o loop image.iso /mnt → Mounts image.iso to * /mnt*.

lsof

List open files and processes using them.

lsof → Lists all open files and the processes using them.

Last updated