A directory in my external drive contained 1tb data, and when accidentally unplugging, the directory shows empty when opened and in properties...
When I go to delete directory, shows "error: directory not empty"
How to resolve this?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You may be able to retrieve a lot of information about your drive when it is connected, and hopefully this will give you some ideas. I will list some command-line based tools.
rm /direcotry/path -rf
...should solve your problem with this direcotry: it should really remove it for good. If you need to, you can precede the above command with sudo; and you have to be VERY cautious, because you will remove almost anyting you ask it to. Also, type
-rf at the end, so if you press Enter accidentally, prematurely, you will not "force" and "recursively" over something you did not intend.
However, if you feel like experimenting more - there is more for you below:
sudo fdisk -l
...will list device name, size and partitions (and more). In the last column you get the partition type.
I think that fat32 is not the optimal choice for large disks, however, it is fairly standard everywhere. You could use ntfs - nowadays Ubuntu also supports it to some extent.
sudo df -h sudo df -hi
...will pint info about mounted filesystems together with the name of a device that contins it. You have bytes (default) used, you have inodes (specified by -i parameter) which are correlated to the number of files on the disk (not only a size matters, bu also the number of entries in the file allocation table). "h" for human readible units.
cd /directory/path du -hs
...will let you know the summary of that is in
/direcotry/path. "s" for summary rather than a complete list and "h" for human readible units.
du -ms * | sort -n du -ms */* | sort -n
...this is the protagon of all console-based disk-free-space checks. My favourite. I love how it shows me the biggest items in the current path. By using
asterisk instead of
asterisk you will compare all sub-items that are in the current location.
...is for viewing the directory too. "h" as above, "a" includes hidden files/dirs, "l" shows access rights and ownership info. Especially "a" flag may be of interest in your case.
Copy your precious data elsewhere and format the drive over again. After all, the system might have suffered some damages due to the power loss.
sudo unmount /dev/name0 # carefully select the device
CAREFULLY CHOOSE THE DEVICE. If you make a typo at some point, you may loose all you data and OS, and your machine will stop working.
sudo fsck /dev/name0
...has the potential to repair your disk whis HAS TO BE unmounted. After fsck finishes, you can remount your drive by
mount /dev/name0 /any/path/you/want and verify, but sometimes you have to replace the filesystem internals - keep on reading.
sudo mkfs.ntfs /dev/name0
...it overwrites the file system the disk already has. This could also be
mkfs.vfat for fat32 or (what I prefer)