Removing Files & Directories from FreeNAS With Invalid Filesname

Today I had a user come to me who was having issues removing an old directory from a dataset on an enterprise FreeNAS storage solution. After some investigation, I discovered that there was a file buried in one of the directory’s subfolders that had a large number of invalid characters in its filename. 

Usually, I would remote into the FreeNAS server and use the following terminal command to remove the offending directory:

sudo rm -R DIRECTORY

However, due to the complexity of the filename I was continually receiving an “Invalid Argument” error.

Unable to remove the file using my Mac, I pulled up the FreeNAS webGUI and opened a shell prompt to attempt to remove the directory directly from the FreeNAS.

WARNING: It is very easy to cause data loss when navigating the array using the FreeNAS shell if you are not careful. Always double check your commands and location before proceeding.

In the shell you need to navigate to the dataset where the problem directory resides. 

cd /mnt/tank/

Confirm the trouble directory is in this location using the ls command. Once you have confirmed that you are in the correct location, you can use the line of code below to remove the trouble directory and it’s subfolders/files.

rm -rf DIRECTORYNAME

The trouble directory will be removed and you can confirm its removal using the ls command. Users will noticed it disappear from their mounted shares shortly thereafter.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.