Adding a second hard drive to your HDA

From Amahi Wiki
Jump to: navigation, search
Warning.png WARNING
This is recommended only for advanced users, proceed with caution.


Adding drives to your HDA is another howto on doing this, a bit shorter and less elaborate, which can be good for some people, specially a novice unfamiliar with doing any of this.

More hard drives can be added in your Amahi HDA for additional storage space.

We'll detail how to add such hard drives, and how to put them to good use.

Important Notes

  • This is a how-to on adding additional drives to your HDA.
  • Amahi cannot be held responsible for any data breakage or destruction arising from the use or misuse of this script. We provide it as a service in good will. You accept this automatically if you use the script.
  • This page and script does not support GUID-partitioned drives (such as drives previously in a Mac or have GPT partition tables). You can find what your partition is like with fdisk -l

Make sure your drive is detected by Fedora

Open a Terminal, and type the following command:

ls -1 /dev/disk/by-id/ | egrep -v "part|scsi"

Look for the line that matches the hard drive you added.

IDE and SATA hard drives will start with ata- and USB hard drives will start with usb-.
Look for your hard drive model and serial number.

Example:

[gb@hda ~]$ ls -1 /dev/disk/by-id/ | egrep -v "part|scsi"
ata-Hitachi_HDS722020ALA330_JK1131YAGDU37V
ata-ST31000528AS_6VP08W65
ata-ST3750640A_3QD0LJN8
ata-ST3750640A_5QD27A57
ata-WDC_WD10EADS-00L5B1_WD-WCAU4C700358
usb-ST310003_33AS_9E1CA6FFFFFF-0:0
usb-ST375064_0A_2009031309E2-0:0

Install prerequisites

In a Terminal, as root, type the following (two) commands:

  • Fedora
yum -y install pmount fuse fuse-libs ntfs-3g gparted util-linux-ng
  • Ubuntu
sudo apt-get -y install gparted

Drives must be formatted as MBR not GUID/GPT for hda-diskmount to recognize the disk.

Partition and format the hard drive

This step is optional, and should only be executed if you want to delete the content of your new hard drive, or if the hard drive has not yet been formatted.

You should (unless you have a good reason not to) use GParted to partition and format your hard drive.
Not having X installed would qualify as a good reason! In such cases, either use SSH X11 Forwarding (Google that if you'd like to use this), or use cfdisk from a Terminal, as root.

You'll probably want to create a single partition, and format it as ext3.
Note that Windows can't read ext3 partitions, so if you want dual-boot Windows on your Amahi PC, or if you intend to connect this hard drive to a Windows computer later, you should format as NTFS instead, and you should do that on Windows before you connect the drive in your HDA.
Remember that using NTFS partitions on Linux will be slower that using ext3 partitions, so you should only use NTFS if you really need it.
How much slower: compare the blue bars (NTFS-3G) with the red bars (ext3) on this graph.

To know what device (/dev/sdX) you need to partition and format, use the following command, in a Terminal, as root:

ls -l /dev/disk/by-id/

Find the row corresponding to your hard drive, and look at the end of the line to identify the correct device to use.

Example:

[gb@hda ~]$ ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root  9 2010-02-18 03:24  ata-Hitachi_HDS722020ALA330_JK1131YAGDU37V -> ../../sda
lrwxrwxrwx 1 root root 10 2010-02-18 03:24 ata-Hitachi_HDS722020ALA330_JK1131YAGDU37V-part1 -> ../../sda1
lrwxrwxrwx 1 root root  9 2010-02-18 03:24 ata-ST31000528AS_6VP08W65 -> ../../sdb

In the above example, /dev/sdb would be what I would select in GParted (or use on the cfdisk command). sda in my primary hard drive, and sdb my second hard drive.

Using GParted

From the HDA desktop (or using VNC), Open Terminal as root and type gparted to launch the GParted application.

Select the device (/dev/sdX) that you found above.

In the above example, /dev/sdb would be what I would select in GParted.

There are many easy to follow guides online on how to use GParted. You should Google for one, to find one that seems clear to you.

Here's one that looks simple. Just use ext3 instead of fat32 in you follow that tutorial.

Note that gparted supports GUID-partitioned drives, however, these directions and script do not support it at the moment.

Using cfdisk

From a terminal, as root, type cfdisk /dev/sdX to launch the cfdisk application.

If you have a GUID-partitioned drive, cfdisk will complain. GUID partitions are not supported.

Make sure to replace /dev/sdX with the actual device (eg. /dev/sdb) that you found above.

If your hard drive contains existing partitions, select them one by one at the top (using up/down arrow keys), then select the [ Delete ] action (using the left/right arrow keys), then hit ENTER.

You should now only have Free Space listed at the top.
Select the [ New ] action, and accept the default (Primary, and size).

You should now have a single partition listed at the top, of type Linux.
Select the [ Write ] action, then [ Quit ].

Now that you partitioned your drive, you need to format your newly created partition.
To format as EXT3, use this command:

mkfs.ext3 -j /dev/sdX1

Replace ext3 with ext4 in the above command to format your partition as EXT4 instead of EXT3.

/dev/sdX1 in the above command refers to the partition your created in cfdisk.
Go back in cfdisk, and check the Name column if you're unsure.
If you see sdb1 in the name column, you should use /dev/sdb1 in the above command.

Partition over 2.1TB

Here is a work around for drives with partitions over 2.1TB like the new 3TB drives.

Page: Partitions_Over_2.1_TB

Mount the hard drive

A script is provided with Amahi that will look for unmounted partitions in your system, and mount any it finds.

In a Terminal, as root, type the following command:

hda-diskmount

Example:

[root@hda ~]$ hda-diskmount
****************************************************************
Ignoring /dev/sda1 - already in /etc/fstab or mounted
****************************************************************
Mounted /dev/sdb1 as '/var/hda/files/drives/sdb1' (read-write)
You may want your system to mount it every time you boot.
To do so, add this line VERY CAREFULLY to /etc/fstab and reboot:
UUID=9d972abc-1639-44df-a60e-668618d40236 /var/hda/files/drives/sdb1 ext4 defaults 1 2
****************************************************************
All Linux, Windows and Mac partitions on non-removable disks have been mounted

Do not edit /etc/fstab just yet. What you'll need to add there will depend on how you want to use the extra storage. More about that below.
Just note down the information in bold (green, red and blue). We'll use them below.

Note about ext4 in the blue line above: that doesn't necessarily mean your partition is formatted as ext4. It means the ext4 driver will be used to mount your partition. Since that driver is backward compatible, it can be safely used to mount ext2, ext3 and ext4 partitions.

If you get something like Disk /dev/dm-0 doesn't contain a valid partition table or mount: unknown file system type 'lvm2pv' its because you have LVM's that 'fdisk' can not recognize (or something similar). It's nothing to worry about if you get that when executing the hda-diskmount script.

Test your hard drive

Optionally, you can test your new drive for bad blocks.
Note that this step can take a long time to complete! You'll probably want to start it in the evening, to have it completed in the morning.

To do so, in a Terminal, as root, type the following command. Replace sdb1 with the (green) value you received from hda-diskmount.

e2fsck -cn /dev/sdb1

You'll receive a warning that says "WARNING!!! Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage. Do you really want to continue (y/n)?"
Answer yes. The -cn option we're using can safely be used on mounted filesystems.

Use the hard drive

You have a choice here on how to use your new hard drive storage space. We'll offer some examples.

Use the hard drive for all shares

If you want all your shares to be on your new hard drive, here's how to do that.

First, you'll want to move all you previous shares data, if any, into your new drive.
You only need to do this next command if you have data that you care about in the /var/hda/files/* folders.
In a Terminal, as root, type the following command. Replace the path in red with the path you received when you ran hda-diskmount.

mv /var/hda/files/* /var/hda/files/drives/sdb1/

You'll get a warning about "cannot move `/var/hda/files/drives' to a subdirectory of itself"; that is fine, ignore that.

Next, you'll need to unmount your new hard drive, and remount it as /var/hda/files

umount /var/hda/files/drives/sdb1/
nano /etc/fstab

In nano, you'll need to add a new line at the bottom. Take the line that hda-diskmount gave you (the blue one), and change the second value (the path).
Replace the second value with /var/hda/files.

hda-diskmount gave me:

UUID=9d972abc-1639-44df-a60e-668618d40236 /var/hda/files/drives/sdb1 ext4 defaults 1 2

So I should add this instead:

UUID=9d972abc-1639-44df-a60e-668618d40236 /var/hda/files ext4 defaults 1 2

Make sure you do not change anything else from the blue line you received from hda-diskmount.
It might not be the same thing as the above example; you need to use the values you've received.

Save and exit nano (CTRL-X, Y, ENTER), and try your new mount:

mount -a
ls /var/hda/files/

That last command should show you the content of you new hard drive.

That's it. All your shares in /var/hda/files are now on your new hard drive.

Use the hard drive for only some shares

If you want only some of your shares to be on your new hard drive, here's how to do that.

First, you'll want to move your previous shares data, if any, into your new drive.
You only need to do this next command if you have data that you care about in the /var/hda/files/* folders (that you want on the new drive).
In a Terminal, as root, type the following command. Replace the path in red with the path you received when you ran hda-diskmount. Replace something with the name of the share you want to have on your new drive (the share should already exist).

mv /var/hda/files/something /var/hda/files/drives/sdb1/

Repeat with every share you want on your new drive.

Next, you'll need to make the mount permanent

umount /var/hda/files/drives/sdb1
nano /etc/fstab

In nano, you'll need to add a new line at the bottom. Take the line that hda-diskmount gave you, and insert that.

So, following previous examples, I should add this:

UUID=9d972abc-1639-44df-a60e-668618d40236 /var/hda/files/drives/sdb1 ext4 defaults 1 2

Save and exit nano (CTRL-X, Y, ENTER), and try your new mount:

mount -a
ls /var/hda/files/drives/sdb1

That last command should show you the content of you new hard drive.

Now, you need to update the location of the moved shares within Amahi. Go to your Amahi Dashboard, click on 'Setup', then 'Shares'.

Click on one of the shares that you have moved. This will open a panel revealing the share settings. Click on the location (the bit that is shown with a dotted underline) and it will change to an edit box. Update the location to match the new share location.

For example, the original movies location was: /var/hda/files/movies
The new location might be: /var/hda/files/drives/sdb1/movies

Repeat for any other shares that you have moved. Check that you can access these shares from another machine within your network.

Finally, if you have any services that depend on the location of these shares, make sure they are configured to use the new share location. For example, if you have a DLNA server installed, check its configuration files to make sure that it can find any media folders that have been moved. Secondly, check that all such services start correctly and behave as expected. If the service doesn't start, it may be that it is testing for a specific location during the service startup. Check the startup files in /etc/init.d to see if this is the case.

That's it. Your share(s) are now on your new hard drive.

Use the hard drive in your Greyhole storage pool

If you want to add your new hard drive to your Greyhole storage pool, here's how to do that.

First, you'll need to make the mount permanent. In a Terminal, as root, type the following command:

umount /var/hda/files/drives/sdb1
nano /etc/fstab

In nano, you'll need to add a new line at the bottom. Take the line that hda-diskmount gave you, and insert that.

So, following previous examples, I should add this:

UUID=9d972abc-1639-44df-a60e-668618d40236 /var/hda/files/drives/sdb1 ext4 defaults 1 2

Save and exit nano (CTRL-X, Y, ENTER), and try your new mount:

mount -a

Finally, you'll need to configure Greyhole to select your new partition. To configure Greyhole, Advanced Settings must be enabled under Setup > Settings.

In the Shares > Storage Pool page of your Amahi dashboard, you'll see a list of mounted partitions, with checkboxes next to each, allowing you to include those partitions in your storage pool.

You should now have a new row in there, referring to /var/hda/files/drives/sdb1.

Select it (click the checkbox).

That's it. Your new hard drive just increased your Greyhole storage pool capacity.