Identify and Mount a Drive

THIS SECTION IS NOT FINISHED

first we need to identify the disk(s):

sudo blkid

This will list any recognised devices:

/dev/mmcblk0p1: LABEL="RECOVERY" UUID="0403-0201" TYPE="vfat" PARTUUID="0006dd3f-01"
/dev/mmcblk0p5: LABEL="SETTINGS" UUID="705f6e2b-fac6-4f33-8611-d57a9c9f04e1" TYPE="ext4" PARTUUID="0006dd3f-05"
/dev/mmcblk0p6: SEC_TYPE="msdos" LABEL="boot" UUID="1495-189B" TYPE="vfat" PARTUUID="0006dd3f-06"
/dev/mmcblk0p7: LABEL="root0" UUID="759bca6b-5766-4941-b830-cdbfcd861107" TYPE="ext4" PARTUUID="0006dd3f-07"
/dev/mmcblk0p8: LABEL="boot-rbp2" UUID="200C-EA5B" TYPE="vfat" PARTUUID="0006dd3f-08"
/dev/mmcblk0p9: LABEL="root-rbp2" UUID="26d10fa3-fe0a-4044-b24a-9b85c2079122" TYPE="ext4" PARTUUID="0006dd3f-09"
/dev/mmcblk0: PTUUID="0006dd3f" PTTYPE="dos"
/dev/sda: PTUUID="279bf5b4" PTTYPE="dos"

In this example, the first 6 items are the SD card that Raspbian booted from /dev/mmcblk0px. The last device /dev/sda is a USB Hard Disk. This is the disk I want to add to Raspbian.
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/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.

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 Boot Start End Sectors Size Id Type
/dev/sda1 2048 625142447 625140400 298.1G 83 Linux

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 Boot Start End Sectors Size Id Type
/dev/sda1 2048 625142447 625140400 298.1G 83 Linux

/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 '300gb'
Proceed anyway? (y,n) <---------------------------------You have to say 'Y' Here.
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: done

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 /mydisk <-- This creates a mount point (a folder) to mount our disk, the folder is called mydisk

To Mount the Disk

sudo mount /dev/sda1 /NewDisk <--- bear in mind that your disk might not be 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 1K-blocks Used Available Use% Mounted on
/dev/root 7928236 3577848 3924612 48% /
devtmpfs 469544 0 469544 0% /dev
tmpfs 473880 0 473880 0% /dev/shm
tmpfs 473880 6520 467360 2% /run
tmpfs 5120 4 5116 1% /run/lock
tmpfs 473880 0 473880 0% /sys/fs/cgroup
/dev/mmcblk0p6 64366 20436 43930 32% /boot
tmpfs 94776 0 94776 0% /run/user/1000
/dev/sda1 307665360 64344 291972508 1% /NewDisk <---- here is our new disk

Try writing a file to the disk to test it:

sudo touch /NewDisk/test
ls /NewDsik
lost+found test