Adding a second hard drive to your HDA

From Amahi Wiki
Revision as of 12:32, 13 May 2010 by Gboudreau (talk | contribs)
Jump to: navigation, search

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 an advanced how-to on how to add 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.

Step by step instructions

Make sure your drive is detected by the BIOS

It should be listed in the drives that appear when you boot your computer, before the Fedora boot screen appears. You can also enter you BIOS and confirm they appear there.

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 match 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:

yum -y install pmount fuse fuse-libs ntfs-3g gparted

wget -q -O /usr/sbin/hda-diskmount2 http://dl.dropbox.com/u/3022105/Amahi/hda-diskmount2 && chmod +x /usr/sbin/hda-diskmount2

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.
From the HDA desktop (or using VNC), Open Terminal as root and type gparted to launch the GParted application.

To know what device (/dev/sdX) you need to select in GParted, use the following command, in a Terminal:

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 select in GParted.

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. sda in my primary hard drive, and sdb my second hard drive.

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 to read your disk on Windows, you should format as NTFS instea, 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.
Be sure to read the last section about NTFS on this page if you use a NTFS partition!

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.

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-diskmount2

Example:

[root@hda ~]$ hda-diskmount2
****************************************************************
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.

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-diskmount2 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-diskmount2.

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-diskmount2.

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-diskmount2 gave you (the blue one), and change the second value (the path).
Replace the second value with /var/hda/files.

hda-diskmount2 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-diskmount2.
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-diskmount2. Replace something with the name of the share you want to have on your new drive (the share should already exists).

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-diskmount2 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.

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-diskmount2 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.

In the <a href="http://hda/setup?sub=disk_pooling&tab=share" target="_blank">Shares > Storage Pool page</a>, 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.


If you need to remove a disk please go to How to Remove a Drive from LVM