top of page
BlueDolphin

Linux Hard Disk/Drive - Reference

Hard Disk Layout
  • du -h --max-depth=1 - Total space taken by each directory

  • du -h --max-depth=1 /usr - Total space taken up individually by the sub directories and usr directory

  • swapon -s - The swap partition is a separate partition that moves items around from computer memory to hard drive,

  • mount - List all partitions on the hard disk and their mount points



Using Various Disk Management Tools

Parted - The parted command can also display and modify the partitions.



sudo parted /dev/sda u s p - To display the partition table

u - An abbreviation for Unit command.

s - Refers to the unit Sector, this can be interchanged with the following: B, KiB, MiB, GiB, TiB, kB, MB, GB, TB, %, cyl, chs, compact.

p - An abbreviation for Print command.



sudo parted -l



Fdisk - is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables. Block devices can be divided into one or more logical disks called partitions. This division is recorded in the partitiontable, usually found in sector 0 of the disk. (In the BSD world one talks about `disk slices' and a `disklabel'.)


List disk information

sudo fdisk -l /dev/sda 


Interactive prompt

sudo fdisk /dev/sda


  • --- press m - to list available commands

  • --- press p - display existing partition tables

  • --- press d - delete partition

  • --- press n - create new partition

  • --- press w - write any changes made, such as deleting and creating a new table

Gdisk - GPT is the latest standard for defining the partitions on a hard disk. GPT uses globally unique identifiers (GUID) to define the partition, and you can create theoretically unlimited partitions on the hard disk. In this task, you will create and access a GPT table on the /dev/sdb device.


sudo gdisk /dev/sda1


Swap



swapon 

sudo mkswap /dev/sdb2

mkfs



sudo mkfs -t ext3 /dev/sdb2

lsblk


sudo lsblk -f


/proc/partitions


You can use view the /proc/partitions file to view the hard drive details. This file contains a table that mentions the major and minor number of partitioned devices. Type the following command:


cat /proc/partitions

Press Enter. Notice that there are major and minor columns. The major column defines the device type. For example, the number 2 denotes a floppy drive. The number 8 denotes sd device. The minor column defines the unique identification of an instance of this device type.


cfdisk

The cfdisk utility is a partition editor that can display and modify the partitions.



sudo fdisk

sudo fdisk -l

sudo sfdisk -l -uM

/proc/mounts


cat /proc/mounts

Similar to the partition and volume information, you can also view the mount points. Type the following command:



df

The df command can also display the information about the mounted filesystems. Type the following command:



df -h

lsscsi

The lsscsi utility is meant to list the SCSI devices on a system



lsscsi


The smartctl utility is meant to print the drive information. Type the following command:


sudo smartctl -i /dev/sda


73 views0 comments

Recent Posts

See All

Comments


bottom of page