How to Add a Hard Drive to Ubuntu

There are many tutorials available that explain how to add a hard drive to a server, but I feel that they often miss a few important last steps.

Many of the tutorials fail to mention how to reclaim 5% of the hard drive’s space that is reserved for the superuser by default, which is often unnecessary. After I walk through the basics, I will introduce you to a CLI tool called tune2fs, which will reclaim this needlessly-lost space.

If you are installing a Western Digital Green hard drive in a server that runs 24/7, you can easily extend the life of your hard drive by using a simple CLI tool called idle3ctl. This tool can disable the head park timer, which will make it behave like a WD Red drive, which is designed for NAS devices and servers that are on 24/7.

Install the New Drive


First, shut down the server, disconnect it from power, and open the case. The fans and other internal components have likely accumulated some dust, so use this opportunity to blast everything with a can of compressed air.

Next, remove the hard drive from its anti-static protective packaging and slide it into an available hard drive bay. Using the hard drive screws that came with your case–you didn’t throw them away, did you?–attach the drive to your case. If you don’t have these screws, they are available on Amazon. Connect a power cord to the hard drive from the PSU, and use a SATA cord to connect the motherboard to the hard drive.

Close the case and boot the server.


Determine the Drive Name

$ sudo lshw -C disk

This will print information about all of the drives attached to your server. The output should resemble the following:

description: ATA Disk
product: WDC WD40EZRX-00S
vendor: Western Digital
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: 80.0
size: 3726GiB (4TB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: ansiversion=5 guid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX sectorsize=4096

From the sample output above, we can see that the logical name of the disk is /dev/sda.


Open a terminal and run the following to open GParted, a tool used to partition drives.

$ sudo gparted

After the application loads, use the drop-down menu in the top left on the window to select the logical name of your drive (/dev/sda in our example).

Next, right-click on the bar and select “New.”

On the window that appears, fill the entire disk with the new partition and choose “Primary Partition.”

Select the ext4 filesystem in the dropdown and click “Add.”

The new partition should fill the entire disk. Click “Apply” to perform the changes. The partition number is appended to the drive’s name. In our example, the new drive is called /dev/sda1.


Create a new directory where Ubuntu will mount the drive. By default, this directory is under /media.

$ sudo mkdir /media/[drive name]

You can now run the mount command to mount the drive.

$ sudo mount /dev/sda1 /media/[drive name]

Auto Mount

Open the Disks program, select the new hard drive, click on the settings button, and select “Edit Mount Options” (shown below).

Select Mount Options

Change the options to reflect my options below.

Mount Options

This interface modifies /etc/fstab, which is why it asks for your superuser password when you apply changes.

Reclaim Lost Space

By default, 5% of the drive’s space is reserved for the superuser. This allows the superuser to write to the disk even when the disk is “full.” You can change this by usng tune2fs. The example shown below reserves 0% of space for the superuser, allowing the entire disk to be used by you.

$ sudo tune2fs -m 0 /dev/sdb1

The -m option specifies the percentage of total space to reserve. Alternatively, you may specify the number of blocks to reserve by using the -r option.

This command executes quickly and can be changed any time, so you may also wait until you need more space to use tune2fs.

Extend the Life of WD Green Drives

The Green line of WD drives has a power-saving feature called auto-park, which parks the drive’s head every 8 seconds. This works well when data isn’t accessed frequently, because it can save power, but if the drive is frequently read from and written to, this can dramatically decrease its lifespan.

There is a DOS utility called WDIDLE3 that can modify the head parking timer. Thankfully, someone has ported the utility to Ubuntu. To install it, run

$ sudo apt-get install idle3-tools

To disable the timer, run the following.

$ sudo idle3ctl -d /dev/sdb

You will see a message instructing you to poweroff the machine for the setting to apply. A reboot will not suffice. To accomplish this, run the following command to shutdown your machine.

$ sudo shutdown -P

The -P argument tells the system to power off after it is shutdown.

That’s it for now! Please let me know if you have any questions or corrections.