Adding a second hard drive to your HDA

From Amahi Wiki
Revision as of 00:18, 8 March 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 command:

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

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.

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.
<a href="http://www.mepisguides.com/Mepis-6/Install/gparted/gparted-set-partition.html">Here's one</a> 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-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:
/dev/sdb1 /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-diskmount script.

Get your partition UUID

Each partition in Linux can be identified with a unique identifier. This identifier, the UUID, is what you'll want to use to permanently mount your new partition.

To get the UUID of your new partition, execute this command in a Terminal. Replace sdb1 with the (green) value you received from hda-diskmount.

ls -l /dev/disk/by-uuid/ | grep sdb1

Example:

[gb@hda ~]$ ls -l /dev/disk/by-uuid/ | grep sdb1
lrwxrwxrwx 1 root root 10 2010-02-18 03:24 9d972abc-1639-44df-a60e-668618d40236 -> ../../sdb1

In the example above, my UUID is 9d972abc-1639-44df-a60e-668618d40236. Note that down.

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 need to move all you shares data into your 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.

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 first two values.
Instead of /dev/sdb1, enter UUID= followed by the UUID you found earlier.
Replace the second value with /var/hda/files.

hda-diskmount gave me:

/dev/sdb1 /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; oyu need to use the values you've received.

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

mount -a

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 need to move your shares data, if any, into your 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 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-diskmount gave you (the blue one), and change the first value only.
Instead of /dev/sdb1, enter UUID= followed by the UUID you found earlier.

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 add it as-is:

hda-diskmount gave me:

/dev/sdb1 /var/hda/files/drives/sdb1 ext4 defaults 1 2

So 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), and try your new mount:

mount -a

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