One of the easiest tasks to perform on Windows and macOS is renaming a USB thumb drive. Using the file explorer on either, you select the item, open its properties, and attempt to rename the thumb drive. Works without issue on Windows and macOS, but try that on Raspbian and you’ll get the following:
Oh dear. No obvious way to run this on the graphical desktop via sudo. It’s these kinds of it-should-be-the-same-on-Raspbian-but-it-isn’t moments that tends to kill some of the enthusiasm of newcomers to the Raspberry Pi and Raspbian itself. Rather than worry about that, let’s do it from the command line. It’s real easy, and you’ll learn a bit about the command line in the process.
First, let’s open an LXTerminal and do a directory listing of where the thumb drive is located (or mounted in Unixese).
pi@raspberrypi:~ $ ls -AlFh /media/pi/total 20Kdrwxr-xr-x 3 pi pi 16K Dec 31 1969 1D2D-5A2A/drwxr-xr-x 2 pi pi 1.0K Dec 31 1969 MICROBIT/pi@raspberrypi:~ $
You can tell I have the micro:bit inserted, but what’s 1D2D-5A2A? That, my friend, is the name given by the OS and the USB to the USB because it has no explicit device/volume name. I want to rename that to something more human-friendly. Before I can rename it, I need to find out what the device name is. Knowing it’s volume name won’t help. But I can use the volume name it currently has to find the device name. So let’s do that right now.
pi@raspberrypi:~ $ mount | grep 1D2D-5A2A/dev/sda1 on /media/pi/1D2D-5A2A type vfat ...pi@raspberrypi:~ $
When you run this command on your Raspberry Pi you’ll see it produces a lot more information than what I’ve show here, which is why I’ve added the ellipsis to the results. The information we are interested in is right up front, which is the device (/dev/sda1) and the type of file system it is, which in this case is vfat. We have our information, so let’s rename it. I’m going to call it ‘green32’ because it’s a green USB thumb drive with 32GB of storage.
pi@raspberrypi:~ $ sudo mlabel -i /dev/sda1 ::green32pi@raspberrypi:~ $ sudo umount /media/pi/1D2D-5A2Api@raspberrypi:~
Now unplug the USB thumb drive and plug it back in again. Raspbian will rediscover it and mount it with the new name you just gave it.
pi@raspberrypi:~ $ ls -AlFh /media/pi/total 20Kdrwxr-xr-x 3 pi pi 16K Dec 31 1969 GREEN32/drwxr-xr-x 2 pi pi 1.0K Dec 31 1969 MICROBIT/pi@raspberrypi:~ $
The keen-eyed among you will note that even though I used ‘green32’ it is seen by Raspian as ‘GREEN32’. Just accept it and move on.
From this point you can use it just like you would before you renamed it, except it’s name is more easily readable. Being able to pick a name for your volume makes building automated tools that look for a specific file path much easier to write, especially if your detachable storage has the same name, such as BACKUP for example, across multiple external devices.
You must be logged in to post a comment.