identify_and_mount_a_drive
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| identify_and_mount_a_drive [2016/07/28 20:07] – walkeradmin | identify_and_mount_a_drive [2017/01/08 21:47] (current) – walkeradmin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Identify and Mount a Drive ====== | ====== Identify and Mount a Drive ====== | ||
| \\ | \\ | ||
| - | \\ | ||
| - | ===== THIS SECTION IS NOT FINISHED ===== | ||
| \\ | \\ | ||
| + | This guide assumes you only have 1 external hard drive connected to the Pi. If so then it should be attached to /dev/sda1 – additional drives will use /dev/sdb1 and /dev/sdc1 etc. If you have multiple external hard drives you will need separate mount points for each drive (e.g. / | ||
| \\ | \\ | ||
| - | |||
| - | first we need to identify the disk(s): | ||
| \\ | \\ | ||
| + | Prepare the Mount Point | ||
| + | | ||
| + | First make a directory in which to mount the USB drive | ||
| + | sudo mkdir / | ||
| \\ | \\ | ||
| - | sudo blkid | + | |
| + | |||
| + | | ||
| + | sudo chmod -R 775 / | ||
| \\ | \\ | ||
| - | This will list any recognised devices: | + | Set all future permissions for the mount point to pi user and group. |
| + | |||
| + | sudo setfacl -Rdm g:pi:rwx / | ||
| + | sudo setfacl -Rm g:pi:rwx / | ||
| \\ | \\ | ||
| + | Determine the USB Hard Drive Format | ||
| + | |||
| + | You also need to know the file system the drive is formatted with | ||
| + | |||
| + | sudo blkid | ||
| + | \\ | ||
| + | You will see something like this. Again it is the sda1 line we are interested in. Note the TYPE=" | ||
| + | | ||
| + | /dev/sda1: UUID=" | ||
| + | / | ||
| / | / | ||
| / | / | ||
| Line 19: | Line 36: | ||
| / | / | ||
| / | / | ||
| - | / | ||
| - | /dev/sda: PTUUID=" | ||
| \\ | \\ | ||
| - | In this example, the first 6 items are the SD card that Raspbian booted from **/ | + | Update your repositories if your hard drive is anything but ext4 as the TYPE above |
| + | |||
| + | sudo apt-get update | ||
| \\ | \\ | ||
| - | Now that we know the disk we wish to work on is /dev/sda we can use: | + | |
| + | |||
| + | sudo apt-get install ntfs-3g -y | ||
| \\ | \\ | ||
| - | sudo fdisk /dev/sda | + | |
| + | |||
| + | | ||
| \\ | \\ | ||
| - | | + | |
| | | ||
| - | | + | |
| - | Units: sectors of 1 * 512 = 512 bytes | + | |
| - | Sector size (logical/physical): 512 bytes / 512 bytes | + | |
| - | I/O size (minimum/optimal): 512 bytes / 512 bytes | + | |
| - | Disklabel type: dos | + | |
| - | Disk identifier: 0x279bf5b4 | + | |
| \\ | \\ | ||
| - | We can see the size is 298.1 GB. | + | If you get an error use this syntax |
| + | |||
| + | sudo mount -t uid=pi, | ||
| \\ | \\ | ||
| - | | + | |
| | | ||
| - | | + | |
| - | Could not delete partition 81165 | + | |
| \\ | \\ | ||
| - | In this case, there are no partitions | + | If you are getting |
| + | |||
| + | Remove the automounting software with this command | ||
| + | |||
| + | sudo apt-get remove usbmount --purge | ||
| \\ | \\ | ||
| - | To create a new partition, use: | + | Automount the USB Hard Drive on Boot |
| - | + | ||
| - | | + | |
| - | | + | sudo ls -l / |
| - | | + | |
| - | Enter - To select first sector | + | |
| - | Enter - To select last sector. | + | |
| \\ | \\ | ||
| - | You should now have a new partition. | + | |
| + | total 0 | ||
| + | |||
| + | lrwxrwxrwx 1 root root 15 Jan 1 1970 3d81d9e2-7d1b-4015-8c2c-29ec0875f762 -> ../ | ||
| + | lrwxrwxrwx 1 root root 15 Jan 1 1970 787C-2FD4 -> ../ | ||
| + | lrwxrwxrwx 1 root root 10 Oct 26 21:10 BA8F-FFE8 -> ../../sda1 | ||
| \\ | \\ | ||
| - | | + | |
| + | |||
| + | sudo nano / | ||
| + | \\ | ||
| + | Add the line in red to the bottom, replace XXXX-XXXX with your UUID and exfat with your type if it is | ||
| + | different (e.g. ntfs, vfat, ext4). You may or may not need the quotation marks wrapped around the UID, you do | ||
| + | not need quotation marks wrapped around the file system type (ext4, vfat, NTFS etc). | ||
| + | \\ | ||
| + | The umask 0002 sets 775 permissions so the pi user and group can read, write and execute files | ||
| + | on the external USB drive. To completely eliminate permission issues you can set the umask to 0000 | ||
| + | which equals 777 permissions so anybody can read, write and execute. Note that 777 permissions are | ||
| + | considered a security risk. | ||
| + | \\ | ||
| + | If you have issues here then try replacing uid=pi, | ||
| + | \\ | ||
| + | This is an example for exfat | ||
| + | / | ||
| + | / | ||
| + | |||
| + | UUID=XXXX-XXXX | ||
| + | \\ | ||
| + | For NTFS, note that it is ntfs and not ntfs-3g | ||
| + | |||
| + | / | ||
| + | / | ||
| + | |||
| + | UUID=XXXX-XXXX | ||
| + | \\ | ||
| + | For ext4 using uid and gid is not recommended so use at your own risk as it could cause issues (thanks mk2soldier). | ||
| + | |||
| + | / | ||
| + | / | ||
| + | |||
| + | UUID=XXXX-XXXX | ||
| + | \\ | ||
| + | If you get any errors you can replace uid=pi, | ||
| + | |||
| + | / | ||
| + | / | ||
| + | |||
| + | UUID=XXXX-XXXX | ||
| + | \\ | ||
| + | For using /dev/sda1 and defaults if you have troubles with UUID | ||
| + | |||
| + | / | ||
| + | / | ||
| + | |||
| + | / | ||
| + | \\ | ||
| + | Now test the fstab file works | ||
| + | |||
| + | sudo mount -a | ||
| + | \\ | ||
| + | If you didn’t get errors reboot, otherwise try the suggestions above to get it working then | ||
| + | mount -a again until it succeeds | ||
| + | |||
| + | sudo reboot | ||
| \\ | \\ | ||
| - | Device | ||
| - | / | ||
| \\ | \\ | ||
| - | |||
| - | |||
| - | |||
| - | Command (m for help): p | ||
| - | Device Boot Start | ||
| - | / | ||
| - | the changes need to be written to the partition table, so use the w command to commit. | ||
| - | |||
| - | run the fdisk -l command to see your disk which will now include /dev/sda1 | ||
| - | |||
| - | Now you can make your file system. Use the mkfs command. | ||
| - | |||
| - | mkfs /dev/sda1 | ||
| - | after the superblocks are created and you get a prompt you are ready to mount your disk create a mount point, say you want it to be " | ||
| - | |||
| - | mkdir /mydisk | ||
| - | now mount it | ||
| - | |||
| - | mount /dev/sda1 /mydisk | ||
| - | use df to verify disk is mounted. If you reboot you will need to remount it (you might want to add it to /etc/fstab) | ||
| - | |||
| - | try writing a file to the disk | ||
| - | |||
| - | touch / | ||
| - | was the file created or did you get an err? | ||
identify_and_mount_a_drive.1469736429.txt.gz · Last modified: (external edit)
