Difference between revisions of "Adding a second hard drive to your HDA"

From Amahi Wiki
Jump to: navigation, search
Line 215: Line 215:
  
 
Ubuntu:
 
Ubuntu:
{{Code|Code=
+
<div style="border: 1px solid #A3B1BF; padding: .5em 1em; color: #000; background-color: #E6F2FF; margin: 3px 3px 1em 3px;"><pre>
 
gstreet@gstreet-MicroServer:~$ sudo blkid
 
gstreet@gstreet-MicroServer:~$ sudo blkid
 
[sudo] password for gstreet:
 
[sudo] password for gstreet:
Line 225: Line 225:
 
/dev/sde3: LABEL="home" UUID="d0531fa1-9311-4d53-b838-f35898adbd98" TYPE="ext4"  
 
/dev/sde3: LABEL="home" UUID="d0531fa1-9311-4d53-b838-f35898adbd98" TYPE="ext4"  
 
/dev/sde5: LABEL="swap" UUID="3c39206c-ba60-47ff-a1fe-f5821b2ab543" TYPE="swap"
 
/dev/sde5: LABEL="swap" UUID="3c39206c-ba60-47ff-a1fe-f5821b2ab543" TYPE="swap"
}}
+
</pre></div>
  
 
In this case, the user has four data drives (sda1, sdb1, sdc1, sdd1) and the Operating system assigned to a fifth drive, sde.
 
In this case, the user has four data drives (sda1, sdb1, sdc1, sdd1) and the Operating system assigned to a fifth drive, sde.
Line 233: Line 233:
 
2. Then edit /etc/fstab to mount each drive - for novices, easiest to do this using a graphical editor.  You might consider first making a copy called fstab.bak (use the "save as" command, close file and then gedit the original fstab again) so that you can recover the original fstab file if you make mistakes.
 
2. Then edit /etc/fstab to mount each drive - for novices, easiest to do this using a graphical editor.  You might consider first making a copy called fstab.bak (use the "save as" command, close file and then gedit the original fstab again) so that you can recover the original fstab file if you make mistakes.
  
Ubuntu: {{Code|Code=
+
Ubuntu:  
sudo gedit /etc/fstab
+
<div style="border: 1px solid #A3B1BF; padding: .5em 1em; color: #000; background-color: #E6F2FF; margin: 3px 3px 1em 3px;">
}}
+
sudo gedit /etc/fstab
 +
</div>
  
 
3.  Then '''very carefully''' add the following line for each disk into the end of the fstab file.  Make sure you paste in the right UUID, drive number and drive file system (ext4 in this case).  
 
3.  Then '''very carefully''' add the following line for each disk into the end of the fstab file.  Make sure you paste in the right UUID, drive number and drive file system (ext4 in this case).  
Line 267: Line 268:
  
 
Save the file and quit the editor. To see if that will work at boot time, try with:
 
Save the file and quit the editor. To see if that will work at boot time, try with:
 
+
<div style="border: 1px solid #A3B1BF; padding: .5em 1em; color: #000; background-color: #E6F2FF; margin: 3px 3px 1em 3px;">
  mount -a
+
mount -a
 +
</div>
  
 
If that gives you errors, there is a good chance that this line was not added properly and your machine may not reboot and get stuck mounting the drives!
 
If that gives you errors, there is a good chance that this line was not added properly and your machine may not reboot and get stuck mounting the drives!

Revision as of 03:54, 18 December 2013

Warning.png WARNING
This is recommended only for advanced users, proceed with caution.


Adding drives to your HDA is another "how to" 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 the OS

Open a Terminal or remotely connect (ssh, ...) to the OS, 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 a general introduction on YouTube. Just use ext3 or ext4 instead of fat32 in you follow that tutorial.

If you have a drive > 2.0 TB, there is an in-depth guide below (that may be outdated). Instead, it is possible to use GParted with the following steps:

  • select the correct drive in the dropdown on the top right of GParted
  • click Device > Create Partition Table... > Advanced > (Choose 'gpt')
  • then create your partition as normally instructed
    • I use /ext4
    • add an appropriate label


NOTE: 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.

Mount the hard drive

Using hda-diskmount script

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.

If hda-diskmount does not recognize your new drive and you are trying to add a GPT partitioned 2+TB drive, you may need to edit your hda-diskmount script. You can a fix for this issue at this forum thread.

Failure to recognize GPT drive:

[root@hda ~]$ hda-diskmount
****************************************************************
Ignoring /dev/sdf1 - already mounted
Ignoring /dev/sdf1 - already in /etc/fstab as UUID=b8c125e3-4199-4b56-a566-397fdd8bab8a
****************************************************************
No usable Linux, Windows or Mac partitions found on your disks.

Example fix to /usr/sbin/hda-dismount

# Now for the real work
drivesntfs=`fdisk -l 2> /dev/null | grep -i 'ntfs' | awk -F '/| ' '{print $3}'`
drivesfat=`fdisk -l  2> /dev/null | grep -i 'fat32' | awk -F '/| ' '{print $3}'`
driveshfs=`fdisk -l  2> /dev/null | grep -i 'HFS' | awk -F '/| ' '{print $3}'`
drivesext=`fdisk -l  2> /dev/null | egrep -iw 'Linux|GPT' | egrep -v 'swap|LVM' | awk -F '/| ' '{print $3}'`

If you have changed the order of your installed hard drives, hda-diskmount may return the following message:

Ignoring /dev/sda1 - already in /etc/fstab as /dev/sda1 This device appears to be commented out of your /etc/fstab. You will need to remove it from there for hda-diskmount to be able to mount it.

This might occur if you have made changes to the drive configuration order after you installed Amahi. If you want to stay with the reconfigured drive order, instructions on how to fix this are in the next section, Manually setting up the disk mount order.

Manually setting up the disk mount order

1. First, get the UUID for each drive by opening a terminal and entering command

Ubuntu:

gstreet@gstreet-MicroServer:~$ sudo blkid
[sudo] password for gstreet:
/dev/sda1: LABEL="Seagate-Alpha2TB" UUID="55d9333f-d801-425a-b2af-d65c5966d56f" TYPE="ext4" 
/dev/sdb1: LABEL="Seagate-Beta2TB" UUID="5bd5498f-30c1-4780-948e-ca46656507d2" TYPE="ext4" 
/dev/sdc1: LABEL="WD-Charlie2TB" UUID="a7337504-376a-4d36-9f7a-1a24c0f55fbd" TYPE="ext4" 
/dev/sdd1: LABEL="WD-Delta2TB" UUID="8d881dcb-8de3-4621-b9bd-00025196868a" TYPE="ext4" 
/dev/sde1: LABEL="root" UUID="4d6f8004-d190-4234-a03b-b68de988abf0" TYPE="ext4" 
/dev/sde3: LABEL="home" UUID="d0531fa1-9311-4d53-b838-f35898adbd98" TYPE="ext4" 
/dev/sde5: LABEL="swap" UUID="3c39206c-ba60-47ff-a1fe-f5821b2ab543" TYPE="swap"

In this case, the user has four data drives (sda1, sdb1, sdc1, sdd1) and the Operating system assigned to a fifth drive, sde.

Take note of the UUID's for each drive. Easiest to cut and paste UUID's straight from the terminal - no typo's!

2. Then edit /etc/fstab to mount each drive - for novices, easiest to do this using a graphical editor. You might consider first making a copy called fstab.bak (use the "save as" command, close file and then gedit the original fstab again) so that you can recover the original fstab file if you make mistakes.

Ubuntu:

sudo gedit /etc/fstab

3. Then very carefully add the following line for each disk into the end of the fstab file. Make sure you paste in the right UUID, drive number and drive file system (ext4 in this case).

UUID=55d9333f-d801-425a-b2af-d65c5966d56f /var/hda/files/drives/drive1 ext4 defaults 1 2

It should look something like the following when lines are added for each of the five drives in this example. Note lines beginning with # are comments where the remainder of the line is ignored)

#  Mounting Greyhole Drives for Drive Pool.  
#
# Drive1 = Seagate-Alpha2TB in Microserver Bay 1 from left 
UUID=55d9333f-d801-425a-b2af-d65c5966d56f /var/hda/files/drives/drive1 ext4 defaults 1 2
#
# Drive2 = Seagate-Beta2TB in Microserver Bay 2 from left 
UUID=5bd5498f-30c1-4780-948e-ca46656507d2 /var/hda/files/drives/drive2 ext4 defaults 1 2
#
# Drive3 = WD-Charlie2TB in Microserver Bay 3 from left 
UUID=a7337504-376a-4d36-9f7a-1a24c0f55fbd /var/hda/files/drives/drive3 ext4 defaults 1 2
#
# Drive4 = WD-Delta2TB in Microserver Bay 4 from left 
UUID=8d881dcb-8de3-4621-b9bd-00025196868a /var/hda/files/drives/drive4 ext4 defaults 1 2
#
# Drive5 = 250GB OS Drive mounted in Optical Drive bay
UUID="4d6f8004-d190-4234-a03b-b68de988abf0 /var/hda/files/drives/drive5 ext4 defaults 1 2
#
#

Save the file and quit the editor. To see if that will work at boot time, try with:

mount -a

If that gives you errors, there is a good chance that this line was not added properly and your machine may not reboot and get stuck mounting the drives!

Note that the hda-diskmount command had already added lines to mount my OS drive which had two partitions (root or /, and home). Save file and close.

4) Save file and reboot machine.

5) Check that drives have successfully mounted in Amahi hda (Setup - Shares - Storage Pool)

In this case, if all drives mounted successfully, it should look like:

caption

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.