Adding a second hard drive to your HDA

From Amahi Wiki
Revision as of 07:10, 17 July 2009 by Moredruid (talk | contribs)
Jump to: navigation, search

Quickstart

A secondary hard drive (fat32, ntfs, etc) can be added for additional storage in your Amahi HDA. First thing's first, make sure your drive is connected properly and detected by the bios. You can check this with the following command (run before and after connecting the (USB)disk): root@localhost # dmesg You'll see something along the lines of "USB Mass Storage device found at ..." followed by a line with a /dev/sd<x> device.

  • download the diskmounter script
  • run the following command on the script: root@localhost # chmod 755 Diskmounter.sh
  • run the script: root@localhost # ./Diskmounter.sh
    Answer "yes" to the prompt to make the drive world writable.
  • install pmount if you get an error: root@localhost # yum -y install pmount
  • try to run the script again: root@localhost # ./Diskmounter.sh
  • reboot
  • check your /etc/fstab how the disk is mounted: root@localhost # cat /etc/fstab (it will usually be the last line that's added). Edit it to where you want to mount it.

Complete walkthrough

It can be configured to mount permanently using the diskmounter script (thanks to Dennis Kaarsemaker and Luigi Capriotti).

  • Execute the script as root and answer YES to the prompt to make the drive writable to all users.
  • Once complete, reboot and the secondary drive should automatically mount.
  • As user root, edit /etc/fstab to change location of shared //hda folders to the secondary drive.
  • To run the diskmounter script, in the directory where the file is located, do the following:

./Diskmounter.sh

This is what the script added for my drive:

Added by diskmounter utility
/dev/sdb1 /var/hda/files vfat rw,user,fmask=0111,dmask=0000 0 0 

I changed second path to /var/hda/files to enable all shared files to be stored on the secondary hard drive. This is the default path for //hda file storage system.

If you get the following error "bash: ./Diskmounter.sh: Permission denied" try executing the following without the commas:

$ chmod 755 Diskmounter.sh 

After executing that command you should be able to execute the Diskmounter.sh script.

If you get "./Diskmounter.sh: line 48: pmount: command not found" try running the following without the commas:

$ yum -y install pmount

Then try again executing the Diskmounter.sh script.

If you get something similar 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 like that) its nothing to worry about if you get that when executed the Diskmounter.sh script.


If the script doesn't work for you

These instructions are adapted from here

If you're planning to mount a NTFS disk, you'll need to make sure you have ntfs-3g, fuse and fuse libs all installed. If not, login as root and run:

$ yum install fuse fuse-libs ntfs-3g

Then use fdisk to find the disk by running fdisk -l (this is a lower case L not a 1). You may have to give the path (/sbin/fdisk) to make it work.

$ /sbin/fdisk -l

This should return the needed information about all your disks. Look out for your newly attached disk. In my case in among the results I can find:

Disk /dev/sdb: 120.0GB 120034123776 bytes 255 heads, 63 sectors/track.... etc etc.

I know my disk is 120GB so that's the right one. This tells us the name of the new disk which is "sdb" in my case. Running

$ sudo /sbin/fdisk -lu /dev/sdb | grep NTFS

..will give you a break down of partitions. In my case, there's just one partition, sdb1, so this is the partition I will mount.

Now we can go on to create the mount points if needs be. But because my disk contains all my music, I want it to be mounted as if it were my local "Music" folder, so for me the mount point already exists. But if just want to access your disk easily you could just as easily mount it anywhere. Commonly mount points are put in either /mnt/ or /media/. It doesn't matter where - just be consistent when you are doing this. To do this run these commands as root:

$ cd /mnt/
$ mkdir my_ntfs_disk

Substituting my_ntfs_disk for whatever you want to call it.

Now we can mount the disk in the desired location. Again as root run this command:

$ mount /dev/sdb1 /mnt/my_ntfs_drive -t ntfs-3g -r -o umask=0222

This command will make the mounted drive read only. That's great if that's what you want, but for me, since I want to save my music there, I need it to be read and writeable. For this you'll use:

$ mount /dev/sdb1 /mnt/my_ntfs_drive -t ntfs-3g -rw -o umask=0000

or in my case

$ mount /dev/sdb1 /home/USERNAME/Music -t ntfs-3g -rw -o umask=0000

because I want it mounted in my "Music" file.

Remember in both of these commands you'll need to substitute sdb1 with whatever the partition name/number is on your machine. And in the second command USERNAME is your linux username.

If you now go to your desktop, you should see the drive is mounted there. Click on it to see the contents are there. If you've mounted it as say So far so good? Ok, let's continue.

What you've achieved so far is a temporary mounting of the drive/partition. That shows it can be done but you'll need to make it permanent otherwise when you reboot it'll disappear again. For this you need to edit fstab with your favourite text editor. As root run:

$ gedit /etc/fstab

A text editor window will pop up. Enter this on the last line:

/dev/sdb1 /mnt/my_ntfs_drive ntfs-3g ro,defaults,umask=0222 0 0

  • change ro to rw and umask=0222 to umask=0000 if you want it to be writable.

You'll need to do this for every partition, so if you have several partitions on sdb, the last lines of you fstab may look something like this

/dev/sdb1 /mnt/my_ntfs_drive_C ntfs-3g ro,defaults,umask=0222 0 0 /dev/sdb2 /mnt/my_ntfs_drive_D ntfs-3g ro,defaults,umask=0222 0 0 /dev/sdb3 /mnt/my_ntfs_drive_E ntfs-3g ro,defaults,umask=0222 0 0

When you reboot, you should find your data where you want it.

Guide to Adding a Hard Drive to Fedora

This is a good guide, for advanced users, to adding a hard drive to Fedora:

http://fedoranews.org/tchung/storage/

And a good fedora 9 guide here, including a section on adding a hard drive here:

http://www.mjmwired.net/resources/mjm-fedora-f9.html