0

I accidentally did

  • mv file /an/important/directory

instead of

  • mv file /an/important/directory/ or
  • mv file -t /an/important/directory,

so it now looks like /an/important/directory/ is clobbered. (I thought I† aliased mv to mv -i to prevent this kind of thing…)

But my filesystem is not smaller, making me think the files have not actually moved and I could do something to an inode to help the system find and organise those non-deleted files again.


Added: since same drive is apparently important, I should add that /media/target.folder is what I clobbered. I was trying to move stuff off /dev/sda1.


sudo mv: oh wait. I didn't alias mv=mv -i in /home/root/.bash_aliases as well as in ~/.bash_aliases. sudo mv likely calls the root version. Whoops.


UPDATE: Per @HackSlash’s comment, here is what my /media directory looks like:

i@scheherezade:/media$ ls -oh
total 80K
drwxr-xr-x   4 root 4.0K Jul 26 16:17 backup
drwxr-xr-x   2 root 4.0K Dec  8  2016 DEIMOS
drwxrwxrwx  69 mars 4.0K Mar 14 13:20 PHOBOS
drwxr-xr-x 113 i     56K Jul 26 18:10 media
drwxr-xr-x   4 root 4.0K Mar 31 08:43 opt
drwxrwxr-x   7 i    4.0K Mar 30 17:27 puck

I was trying to move file to /media/media, where the first /media is the system saying "things that are mounted", and the second /.../media is me saying "video and audio files". Something is clearly different about /media/media, but I don’t know if this answers @HackSlash’s suggestion about symlinks.

1 Answers1

0

What happened was: I had tried to mv /some/file /media/backup without mount /dev/sd1 /media/backup really being mounted. (When I close my laptop, network and USB hard drives disconnect.) So files were actually being copied to /dev/sda1 's root / tree, one layer down in a folder called /media. (I had to back up with sudo anyway, so the user-vs-root protection didn't stop me.) In turn, files in /media/backup (which was really /dev/sda1) were not behaving like the connected peripheral device I thought they were.

I used lsblk -f to see which things really were mounted, and where. (You can also use df -h /media/backup/ to see which UUID a folder is on. ( cat /proc/*some*file*I*forget*which* shows this information too.)

lsblk -f also tells me the names of the hardware volumes, which I've chosen to match the names of the mount points under /media/*/. To prevent confusion between the old putative /media/*/ mounts and the new correct mounts, I mounted /dev/sdk1 etc to /mnt/sdk1/.

Then mv behaves as expected.


This is on Ubuntu.