-->

Wednesday, December 11, 2013

Mounting a USB disk drive at boot

In the following I have plugged in a USB drive and I want to have it mounted when the system boots.

Get a list of your USB devices to check if your USB drive is available

pi@raspberrycam2$ lsusb

Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 13fe:5200 Kingston Technology Company Inc. 
Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Make a directory to mount your drive/volume into

pi@raspberrycam2$ sudo mkdir /home/pi/crap




Find the UUID of your drive

pi@raspberrycam2$ sudo blkid

/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="2654-BFC0" TYPE="vfat" /dev/mmcblk0p2: UUID="548da502-ebde-45c0-9ab2-de5e2431ee0b" TYPE="ext4"
/dev/sda1: LABEL="CRAP" UUID="7CCD-19F2" TYPE="vfat"


Edit your /etc/fstab file by appending a line for your dive

pi@raspberrycam2$ sudo pico /etc/fstab

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
UUID=7CCD-19F2 /home/pi/crap    vfat    rw,umask=0      0       0
# a swapfile is not a swap partition, so no using swapon|off from here on, use $

Important. When you make the directory where a drive will be mounted it MUST be done with sudo mkdir /home/pi/crap. This is so fstab can mount it on boot, the final permissions of this mounted drive are set in the fstab line with rw,umask=0.

Linux Commands

lsusb
sudo blkid
sudo umount /home/pi/crap
sudo mount -a

No comments:

Post a Comment