HostOnNet Blog

Useful Linux Commands to work with Hard Disk Drives

Looking for Linux Server Admin or WordPress Expert? We can help.

hard_disk_drive

Some useful commands when working with Hard Disks on Linux Server.

lsblk

lsblk command list all hard disks on your server.

boby@fwhlin:~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   1.8T  0 disk 
├─sda1   8:1    0 927.8G  0 part /mnt/drive_d
└─sda2   8:2    0 927.8G  0 part /mnt/backup_win
sdb      8:16   0 931.5G  0 disk 
├─sdb1   8:17   0 244.1G  0 part 
├─sdb2   8:18   0 247.3G  0 part 
├─sdb3   8:19   0 187.4G  0 part 
├─sdb4   8:20   0     1K  0 part 
├─sdb5   8:21   0 246.8G  0 part /
└─sdb6   8:22   0     6G  0 part [SWAP]
sdc      8:32   0   1.8T  0 disk 
├─sdc1   8:33   0   2.9M  0 part 
├─sdc2   8:34   0 186.3G  0 part 
└─sdc3   8:35   0   1.7T  0 part /home/boby/disks/part_data
sr0     11:0    1  1024M  0 rom  
boby@fwhlin:~ $ 

parted

parted is improved fdisk. If your hard disk is better, always use parted instead of fdisk to partition it.

To list all partition on your hard disk, run

root@fwhlin:~# parted -l
Model: ATA WDC WD20EZRX-00D (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  2000GB  2000GB  primary


Model: ATA ST31000528AS (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  262GB   262GB   primary   ntfs            boot
 2      262GB   528GB   265GB   primary   ntfs
 4      528GB   799GB   271GB   extended
 5      528GB   793GB   265GB   logical   ext4
 6      793GB   799GB   6433MB  logical   linux-swap(v1)
 3      799GB   1000GB  201GB   primary


Model: ATA WDC WD20EZRX-00D (scsi)
Disk /dev/sdc: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  3049kB  3032kB                     bios_grub
 2      3049kB  200GB   200GB   ext4
 3      200GB   2000GB  1800GB  ext4


root@fwhlin:~# 

ls /dev/disk/by-id

boby@hon-pc-01:~ $ ls /dev/disk/by-id
ata-ATAPI_iHAS124_E_3524696_2H7416504666        wwn-0x5000c5002d82a97a
ata-ST31000528AS_9VPB6LGV                       wwn-0x50014ee6034ace9f
ata-WDC_WD20EZRX-00D8PB0_WD-WMC4M2583202        wwn-0x50014ee6034ace9f-part1
ata-WDC_WD20EZRX-00D8PB0_WD-WMC4M2583202-part1  wwn-0x50014ee6034ace9f-part2
ata-WDC_WD20EZRX-00D8PB0_WD-WMC4M2583202-part2  wwn-0x50014ee6034ace9f-part3
ata-WDC_WD20EZRX-00D8PB0_WD-WMC4M2583202-part3  wwn-0x50014ee6034ace9f-part4
ata-WDC_WD20EZRX-00D8PB0_WD-WMC4M2583202-part4  wwn-0x50014ee6aee8b23b
ata-WDC_WD20EZRX-00DC0B0_WD-WMC301728244        wwn-0x50014ee6aee8b23b-part1
ata-WDC_WD20EZRX-00DC0B0_WD-WMC301728244-part1  wwn-0x50014ee6aee8b23b-part2
ata-WDC_WD20EZRX-00DC0B0_WD-WMC301728244-part2  wwn-0x50014ee6aee8b23b-part3
ata-WDC_WD20EZRX-00DC0B0_WD-WMC301728244-part3  wwn-0x50014ee6aee8b23b-part4
ata-WDC_WD20EZRX-00DC0B0_WD-WMC301728244-part4
boby@hon-pc-01:~ $ 

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.