1

I have a mounted an external hard disk on /media/pcmagas/Backup disk containing a folder dimitrios. When I try to remove it with the following comand:

/media/pcmagas/Backup disk
sudo rm -rf ./dimitrios

I get this error:

rm: cannot remove './dimitrios/Kwdikas/Javascript/data_map/node_modules/random-bytes': Directory not empty

The mounted disk is ntfs, and I have mounted it into an Ubuntu GNU/Linux system.

When I run ls -l ./dimitrios/Kwdikas/Javascript/data_map/node_modules/random-bytes I get the following error:

ls: reading directory './dimitrios/Kwdikas/Javascript/data_map/node_modules/random-bytes': Input/output error
  • 2
    This could indicate filesystem corruption or a hardware issue. What does dmesg output after getting the I/O error? – Torin Apr 15 at 16:46
  • Well I reformated the disk after backed up the wanted data. – Dimitrios Desyllas Apr 15 at 17:05
  • You may want to run badblocks on the device since it's possible the disk might have bad sectors – Torin Apr 15 at 17:16
  • 1
    Two questions — (a) which filesystem does “Backup disk” use? (b) are there any error messages from the kernel in dmesg, /var/log/kern.log, the systemd journal, etc.? – derobert Apr 15 at 17:26
  • 1
    @DimitriosDesyllas I'd guess you've hit a bug in the NTFS drivers for Linux. If this disk is just for backup from Linux, I'd strongly suggest using ext4, XFS, btrfs, etc. instead of NTFS. If you hadn't reformatted the disk, the next step would have been an fsck. Possibly from a Windows machine. – derobert Apr 15 at 17:29
1

In order to solve the problem you should do:

  1. rsync any folder that you want to keep in the hard disk back to your computer's hard disk.
  2. Then format it, you can use the gparted gui program to do so if you have an XOrg installed GNU/Linux system.
  3. Move back the folders you kept.

I know its a bit hacky but for desktop use did the job in my case.

-2

'rm' command is used to remove files only and directories that are not empty

use 'rmdir' to remove directories to remove dir's which are empty

  • 3
    The -r flag on rm removes empty directories too – Torin Apr 15 at 17:35
  • 1
    The OP correctly used the rm command to remove non-empty directories. Your answer is incorrect. – 0xSheepdog Apr 15 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.