I have an exfat formatted sdcard. It went into a mac, some files were pulled off of it, then it went back into a linux machine. The filesystem still appears to be mostly full even though there's nothing left on it. I deleted the remaining files from it (just the empty DCIM
directory) and it still reports 55% full. For instance running df -h
/dev/mmcblk2p1 60G 32G 29G 53% /mnt/sdcard
Even though ls -lsa
shows:
total 132
128 drwxrwxrwx 1 user user 131072 Dec 31 1969 .
4 drwxrwxr-x 12 user user 4096 Feb 26 10:31 ..
If I umount it and use exfatfsck
I see that it has zero files and directories but still 31GB of used space:
fsck from util-linux 2.27.1
exfatfsck 1.2.3
Checking file system on /dev/mmcblk2p1.
File system version 1.0
Sector size 512 bytes
Cluster size 128 KB
Volume size 59 GB
Used space 31 GB
Available space 28 GB
Totally 0 directories and 0 files.
File system checking finished. No errors found.
I had to reformat the partition to get the space back: mkfs.exfat /dev/mmcblk2p1
.
fsck from util-linux 2.27.1
exfatfsck 1.2.3
Checking file system on /dev/mmcblk2p1.
File system version 1.0
Sector size 512 bytes
Cluster size 128 KB
Volume size 59 GB
Used space 2688 KB
Available space 59 GB
Totally 0 directories and 0 files.
File system checking finished. No errors found.
How does this happen? Is there any way to recover the space without reformatting the entire disk? I'm concerned about running into this situation again and the sdcard being not-entirely-empty.
Best Answer
It appears that you didn't properly eject the removable storage when you had it connected to the Mac, resulting in a corrupted file-system. Regardless of Operating system (this applies to Ubuntu as well) it's important to
sync
to flush the buffers and/or safely eject removable storage to avoid corruption and possible data loss.Note: emphasis mine.
Source: How do I safely remove a USB device from my computer? - Tech Ease