"parted" - Partition Manipulation Program

Provides a tutorial example on how to use 'parted' command to print the partition table of a given hard disk.

If you are tired of using the "fdisk" command to view and manage hard disk partitions, you can try the "parted" command, which provides almost the same functionalities as "fdisk". But "parted" command seems to output better information.

Here is an example of using the "parted" command to print the partition table of the first hard disk, comparing with the "fdisk" command:

herong$ sudo parted /dev/sda print

  Model: ATA WDC WD10EZEX-08M (scsi)
  Disk /dev/sda: 1000GB
  Sector size (logical/physical): 512B/4096B
  Partition Table: msdos
  Disk Flags:

  Number  Start   End     Size    Type      File system  Flags
   1      1049kB  85.9GB  85.9GB  primary   ntfs         boot
   2      85.9GB  1000GB  914GB   extended               lba
   5      85.9GB  895GB   809GB   logical   ntfs
   6      895GB   896GB   1074MB  logical   ext4
   7      896GB   1000GB  104GB   logical                lvm

herong$ sudo fdisk -l /dev/sda

  Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 4096 bytes
  I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  Disklabel type: dos

  Device     Boot      Start        End    Sectors   Size Id Type
  /dev/sda1  *          2048  167776255  167774208    80G  7 HPFS/NTFS/exFAT
  /dev/sda2        167776256 1953523711 1785747456 851.5G  f W95 Ext'd (LBA)
  /dev/sda5        167778304 1748721663 1580943360 753.9G  7 HPFS/NTFS/exFAT
  /dev/sda6       1748723712 1750820863    2097152     1G 83 Linux
  /dev/sda7       1750822912 1953523711  202700800  96.7G 8e Linux LVM

As you can see from the output, the "parted" command provides better information about each partition. For example, partition #2 is an "extended" partition, which is flagged as "lba (Logical Block Addressing)" with no file system. This is becuase partition #2 is used as a container to create sub-partitions.

Here is another example of using "parted" command on a logical volume:

herong$ sudo lvs
  LV   VG Attr       LSize  Pool Origin Data%  Meta%  Move Log
  home cl -wi-ao---- 38.94g
  root cl -wi-ao---- 50.00g
  swap cl -wi-ao----  7.71g

herong$ sudo parted /dev/mapper/cl-home print
  Model: Linux device-mapper (linear) (dm)
  Disk /dev/mapper/cl-home: 41.8GB
  Sector size (logical/physical): 512B/4096B
  Partition Table: loop
  Disk Flags:

  Number  Start  End     Size    File system  Flags
   1      0.00B  41.8GB  41.8GB  xfs

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

File Systems

 "df" - Display Free Space of File System

 Mount USB Drive as File System

 "fdisk" - Format Disk Partitions

 "dd" - Copy Data from/to Storage Devices

 Use "dd" Command to Test I/O Speed

 "hdparm" - Hard Disk Parameters

 "du" - Display Disk Usage of Directories

 Mount Windows NTFS File System

 Access Persmissions on "ntfs-3g" File System

 Mount Windows Shared Folders

 W95 Ext'd (LBA) Partition

 File System Types, IDs and Formats

 LVM (Logical Volume Manager)

"parted" - Partition Manipulation Program

 Reformat NTFS Partition into EXT4 Partition

 Unreachable Remote File Systems

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 Running Apache Web Server (httpd) on Linux Systems

 Running PHP Scripts on Linux Systems

 Running MySQL Database Server on Linux Systems

 Running Python Scripts on Linux Systems

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 GCC - C/C++ Compiler

 Conda - Environment and Package Manager

 Tools and Utilities

 References

 Full Version in PDF/EPUB