Summary:
- Had a directory at
~/src/databasecontaining~250 GBof files. - Executed
mv ~/src/database ~/ - Instead of expected result (
databasenow at~/), I ended up with adatabasedirectory in both the source and destination, but with only a small fraction of the original files (i.e. the database was apparently corrupted/lost duringmvsomehow).
The lost files are not an issue---I have multiple backups. The issue is that even after doing rm -rf ~/database; rm -rf ~/src/database my harddrive is now short ~500 GB (coincidentally, the size of 2 copies of the database).
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/nvme1n1p2 1.9T 1.1T 701G 61% /
However, a complete breakdown of the drive in baobab shows that I'm only using ~600 GB with all files accounted for on the root volume. This is consistent with what I knew beforehand and also the failed mv operation. The math is roughly correct: 1.1 TB - 500 GB = 600 GB, which is exactly what baobab says I'm using.
In the past I have had similar issues, and the solution was to remove the parent directory, which somehow reclaimed the space. That isn't working here.
- I already tried removing the parent of the source, didn't work.
- Parent of the destination is my home dir, so not easy to
rmthat.
Question:
How can I reclaim this space? Is there a way to force the OS to reclaim stranded nodes from the disk?
$ findmnt -T ~/src
TARGET SOURCE FSTYPE OPTIONS
/ /dev/nvme1n1p2 ext4 rw,relatime,discard
$ findmnt -T ~/
TARGET SOURCE FSTYPE OPTIONS
/ /dev/nvme1n1p2 ext4 rw,relatime,discard
mvis equivalent tocp+rmif from one filesystem to another (or in some rare circumstances (example)). The question suggests there is just one filesystem involved, so in theory there was no need forcp. Is this really so? What is the output offindmnt -T ~/src/?findmnt -T ~/? What is the type of the filesystem? Are you sure it's healthy? (2)B(byte) is 8 times larger thanb(bit).GBis 8 times larger thanGb. It's very uncommon to measure disk usage inGborTb. I don't know where1.1 Tbcame from. Check your units. – Kamil Maciorowski Jun 04 '23 at 17:15mvis basicallycp+rm, and it appears thecpportion failed and we never reachedrm. This is just a standard directory move, same as if you used a UI tool to drag a directory from one place to another on the same drive. The units involved here are all Gigabytes and Terabytes. I updated theb->Bif you want to be pedantic, but doesn't change the issue. Not sure if filesystem is healthy. Can you suggest a way to check that? – EntangledLoops Jun 04 '23 at 17:20mviscp+rm. Within a single filesystem it's (almost always) not, there is nocpto begin with, there is onlyrename. I think it's important to know how many filesystems were involved, hence my requests forfindmnt. – Kamil Maciorowski Jun 04 '23 at 17:24cp"inside"mv. The stranger "the size of 2 copies of the database" is. The tool to check ext4 isfsck.ext4akae2fsck(the filesystem must not be mounted; or check this question). – Kamil Maciorowski Jun 04 '23 at 17:55database, is this an odd storage location of the files of an actual database application and you tried to move it while the process utilising said database was still running? – tink Jun 04 '23 at 21:31