Awasu » Adding a new hard disk to Open Media Vault
Sunday 4th October 2015 6:38 PM []

We're now ready to add a hard disk, to store our files on. After you plug it in, it will appear as a "file"[1]Linux has the convention that everything can be treated as a file. in the /dev/ directory:

If there are no other external drives plugged in, it will appear as /dev/sda[2]The "sd" in sda means it's a removable device ("SCSI device", a historical artifact), the first drive gets the letter "a", the second "b", etc.[3]If you unplug the drive, you will see this "file" disappear..

Assuming it's a brand new disk, we need to prepare it, so that it can be used by Linux.

Preparing the hard disk

First, we need to create a partition[4]Partitions are used to split a disk up into separate, independent sections that can be used for different purposes. Since I will only be storing data files on this disk, I only need a single partition. on the disk that takes up all the available space.

If the drive is 2 TB or smaller[5]For drives larger than 2 TB, you will need to use the parted command, but the process is similar., we can use fdisk:

  • Type "n" to create a new partition. Accept all the defaults, so that the partition will take up the entire disk.

     

  • Type "p" to print the current partition table. Since we started with a new disk, there should have been no partitions present, so the only partition will be the one we just created[6]If there are other partitions present, you should delete them beforehand..

     

  • Type "w" to write out the new partition table.


If we check the /dev/ directory, we now see a new entry that represents the partition we just created[7]If we had created multiple partitions, then we would also see /dev/sda2, /dev/sda3, etc.[8]Note that the /dev/sda entry is still present, which represents the physical disk drive; the numbered entries represent the partitions on the drive.:

 

We now create a new file system in this partition[9]Note that we specify /dev/sda1 since we want to create the file system in the partition, not /dev/sda, which refers to the physical disk drive..

There are many different types of file system, but I use ext3[10]This post provides a work-around for a problem ext3 has when deleting large files. rather than the newer ext4, since I want to be able to plug these disks into a Windows computer and the tool that I use for this (ext2fsd) has trouble writing to ext4.

Other considerations

Our new disk is ready to go, but there are a few more things we should do.

Firstly, it would be a good idea to turn off quotas, since this can sometimes cause lengthy delays when the system boots up:

    sudo update-rc.d quota disable 

Secondly, by default, mkfs.ext3 holds back some space (5%) for the sole use of the root super-user, to stop the system from failing if the disk fills up.

This policy was implemented when disk drives were much smaller, and these days, with much larger disk drives, it will result in a lot of space being wasted[11]In this example, I'm using a 1TB drive, and 12209519 blocks (size 4K each) is about 46 GB!. Furthermore, since I will only be storing data files on this disk, and not using it for anything system-related, holding back this space is pointless.

Fortunately, it's easy to reclaim this space using tune2fs:

Mounting the file system

Normally, we would now use the mount command to load the new file system into Linux, but since we're going to use it for OMV, it's better to let OMV do this for us.

In the web admin interface, go to the Storage/File Systems section and mount the file system there.

 

It will be mounted into the /media/ directory:

The file system is, of course, empty except for the standard lost+found directory[12]This is used to store lost data if the file system gets corrupted..

Because we mounted the file system via OMV, it has updated /etc/fstab and our drive will now be mounted every time the system boots:

« Setting up Open Media Vault on a Banana Pi

Tutorial index

Configuring Open Media Vault »

   [ + ]

1. Linux has the convention that everything can be treated as a file.
2. The "sd" in sda means it's a removable device ("SCSI device", a historical artifact), the first drive gets the letter "a", the second "b", etc.
3. If you unplug the drive, you will see this "file" disappear.
4. Partitions are used to split a disk up into separate, independent sections that can be used for different purposes. Since I will only be storing data files on this disk, I only need a single partition.
5. For drives larger than 2 TB, you will need to use the parted command, but the process is similar.
6. If there are other partitions present, you should delete them beforehand.
7. If we had created multiple partitions, then we would also see /dev/sda2, /dev/sda3, etc.
8. Note that the /dev/sda entry is still present, which represents the physical disk drive; the numbered entries represent the partitions on the drive.
9. Note that we specify /dev/sda1 since we want to create the file system in the partition, not /dev/sda, which refers to the physical disk drive.
10. This post provides a work-around for a problem ext3 has when deleting large files.
11. In this example, I'm using a 1TB drive, and 12209519 blocks (size 4K each) is about 46 GB!
12. This is used to store lost data if the file system gets corrupted.

2 Responses to this post

Hi, Taka!
Nice tutorial.
The link in footnote 10, though, doesn't seem to go to the right place.

Fixed, thanks for the heads-up.

Good to see you're still around... 🙂

Have your say