Difference between revisions of "Adding a second hard drive to your HDA"
Line 13: | Line 13: | ||
Open a Terminal, and type the following command: | Open a Terminal, and type the following command: | ||
− | <div style="border: 1px solid #A3B1BF; padding: .5em | + | <div style="border: 1px solid #A3B1BF; padding: .5em .5em; background-color: #E6F2FF; margin: 0 4em;"> |
ls -1 /dev/disk/by-id/ | egrep -v "part|scsi" | ls -1 /dev/disk/by-id/ | egrep -v "part|scsi" | ||
</div> | </div> |
Revision as of 23:19, 2 October 2010
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.
Contents
Important Notes
- This is an 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.
- This page and script does not support GUID-partitioned drives. 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 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 util-linux-ng
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.
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.
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.
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 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, 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-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.