Member-only story

Summary Linux Disk Related Commands

Maciej
6 min readDec 6, 2021

--

Introduction

In this post we will look at commands that relate to disks in Linux.

Commands

  • Information display: lsblk , blkid
  • Partition creation: fdisk , cfdisk , gdisk, cgdisk, sgdisk, parted
  • Mount: mount , umount
  • File system: mkfs , fsck
  • File system (ext2 / 3/4): resize2fs, dumpe2fs, tune2fs
  • Swap: mkswap , swapon, swapoff
  • SMART Information display: smartctl
  • LVM: lvmdiskscan, pvdisplay, pvscan, lvdisplay, lvscan
  • Dealing with Bad sectors: badblocks, ddrescue
  • Finding out which directory is consuming space: ncdu

Information display

You can find almost all the information with fdisk -l You can tell whether it is MBR or GPT by looking at “Disk Label Type”. It doesn’t show where it’s mounted, so use the mount command.

Use Fdisk -l

root@master:/home/ozyrys# fdisk -l  -o +UUID
Disk /dev/loop0: 42.18 MiB, 44220416 bytes, 86368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 55.5 MiB, 58183680 bytes, 113640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 61.85 MiB, 64835584 bytes, 126632 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop3: 67.25 MiB, 70508544 bytes, 137712 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop4: 55.51 MiB, 58191872 bytes, 113656 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop5: 32.42 MiB, 33980416 bytes, 66368 sectors
Units: sectors…

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

No responses yet

Write a response