I get an error when copying files to a USB drive with my script
Solution 1:
Testing for /dev/sdb1
does not guarantee anything. You would like to identify the mountpoint of the file system on the USB drive. Try with the a command line with lsblk
, for example
lsblk -f
or I think better, with
lsblk -o NAME,SIZE,HOTPLUG,FSTYPE,LABEL,MOUNTPOINT,MODEL | grep -v '/snap/'
You can make an alias to make it easier:
alias mylsblk="lsblk -o NAME,SIZE,HOTPLUG,FSTYPE,LABEL,MOUNTPOINT,MODEL | grep -v '/snap/'"
and edit it into your ~/.bashrc
file near the other aliases. Run
source ~/.bashrc
and you can start using it:
$ mylsblk
NAME SIZE HOTPLUG FSTYPE LABEL MOUNTPOINT MODEL
sda 238,5G 0 SanDisk SD6SB1M2
├─sda1 500M 0 ntfs System
├─sda2 139,4G 0 ntfs Windows
├─sda3 1000M 0 ntfs Recovery
├─sda4 1K 0
├─sda5 89,7G 0 ext4 lubionic /
└─sda6 8G 0 swap [SWAP]
sdb 3,7T 0 WDC WD4002FYYZ-0
├─sdb1 510M 0 ext4 boot-nvme-focal
├─sdb2 30G 0 ext4 xubufocal-hdd
├─sdb5 1M 0
├─sdb6 100G 0 ext4 studio12.04
├─sdb7 3,5T 0 ext4 multimed-2 /media/multimed-2
└─sdb8 5G 0 swap
sdc 15G 1 Transcend 16GB
└─sdc1 15G 1 vfat KEEP_ME /media/nio/KEEP_ME
sr0 1024M 1 DVD-RW DH16AESH
nvme0n1 232,9G 0 KINGSTON SA2000M8250G
├─nvme0n1p1 232,9G 0 ext4 nvme-focal
└─nvme0n1p2 1M 0
In the example from my computer there are many drives and even more partitions. But now you can see that HOTPLUG is 1 for /dev/sdc
, and you can see the size and model, to make it easy to identify. So in this case you should copy to the mountpoint of the FAT file system /media/nio/KEEP_ME
.