I am trying to rename the my pen-drive by using mv command but it tries to move it and fails.
uman@uman-All-Series /media/uman$ sudo mv USB\ STICK/ Videos
mv: cannot move 'USB STICK/' to 'Videos': Device or resource busyHow can I explicitly use mv to rename a folder(it is Pen-drive in this case)?
3 Answers
When you connect a USB, the kernel will give it a name in the /dev folder, probably /dev/sdb or /dev/sdc.
The partition in your device gets mounted in the folder /media/yourusername/partition-label.
What you are trying to do is to move the folder where is mounted /media/uman/USB\ STICK, and this cannot be don whilst is mounted (busy).
If you want to rename the pendrive, you can change the label of the partition with the "disks" utility in Ubuntu. Next time it will mount in a /media/yourusername/newlabel.
You can also mount it manually in a different folder with any name you want. Have a look at man mount if this is what you want.
As long as I know moving a mounted folder is not possible still now. If you want to really move to another folder then you must remount to the target location.
First unmount your device $ umount /path/to/device device path is usually /dev/sdb1 for a pendrive (make sure especially if you have multiple drives connected).
Then make a folder in your taget folder
$ mkdir -p ~/Videos/PendriveHere -p indicates that the entire path will be created if not exists.
Then mount your drive here.
$ mount /dev/sdb1 /absolute/path/to/Videos/PendriveIf anything is not permitted try as root or add sudo before every command.
When Ubuntu mounts external drives to /media/username/ it uses partition labels for the directory names. You can mount the partition manually to set the name of the folder as you want as Chitholian suggests or change the label of the partition on the pen drive.
You have e2label, mlabel,... programs to change the partition label. You can also to it with Disks application, which is part of Ubuntu distribution.