User Tools

Site Tools


mount_usb_drive_on_boot

Mount USB Drive on Boot



Having created a partition, formatted it and mounted it, the mounting is temporary and will be lost upon reboot. To mount it at boot we can do the following:

First we need to work out the disk we wish to mount:

  ls -l /dev/disk/by-uuid
  
  (on my system that is the SD card we booted from and a single USB Hard Disk)
  
  total 0
  lrwxrwxrwx 1 root root 15 Jul 28 20:33 0403-0201 -> ../../mmcblk0p1
  lrwxrwxrwx 1 root root 15 Jul 28 20:33 1495-189B -> ../../mmcblk0p6
  lrwxrwxrwx 1 root root 15 Jul 28 20:33 200C-EA5B -> ../../mmcblk0p8
  lrwxrwxrwx 1 root root 15 Jul 28 20:33 26d10fa3-fe0a-4044-b24a-9b85c2079122 -> ../../mmcblk0p9
  lrwxrwxrwx 1 root root 10 Jul 28 20:33 6af40af7-759f-4ee5-afea-882e9f58f17e -> ../../sda1
  lrwxrwxrwx 1 root root 15 Jul 28 20:32 705f6e2b-fac6-4f33-8611-d57a9c9f04e1 -> ../../mmcblk0p5
  lrwxrwxrwx 1 root root 15 Jul 28 20:33 759bca6b-5766-4941-b830-cdbfcd861107 -> ../../mmcblk0p7
  
  The assignment ending in /sda1 is what I am interested in.


  Note Down the value of the drive you wish to mount
  
  6af40af7-759f-4ee5-afea-882e9f58f17e (in this example)


  Get the uid, gid for pi user and group using:
  
  id
  
  uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),101(input),108(netdev),997(gpio),998(i2c),999(spi)
  
  Here we can see the uid for pi is 1000 (I am assuming you are using the pi account)


  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


mount_usb_drive_on_boot.txt · Last modified: 2017/02/28 18:00 (external edit)