Linux: How to connect external hard drive

Quick How To Guide

Diagnostic commands

Display from log directory what was recently connected

# tail -20 /var/log/messages

Display list of the partition tables

# fdisk -l

Display device parameters

# hdparm /dev/sda

More detailed information

# hwbrowser
# more /etc/sysconfig/hwconf

Connection process

Run fdisk

# fdisk /dev/sda

Get list of existing partitions

Command (m for help): p

Delete partition which exist on the drive

Command (m for help): d

Create new partition

Command (m for help): n

Verification before save

Command (m for help): p

Save new table to drive

Command (m for help): w

Update partition table in system

# partprobe

Alternative to partprobe is hdparm -z

# hdparm -z /dev/sda

Format created partition to ext3 file system

# mkfs.ext3 /dev/sda1

Verification if partition is not mounted

# df -hT

Mount new-created partition to directory /mnt/usb. If directory is not exist, first created it.

# mkdir /mnt/usb
# mount /dev/sda1 /mnt/usb
# df -hT

Display disk partitions

# parted /dev/sda unit GB print free

Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.