1. IMPORTANT - 11/13/2015: In light of a possible breach we have scrubbed all passwords. You will need to request a password reset through the site. Click here for more information.

Formatting USB keys and Floppy Drives

Discussion in 'Command Line' started by cainram, Sep 20, 2013.

  1. cainram

    cainram New Member

    Sep 20, 2013
    Likes Received:
    I've been tasked with building a floppy disk and USB flash drive formatter. I'm using a raspberry pi with a USB floppy drive connected. The device will be headless. My co-worker is writing the python required to interact with the GPIO pins on the board but I'm in charge of the bash script that will perform the formatting.
    Here's what I need to know:
    How do I format a USB drive that is plugged into a specific USB port? I don't think I want to rely on sda or sdb, I want to direct the command specifically to the USB port. Is this possible?

    The floppy drive is a USB drive. It shows up as /dev/sdc... can I use the same method for this drive?

    Also, the machine will be completely headless so I'm going to use the GPIO pins to light up a green LED when the format is complete. Does the format command return a value that I can use to trigger this?

  2. KenJackson

    KenJackson Active Member

    Dec 26, 2011
    Likes Received:
    This will give you the most recently added disk to the /dev direcory. So you could use it immediately after plugging in the device.
    DEVICE=$(ls -t /dev/sd* | head -n1)
    But if you have information about the specific device, you could be even more certain by using the /dev/disk directory. It has four subdirectories with symlinks to the real device name. e.g.:
    /dev/disk/by-uuid/b99f0425-e58d-45df-668f-8f2334690f08 -> /dev/sdb1

Share This Page