For those who want to use the Raspberry Pi as a mini PC or a mini server, the amount of space available on the SD card used to boot up the RasPi could be too small, and furthermore the risks to maintain all data on the SD Card are too high.
For the above reasons it could be useful adding an external USB drive, it costs less than an SD Card of the same capacity and it can be attached to different PC/RaspPi's.
First step: "The filesystem"
Normally USB HD comes pre-formatted, normally the filesystem chosen to format the HD from the manufacturer is the Fat32, less often (but could be the case) the manufacturer could use the NTFS filesystem.
In the first case you don't have to do anything, Raspbian is already able to handle the Fat32 filesystem, in the second case you have to add the support for the NTFS filesystem, from the terminal issue the following command:
$ sudo apt-get install ntfs-3g
To verify what filesystem is in your HD:
1. Connect your HD to the RasPi USB port
2. Issue the following command:
$ sudo fdisk -l | grep sda Disk /dev/sda: 21.8 GB, 21793882112 bytes /dev/sda1 * 2048 39280639 19639296 b W95 FAT32
if you will read "W95 FAT32" you are in the first case, if you will read "NTFS" you are in the second case.
Second step: "mounting the disk"
In order to access files on the disk Linux needs to mount the HD on a directory, normally I create a directory into the /mnt directory
$ sudo mkdir /mnt/USB_HD
$ sudo chown pi:pi /mnt/USB_HD
and then I mount the disk issuing the following command:
$ sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /mnt/USB_HD
or, if the filesystem is NTFS
$ sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sda1 /mnt/USB_HD
Third Step: Automagic
If you are going to use the HD definitively on the RasPi you may want to mount the HD automatically at each boot. To do this, simply issue the following command:
$ sudo echo "/dev/sda1 /mnt/USB_HD vfat uid=pi,gid=pi 0 0" >> /etc/fstab
or if you are using an NTFS formatted HD
$ sudo echo "/dev/sda1 /mnt/USB_HD ntfs-3g uid=pi,gid=pi 0 0" >> /etc/fstab
Now reboot the system and your HD should be automatically mounted.
Gg1
As a matter of power consumption, are you running an externally powered HDD or would you reccommend a SSD?
If the drive you are mounting is encrypted via filevault or another encryption method, will raspbian prompt for the password?