Formatting USB storage

Formatting USB storage#

Note

You will need a formatted external thumb drive to collect images from the AutoPollS units. The units are most regularly tested using Samsung BAR 3.1 USB 256 GB external thumb drives, but the following instructions should work for most thumb drives.

Option 1: ( most reliable and most tested)#

What you will need:
  • Thumb drive that can be completely wiped

  • Access to working raspberry pi or linux machine WITH a working/formatted thumb drive

Open terminal

sudo fdisk -l

that is a lowercase “L”

Make sure that your new thumb drive is located at /dev/sda1 NOT /dev/sdb or other position, and that no other external device is plugged into sda1 or it could get reformatted. I.e., confirm that there is a device listed as ‘/dev/sda1’ under ‘Device’ on the last line of the output from the command above

Once confirmed, in terminal .. code-block:: None

type sudo fdisk /dev/sda

This will open up a program for reformatting the hard drive.

  • Type g, then press “enter” [This creates a new ‘GPT’ disklabel]

  • Type d, then press “enter” [This will delete existing partitions - you can ignore the warning if it says ‘No partition is defined yet’]

  • Type n, then press “enter” through all default settings. [This will generate a new partition]. Press “y” if prompted about over writing format or ‘removing the signature’

  • Type t, then press “enter”, type “11” then press “enter” [This changes the partition type from one filesystem to another ‘Microsoft basic data’]

  • Type w, then press “enter” [This command will write the changes to the disk]

This should exit the fdisk utility and take you back to terminal, if you see text that says that “writing has failed” or an issue with “formatting the drive” run the above lines (h-n) again. In terminal type:

sudo mkfs.ntfs -f /dev/sda1

If it runs successfully, you should see text that says “have a nice day”

If not, reboot (by typing ‘sudo reboot -h now’ in Terminal), and attempt this step “p” again

[If you are again working on a separate RPi or other machine, skip the following steps]

In terminal type: .. code-block:

sudo mount /mnt/data

If there’s an error saying sda is already mounted, run

sudo umount /dev/sda1

Then attempt to mount again with

sudo mount /mnt/data

Use the file explorer to check that your new thumb drive is mounted at /mnt/data, you should see around 256GB of storage In terminal type .. code-block:

sudo mkdir -p /mnt/data/logs
sudo chgrp ftp /mnt/data
sudo chmod 775 /mnt/data
sudo chown  pi /mnt/data