Using a New Hard Disk on Ubuntu

🔖 iot ⏲️ 1 minute to read

A guide on formatting and mounting a new physical disk on Ubuntu.

First, it's a good idea to list block devices attached to the system:

$ sudo lsblk

NAME                      MAJ:MIN RM    SIZE RO TYPE MOUNTPOINTS
sda                         8:0    0      1T  0 disk
├─sda1                      8:1    0      1G  0 part /boot/efi
├─sda2                      8:2    0      2G  0 part /boot
└─sda3                      8:3    0 1020.9G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 1020.9G  0 lvm  /
sdb                         8:32   0  931.5G  0 disk
sr0                        11:0    1   1024M  0 rom

This allows you to see if the hard disk you expect is actually recognised by the OS. Next, list the partitions on the system - note the disk name:

$ sudo parted -l

Model: WDC WD10 EZEX-08RKKA0 (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  1000GB  1000GB  ext4

By now we've seen the disk name twice as /dev/sdb. It's important to get the name of the disk right, since the next step will destroy data. To format the disk as ext4:

$ sudo mkfs.ext4 -j -L ext1 /dev/sdb

And to verify it worked, and get the disk UUID:

$ sudo blkid /dev/sdb

/dev/sdb: LABEL="ext1" UUID="86a24bca-ac32-4d8c-a7f8-af893dad5fac" BLOCK_SIZE="4096" TYPE="ext4"

Now, you need to make a mount point folder, where the contents of the drive will be available:

$ sudo mkdir /mnt/ext1

And then, add the fstab entry for the mount point, using the disk UUID from earlier:

$ sudo nano /etc/fstab

Add the following line to the end fstab, where 86a24bca-ac32-4d8c-a7f8-af893dad5fac is the UUID of your disk from the output of sudo blkid /dev/sdb:

/dev/disk/by-uuid/86a24bca-ac32-4d8c-a7f8-af893dad5fac /mnt/ext1 auto

To mount the drive:

$ sudo mount -a

If you see a lost+found folder in /mnt/ext1, it worked! To check the SMART status of your drive, use the following command:

$ sudo smartctl --all /dev/sdb

The vendor specific attributes near the bottom are the interesting ones, such as Power_On_Hours:

Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   174   171   021    Pre-fail  Always       -       2300
  4 Start_Stop_Count        0x0032   093   093   000    Old_age   Always       -       7760
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   080   080   000    Old_age   Always       -       15246
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   099   099   000    Old_age   Always       -       1721
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       90
193 Load_Cycle_Count        0x0032   198   198   000    Old_age   Always       -       7669
194 Temperature_Celsius     0x0022   117   100   000    Old_age   Always       -       26
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   200   200   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   200   200   000    Old_age   Offline      -       0

🏷️ disk uuid mount drive ubuntu next folder guide formatting mounting idea block devices attached expect

⬅️ Previous post: 10 Year Anniversary of Estranged

🎲 Random post: Useful ffmpeg Recipes

Comments

Please click here to load comments.