I can't find a file I moved to USB drive
I downloaded a short video, then wrote:
sudo mv /home/myname/Downloads/m.mp4 /dev/sdb1
the video disappeared completely. It's not in the USB drive. I searched for it by writing:
find / m.mp4
find m.mp4
But it's nowhere to be found.I keep getting
find: ‘m.mp4’: No such file or directory
The USB is mounted and accessible. The video is no longer in Downloads.
Sudodus, thank you. I still don't get it fully but I understand I should've used the mount point. I used it and it worked, like magic. Nothing was erased from the USB, so I am not sure why you apologized. How would you know what the mount point is? I found it in Gparted. And what does this mean, from Gparted:
init :: non DOS media
Cannot initialize '::'
mlabel: Cannot initialize drive
init :: non DOS media
Cannot initialize '::'
The output when I wrote sudo ls -l /dev/sdb1
is
-rw-rw-r-- 1 moe moe 23362068 Jul 2 15:44 /dev/sdb1
Solution 1:
Your file is still there. It's just now named /dev/sdb1
and has replaced the device special node that would otherwise be used to mount your USB disk.
You can recover it by moving it back to somewhere else, for example:
sudo mv /dev/sdb1 /home/myname/Downloads/m.mp4
Don't overwrite files in /dev
as these are not normal files, but special markers which give the OS raw access to certain hardware devices. Your use of sudo mv
destroyed the device special node /dev/sdb1
and replaced it with your video file.
After you move the video back to where it came from, eject and reinsert your USB stick, and you can write files to it via its mount point (typically /run/media/yourusername/USBSTICKNAME
but you can run the command mount
to see where it was actually mounted). Linux will recreate the device special /dev/sdb1
if necessary when you reinsert the USB stick.
Also note that if your USB stick was correctly mounted by the system, its files should be writable by your username, and you should not need to use sudo
to move files to or from it.
Solution 2:
lsblk
command could be used to find out your mount point:
$ lsblk | grep -v loop
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 223.6G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 221.6G 0 part /
└─sda3 8:3 0 2G 0 part [SWAP]
sdb 8:16 0 232.9G 0 disk
└─sdb1 8:17 0 232.9G 0 part /home
All devices in /dev/
folder are recreated during OS start. You could see it by ls -ailh /dev/
command and in case if some device have been reattached.
If you'll have a deal with Android device, you could find your device storages in /var/run/user/1000/gvfs
folder, where 1000
is uid
of your user.
$ ls /var/run/user/1000/gvfs
gvfs/ gvfs-burn/
user@ubuntu:~$ cd /var/run/user/1000/gvfs/mtp\:host\=Xiaomi_Redmi_6A_3951d46a7d27/
user@ubuntu:/var/run/user/1000/gvfs/mtp:host=Xiaomi_Redmi_6A_3951d46a7d27$ ls
disk 'Internal shared storage'
user@ubuntu:/var/run/user/1000/gvfs/mtp:host=Xiaomi_Redmi_6A_3951d46a7d27$ echo $UID
1000
Devices also could be mount automatically into /media/$USER
or /mnt
folders.
Solution 3:
It could be because of usb-port. Sometimes usb-ports of computers or notebooks are not fully mounted by driver. So you could try :
umount /dev/sdb1
or
sudo umount /dev/sdb1
then
mount /dev/sdb1
or
sudo mount /dev/sdb1
If this does not help - plug-out and plug-in again the usb-drive (usb-stick?). Then repeat umount and mount again like written above.
When you want to move or to copy files as sudo, then you need to mount as sudo too.
Before you move or copy files not as sudo, instead as normal user - then you can umount or mount as normal user too. It depends on the files, which file-permissions they have.