I have a program that records telemetry data every 15 minutes or so into a binary file. If there is no USB stick in any of the USB port, it will save these telemetry data files in the SD Memory card. If there is an USB stick available, it will save these telemetry data files into USB stick. So, while my program is running, I plug an EMPTY USB Stick and the error DISK IS FULL message pops up crashing my program. I have no idea why this is happening. If anyone can give me a hint, I would appreciated. Thank you.
Try formatting the USB drive.
I use a digital camera to format my SD cards, but windows does a great job on the flash drives.
- Open a command Prompt as administrator (cmd.exe)
- Type Diskpart and press Enter
- Type List Disk and press Enter
- Type Select Disk X (where X is the disk number of your USB drive) and press Enter
- Type Clean and press Enter
- Type Create Partition Primary and press Enter
- Type Active and press Enter
- Type Format fs=Fat32 Quick and press Enter
- Type Exit and press Enter
Warning: Make sure you are 100% sure you format the right disk. If not, you could clear your hard drive!
Try formatting the USB drive. You should use the operating system that will use the USB drive to avoid possible inconsistencies in particular if you need an ext4 filesystem.
Boot your RasPi with the USB stick plugged in and maybe without starting your program so it will not crash.
If you want an fat filesystem then execute this command, assuming the partition on the USB stick is seen as
rpi ~$ sudo mkfs.fat -n USBSTICK -F 32 /dev/sda1
This will create a fat32 filesystem on the partition with label USBSTICK.
If you want an ext4 filesystem then execute this command:
rpi ~$ sudo mkfs.ext4 -L usbstick /dev/sda1
This will create the filesystem with label usbstick.