Author Topic: How to Really Rename USB Stick - SOLVED  (Read 1425 times)

How to Really Rename USB Stick - SOLVED
« on: 16 January, 2021, 06:01:56 pm »
I have a 2Gb usb data stick that previously had a Debian iso on it, having been placed there by the use of a dd command.

Since then, wishing to repurpose the stick, I have used parted and done mklabel.  Choosing gpt, this allowed me also to rename the stick.  Then I used 'mkfs.ext3 /dev/sdb1' to create the file system.  Here's the output of the parted 'print' command:

Code: [Select]
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: Kingston DataTraveler 2.0 (scsi)
Disk /dev/sdb: 2046MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name      Flags
 1      1049kB  2046MB  2045MB  ext3         usbstick

I can see from the above that the parted 'name' sub-command changed the name of partition number 1 only, not the name of the whole device.

So, when I insert the drive under the Debian GUI file system, it still comes up under /media/martin/ as 'Debian 10.4.0 amd64 n', as a left-over from its former incarnation.

I want to copy some files to it, and that 'name', 'title', or whatever it is, makes the operation impossible to complete.

How can I get it named as something sensible, so that I can copy to it?  Or is there a way of formulating a command line incantation such that it will achieve the result of copying files to the device?

Re: How to Really Rename USB Stick
« Reply #1 on: 16 January, 2021, 10:44:26 pm »
I don't understand why the label would stop you copying files to the stick.

You can probably erase the label using

  sudo wipefs -a /dev/sdX

but this will remove all the partitons and data on the stick. Make sure /dev/sdX is really the stick.

Re: How to Really Rename USB Stick
« Reply #2 on: 16 January, 2021, 11:09:54 pm »
The Debian image has 2 partitions, the first is an iso9660 image that containes the 'Debian 10.4.0 amd64 n' label. Since your new partition scheme has left some unused blocks at the start of the device I suspect that this label was not overwritten when you created the new partion. I'm still not sure why the presence of the old label stopped you using the stick.

Re: How to Really Rename USB Stick
« Reply #3 on: 17 January, 2021, 09:13:08 am »
Also you may or may not be able to change the actual USB stick name which almost certainly isn't 'Debian 10.4.0 amd64 n' that's probably a partition name as others have said. The name will be probably be something like "Sandisk Cruzer" or whatever manufacturer it is and embedded in the electronics of the drive. On some it can be changed on some it can't.
I think you'll find it's a bit more complicated than that.

Re: How to Really Rename USB Stick
« Reply #4 on: 17 January, 2021, 03:38:38 pm »
I don't understand why the label would stop you copying files to the stick.

You can probably erase the label using

  sudo wipefs -a /dev/sdX

but this will remove all the partitons and data on the stick. Make sure /dev/sdX is really the stick.

Thanks, Philip.

Thanks to careful use of that powerful command, I have been able to remove the previous name and then re-format the stick using parted and mkfs.  It now comes up on /media/martin/ as 'cb844838-5faf-49af-baab-121708a5047c', which is a bit unweildy, but allows me to copy stuff to it, whereas the spaces in the previous Debian iso name didn't.


Kim

  • Timelord
    • Fediverse
Re: How to Really Rename USB Stick - SOLVED
« Reply #5 on: 17 January, 2021, 04:52:05 pm »
You do know about escaping spaces with a backslash?

Eg, for a file named "foo bar.txt"

kim@penelope:~$ cp foo bar.txt ~/stuff/
cp: cannot stat 'foo': No such file or directory
cp: cannot stat 'bar.txt': No such file or directory
kim@penelope:~$


But if you escape the space:

kim@penelope:~$cp foo\ bar.txt ~/stuff/
kim@penelope:~$



Also quotes, which unless handled with tranquillity can result in considerable stress, ulcers and even death:

kim@penelope:~$cp "foo bar.txt" ~/stuff/
kim@penelope:~$

quixoticgeek

  • Mostly Harmless
Re: How to Really Rename USB Stick - SOLVED
« Reply #6 on: 17 January, 2021, 05:58:24 pm »
You do know about escaping spaces with a backslash?

Eg, for a file named "foo bar.txt"

kim@penelope:~$ cp foo bar.txt ~/stuff/
cp: cannot stat 'foo': No such file or directory
cp: cannot stat 'bar.txt': No such file or directory
kim@penelope:~$


But if you escape the space:

kim@penelope:~$cp foo\ bar.txt ~/stuff/
kim@penelope:~$



Also quotes, which unless handled with tranquillity can result in considerable stress, ulcers and even death:

kim@penelope:~$cp "foo bar.txt" ~/stuff/
kim@penelope:~$


or just use wild cards.

$ cp foo*bar.txt ~/stuff/

I tend to use this more often as I'm a barbarian, and it's easier to type... Works for other annoying characters people put in names like () and ?


J
--
Beer, bikes, and backpacking
http://b.42q.eu/

Re: How to Really Rename USB Stick - SOLVED
« Reply #7 on: 18 January, 2021, 02:23:42 pm »
Since the OP is relatively new to the Linux command line he may not know about shell tab completion. Most shells have tab completion, although it may not be enabled by default, and will complete commands, parameters, paths, etc. when you type the first few letters and then press tab. So

  touch 'foo bar'
  rm fo<TAB>

will cause the shell to complete the filename to a properly escaped foo\ bar.  If the completion is ambiguous it will complete up to the ambiguity and then display the potential completions, you type a bit more and press tab again.

In this case you can get the awkward names by typing something like:

  ls /media/martin/cb84<TAB>

or for the original:

  ls /media/martin/Debi<TAB>

You might even type something like

  ls /me<TAB>m<TAB><TAB>

where the first tab completes media, the second completes martin and third completes the uuid path if that is the only thing you have mounted.

Re: How to Really Rename USB Stick - SOLVED
« Reply #8 on: 19 January, 2021, 04:57:59 pm »
Thanks for all that help.

I did think of using single quotes, and later double quotes around the original Debian name, but that appeared not to work.

Still learning all the time! ;)