User Tools

Site Tools


identify_and_mount_a_drive

This is an old revision of the document!


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.

If you are connected to the RasPi with a terminal window or via ssh use fdisk to view and recreate the partitions. (make sure you are root, su - root or sudo -s)

  sudo fdisk /dev/sda


  while in fdisk you can verify the partitions with the the p command
  Disk /dev/sda: xxx GB, xxx bytes


Use the d command to delete existing partition, then p again to verify it is gone

use the n command creates a new partition, use p for primary partition, Enter to default to partition 1, Enter to select first sector and Enter again to select last sector. This gives the whole disk to your new partition.

now use the p command again to see your new partition

Command (m for help): p Device Boot Start End Blocks Id System /dev/sda1 2048 234441647 117219800 83 Linux 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 “mydisk”

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 /diskname/test was the file created or did you get an err?

identify_and_mount_a_drive.1469735809.txt.gz · Last modified: 2023/03/09 22:35 (external edit)