In the past my pen drive would be sdc.
But it is actual this.
cd /media/andy
I plugged in sticks to 2 drives and used lsblk.
It looks like Ubuntu generates random directories ?
If that is true, it would be hard to write a script to transfer files to sticks.
Is there a command line way to get this info ?
It still most likely is sdc (/dev/sdc to be precise). What you have under /media/andy/ is a mountpoint - a directory where the USB stick's filesystem is attached to the root file system, so that the contents of the USB stick can be accessed.
The name of the mountpoint directory? They are not random. If volume label is set, that will be used. If not, UUID (Universally Unique Identifier) of the drive will be used instead.
With UUID you can identify a device independent form its mount point or device name. You find them being used in your /etc/fstab, for example. Grub also uses them.
EXAMPLES
Below is lsblk listing of a USB stick that has volume label set (WINSTICK). As you can see, a directory called WINSTICK is created under /media/samuvuo and the stick is mounted there (meaning: its filesystem is attached to the root filesystem so it can be accessed via /media/username/mountpoint).
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 1 1,9G 0 disk
└─sdc1 8:33 1 1,9G 0 part /media/samuvuo/WINSTICK
Same stick but this time without volume label. UUID is now used in the mountpoint name:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 1 1,9G 0 disk
└─sdc1 8:33 1 1,9G 0 part /media/samuvuo/66AB-F207
USB stick formatted as ext4, no volume label. UUID is used as mountpoint name:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 1 1,9G 0 disk
└─sdc1 8:33 1 1,9G 0 part /media/samuvuo/9fbc37b5-027f-4b3d-8cc0-89e274291946
So yes, UUIDs could be used in scripting for better control over things. Depends on what you really want to do.
2 Likes
Thanks.
I usually use Gparted, but often use a console.
If I unmount a stick, how do I re-mount it from a console?
Another question.
If I label each stick, then it will have the same mount point.
Thus my script to copy to the stick can stay the same ?