Raspberry Pi Mount Usb Drive Read Write

Whether y'all call them USB flash disks, memory sticks, keys or drives they are a useful accessory in the earth of computers. Past now many people will have a collection of various devices of varying capacities. Using them with the Pi is a great way of getting some utilise out of them rather than letting them get together dust in a drawer.

SanDisk Cruzer Micro USB Flash DriveI tend to transfer files from my Pi using FTP simply occasionally it is useful to become stuff onto a USB drive. There are lots of guides already out in that location but I had a few problems using most of them, mainly due to permission problems. My primary goal was to clarify the process by which I could mount standard FAT32 drives and permit the default Pi user read/write permissions.

And then here is my procedure for using USB flash drives with the Raspberry Pi where the Pi user has permissions to use it without needing "sudo". It works great with the shiney new Kingston Digital 32GB DataTraveler Micro I've just bought myself.

PiHub by PimoroniPace 1 – Plug In The Device

The start step is to plug in your USB stick. If you are using a mouse and keyboard you lot volition need a decent USB hub at this point. (e.g. the PiHub by Pimoroni).

Step two – Identify The Devices Unique ID

In gild to find the unique reference (UUID) for your drive run the following command in the last :

ls -l /dev/disk/by-uuid/

This will requite you an output that should list your drive :

Mount USB Stick

The line volition usually refer to "/sda" and in this example it is "sda1". My ID is "18A9-9943". Annotation down yours.

Y'all would need to repeat this footstep if yous wanted to employ a different device as the UUID would be different.

Step 3 – Create a Mount Point

A mount indicate is a directory that volition indicate to the contents of your flash bulldoze. Create a suitable binder :

sudo mkdir /media/usb

I'grand using "usb" simply you can give it whatever proper noun you lot like. Keep it brusk every bit information technology saves typing subsequently. Now we need to make sure the Pi user owns this folder :

sudo chown -R pi:pi /media/usb

You will only need to do this step once.

Step four – Manually Mount The Drive

To manually mount the bulldoze employ the post-obit command :

sudo mountain /dev/sda1 /media/usb -o uid=pi,gid=pi

This will mount the drive then that the ordinary Pi user can write to it. Omitting the "-o uid=pi,gid=pi" would mean you could only write to it using "sudo".

Now you lot can read, write and delete files using "/media/usb" as a destination or source without needing to use sudo.

Step 5 – United nations-mounting The Drive

You don't need to manually un-mount if you shutdown your Pi just if you lot need to remove the drive at any other time you should united nations-mount information technology first. Only the user that mounted the bulldoze tin can un-mount information technology.

umount /media/usb

If yous used the fstab file to auto-mount it you will need to use :

sudo umount /media/usb

If you are paying attention y'all will notice the control is "umount" Non "unorthmountain"!

Pace half dozen – Auto Mount

When you restart your Pi your mounts will be lost and you will need to repeat Step 4. If you want your USB drive to be mounted when the system starts you can edit the fstab file :

sudo nano /etc/fstab

Then add together the following line at the end :

UUID=18A9-9943 /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0

The "nofail" pick allows the kicking process to proceed if the drive is not plugged in. The "noatime" selection stops the file access time being updated every time a file is read from the USB stick. This helps meliorate functioning.

My fstab file looks similar this :

USB Stick Automount Fstab File

Make sure y'all set up the right UUID. Apply CTRL-10 followed by Y to save and exit the nano editor.

Now reboot :

sudo reboot

Your USB drive should be auto-mounted and bachelor as "/media/usb".

 An Actress Note About File Systems

In the examples to a higher place I specified "vfat" as the file system of the device as it was formatted as FAT32. If y'all need to change the file organisation replace references of "vfat" with "ntfs-3g", "ext3" or "ext4".

If you lot are using NTFS you will also need to install the post-obit bundle :

sudo apt-get install ntfs-3g

Last Thoughts

This technique suits my applications merely the chief disadvantage is that information technology is specific to a known USB device given we are using the device ID. However if yous created a few mount points in advance you could manually mount a new device to a spare mountain point without worrying about updating the fstab file.

daileysmad1946.blogspot.com

Source: https://www.raspberrypi-spy.co.uk/2014/05/how-to-mount-a-usb-flash-disk-on-the-raspberry-pi/

0 Response to "Raspberry Pi Mount Usb Drive Read Write"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel