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 21:34] – walkeradmin | identify_and_mount_a_drive [2023/03/09 22:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Identify and Mount a Drive ====== | ====== Identify and Mount a Drive ====== | ||
\\ | \\ | ||
- | \\ | ||
- | First we need to identify the disk(s): | ||
\\ | \\ | ||
+ | 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. / | ||
\\ | \\ | ||
- | sudo blkid | ||
\\ | \\ | ||
- | This will list any recognised devices: | + | Prepare the Mount Point |
+ | |||
+ | First make a directory in which to mount the USB drive | ||
+ | sudo mkdir / | ||
\\ | \\ | ||
+ | Make pi the owner of the mounted drive and make its permissions read, write and execute for it | ||
+ | | ||
+ | sudo chown -R pi:pi / | ||
+ | sudo chmod -R 775 / | ||
+ | \\ | ||
+ | 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 15: | 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 |
- | p - To display the new partition | + | |
| | ||
- | | + | |
- | /dev/ | + | |
- | \\ | + | |
- | The changes need to be written to the partition table: | + | |
\\ | \\ | ||
- | | + | |
| | ||
- | | + | |
- | Calling ioctl() to re-read partition table. | + | |
- | Syncing disks. | + | |
\\ | \\ | ||
- | Now run the following command | + | 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). | ||
\\ | \\ | ||
- | | + | |
+ | 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. | ||
\\ | \\ | ||
- | There will be a large output, but the important part is at the end: | + | If you have issues here then try replacing uid=pi,gid=pi with just the word defaults (typical for ext4). You can also try replacing |
\\ | \\ | ||
- | | + | |
- | /dev/sda1 2048 625142447 625140400 298.1G 83 Linux | + | /dev/mmcblk0p1 |
- | \\ | + | /dev/mmcblk0p2 / ext4 errors=remount-ro, |
- | /dev/sda1 is the partition we have just created on device /dev/sda | + | |
- | \\ | + | |
- | Now we need to create the file system: | + | |
- | \\ | + | |
- | | + | |
| | ||
- | | + | |
- | | + | \\ |
- | | + | |
| | ||
- | | + | |
+ | / | ||
| | ||
- | | + | UUID=XXXX-XXXX / |
- | Filesystem | + | \\ |
- | Superblock backups stored on blocks: | + | For ext4 using uid and gid is not recommended so use at your own risk as it could cause issues (thanks mk2soldier). |
- | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | + | |
- | | + | |
| | ||
- | | + | |
- | | + | |
- | | + | |
+ | UUID=XXXX-XXXX | ||
\\ | \\ | ||
- | After the superblocks are created and you get a command prompt, Now you are ready to mount your disk. | + | If you get any errors |
+ | |||
+ | / | ||
+ | / | ||
+ | |||
+ | UUID=XXXX-XXXX | ||
\\ | \\ | ||
- | Lets create a mount point and call it NewDisk | + | For using / |
- | \\ | + | |
- | | + | /dev/ |
- | \\ | + | / |
- | To Mount the Disk | + | |
- | \\ | + | / |
- | | + | |
- | \\ | + | |
- | 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) | + | |
\\ | \\ | ||
- | | + | |
| | ||
- | | + | |
- | / | + | |
- | devtmpfs | + | |
- | tmpfs | + | |
- | tmpfs | + | |
- | tmpfs | + | |
- | tmpfs | + | |
- | / | + | |
- | tmpfs 94776 | + | |
- | / | + | |
\\ | \\ | ||
- | Try writing a file to the disk to test it: | + | If you didn’t get errors reboot, otherwise try the suggestions above to get it working then |
- | \\ | + | |
- | | + | |
| | ||
- | | + | |
- | + | \\ | |
- | lost+found | + | |
\\ | \\ | ||
- | |||
- |
identify_and_mount_a_drive.1469738087.txt.gz · Last modified: 2023/03/09 22:35 (external edit)