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/29 17:01] – walkeradmin | identify_and_mount_a_drive [2023/03/09 22:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 23: | Line 23: | ||
You also need to know the file system the drive is formatted with | You also need to know the file system the drive is formatted with | ||
+ | |||
sudo blkid | sudo blkid | ||
\\ | \\ | ||
Line 67: | Line 68: | ||
\\ | \\ | ||
Automount the USB Hard Drive on Boot | Automount the USB Hard Drive on Boot | ||
+ | | ||
/ | / | ||
sudo ls -l / | sudo ls -l / | ||
Line 73: | Line 74: | ||
You will see some output like this. The UUID you want is formatted like this XXXX-XXXX for the sda1 drive. If the drive is NTFS it can have a longer format like UUID=" | You will see some output like this. The UUID you want is formatted like this XXXX-XXXX for the sda1 drive. If the drive is NTFS it can have a longer format like UUID=" | ||
total 0 | total 0 | ||
+ | | ||
lrwxrwxrwx 1 root root 15 Jan 1 1970 3d81d9e2-7d1b-4015-8c2c-29ec0875f762 -> ../ | 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 15 Jan 1 1970 787C-2FD4 -> ../ | ||
Line 82: | Line 83: | ||
sudo nano /etc/fstab | sudo nano /etc/fstab | ||
\\ | \\ | ||
- | 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). | + | Add the line in red to the bottom, replace XXXX-XXXX with your UUID and exfat with your type if it is |
+ | | ||
+ | | ||
\\ | \\ | ||
- | 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. | + | The umask 0002 sets 775 permissions so the pi user and group can read, write and execute files |
+ | | ||
+ | | ||
+ | | ||
\\ | \\ | ||
If you have issues here then try replacing uid=pi, | If you have issues here then try replacing uid=pi, | ||
Line 126: | Line 132: | ||
sudo mount -a | 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 | + | If you didn’t get errors reboot, otherwise try the suggestions above to get it working then |
+ | | ||
| | ||
sudo reboot | sudo reboot | ||
\\ | \\ | ||
\\ | \\ | ||
- | |||
- | |||
- | |||
- | You should be able to access the mounted USB drive and list its contents | ||
- | cd / | ||
- | ls | ||
- | |||
- | Every time you reboot, the drives will be mounted as long as the UUID remains the same. If you delete the partitions or format the USB hard drive or stick the UUID changes so bear this in mind. You can always repeat the process for additional hard drives in the future. | ||
- | |||
- | Now you can manage the hard drive power using these guides since it will not spin down automatically on Linux | ||
- | |||
- | If you have multiple hard drives you will have to make separate mount points (e.g. / | ||
- | |||
- | Fix Raspberry Pi 2 Mounting Issues | ||
- | |||
- | Thanks to Jake for bringing this to my attention. Apparently there is a bug in the Pi 2 that messes up automounting. You can fix it by creating a delay. | ||
- | |||
- | Open up the / | ||
- | sudo nano / | ||
- | |||
- | Add this line to the bottom, you can increase this delay if necessary | ||
- | rootdelay=5 | ||
- | |||
- | Hit Ctrl+X, Y and Enter to save and exit, then reboot to see if it automounts now. | ||
- | If the Raspberry Pi hard drive still does not automount we can use rc.local (thanks Julian) | ||
- | sudo nano / | ||
- | |||
- | Add this lines before the exit line | ||
- | sleep 30 | ||
- | sudo mount -a | ||
- | exit | ||
- | |||
- | Ctrl+X, Y and Enter to save | ||
- | |||
- | Reboot again to test | ||
- | sudo reboot | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ====== Identify and Mount a Drive ====== | ||
- | \\ | ||
- | \\ | ||
- | First we need to identify the disk(s): | ||
- | \\ | ||
- | \\ | ||
- | sudo blkid | ||
- | \\ | ||
- | This will list any recognised devices: | ||
- | \\ | ||
- | / | ||
- | / | ||
- | / | ||
- | / | ||
- | / | ||
- | / | ||
- | / | ||
- | /dev/sda: PTUUID=" | ||
- | \\ | ||
- | In this example, the first 6 items are the SD card that Raspbian booted from **/ | ||
- | \\ | ||
- | \\ | ||
- | Now that we know the disk we wish to work on is /dev/sda we can use: | ||
- | \\ | ||
- | sudo fdisk /dev/sda | ||
- | \\ | ||
- | enter p to display partition information | ||
- | | ||
- | Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors | ||
- | Units: sectors of 1 * 512 = 512 bytes | ||
- | Sector size (logical/ | ||
- | I/O size (minimum/ | ||
- | Disklabel type: dos | ||
- | Disk identifier: 0x279bf5b4 | ||
- | \\ | ||
- | We can see the size is 298.1 GB. | ||
- | \\ | ||
- | Use the d command to delete existing partition | ||
- | | ||
- | No partition is defined yet! | ||
- | Could not delete partition 81165 | ||
- | \\ | ||
- | In this case, there are no partitions to delete | ||
- | \\ | ||
- | To create a new partition, use: | ||
- | |||
- | n - This creates a new partition | ||
- | p - This is for a primary partition | ||
- | Enter - To default to partition 1 | ||
- | Enter - To select first sector | ||
- | Enter - To select last sector. | ||
- | \\ | ||
- | You should now have a new partition. | ||
- | \\ | ||
- | p - To display the new partition | ||
- | | ||
- | Device | ||
- | / | ||
- | \\ | ||
- | The changes need to be written to the partition table: | ||
- | \\ | ||
- | w - To commit changes | ||
- | | ||
- | The partition table has been altered. | ||
- | Calling ioctl() to re-read partition table. | ||
- | Syncing disks. | ||
- | \\ | ||
- | Now run the following command to see your disk, which will now include /dev/sda1 | ||
- | \\ | ||
- | sudo fdisk -l | ||
- | \\ | ||
- | There will be a large output, but the important part is at the end: | ||
- | \\ | ||
- | Device | ||
- | / | ||
- | \\ | ||
- | /dev/sda1 is the partition we have just created on device /dev/sda | ||
- | \\ | ||
- | Now we need to create the file system: | ||
- | \\ | ||
- | sudo mkfs /dev/sda1 | ||
- | | ||
- | mke2fs 1.42.12 (29-Aug-2014) | ||
- | /dev/sda1 contains a ntfs file system labelled ' | ||
- | Proceed anyway? (y,n) < | ||
- | | ||
- | Depending on drive size, this will take a minute or two | ||
- | | ||
- | Creating filesystem with 78142550 4k blocks and 19537920 inodes | ||
- | Filesystem UUID: 6af40af7-759f-4ee5-afea-882e9f58f17e | ||
- | Superblock backups stored on blocks: | ||
- | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | ||
- | 4096000, 7962624, 11239424, 20480000, 23887872, 71663616 | ||
- | | ||
- | Allocating group tables: done | ||
- | Writing inode tables: done | ||
- | Writing superblocks and filesystem accounting information: | ||
- | \\ | ||
- | After the superblocks are created and you get a command prompt, Now you are ready to mount your disk. | ||
- | \\ | ||
- | Lets create a mount point and call it NewDisk | ||
- | \\ | ||
- | sudo mkdir / | ||
- | \\ | ||
- | To Mount the Disk | ||
- | \\ | ||
- | sudo mount /dev/sda1 / | ||
- | \\ | ||
- | 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) | ||
- | \\ | ||
- | df | ||
- | | ||
- | Filesystem | ||
- | / | ||
- | devtmpfs | ||
- | tmpfs | ||
- | tmpfs | ||
- | tmpfs | ||
- | tmpfs | ||
- | / | ||
- | tmpfs 94776 | ||
- | / | ||
- | \\ | ||
- | Try writing a file to the disk to test it: | ||
- | \\ | ||
- | sudo touch / | ||
- | | ||
- | ls /NewDsik | ||
- | | ||
- | lost+found | ||
- | \\ | ||
- | |||
- |
identify_and_mount_a_drive.1469808096.txt.gz · Last modified: 2023/03/09 22:35 (external edit)