renaming a huge folder: is it risky?

Changing the name on a folder is safe, if it stays within the same file system.


If it is a mount point (/data kinda looks like it could be a mount point to me, check this with mount), then you need to do something other than just a simple mv since mv /data /BD_FILES would move the data to the root partition (which may not be what you want to happen).

You should unmount the filesystem, rename the now empty directory, update /etc/fstab with the new location for this filesystem, and then remount the filesystem at the renamed location.

In other words,

  1. umount /data
  2. mv /data /BD_FILES (assuming /BD_FILES doesn't already exist, in that case, move it out of the way first)
  3. update /etc/fstab, changing the mount point from /data to /BD_FILES
  4. mount /BD_FILES

This does not involve copying any files around, it just changes the name of the directory that acts as the mount point for the filesystem.


If the renaming of the directory involves moving it to a new file system (which would be the case if /data is on one disk while /BD_FILES is on another disk, a common thing to do if you're moving things to a bigger partition, for example), I'd recommend copying the data while leaving the original intact until you can check that the copy is ok. You may do this with

rsync -a /data/ /BD_FILES/

for example, but see the rsync manual for what this does and does not do (it does not preserve hard links, for example).


Once the folder is renamed, you also need to make sure that existing procedures (programs and users using the folder, backups etc.) are aware of the name change.


You aren't renaming every file in the directory, you're renaming one file in /. That's because:

  1. directories are files, and
  2. the file system really cares about the inode, not the actual text.

Thus, renaming a directory, no matter how many files or how much data is in it, is trivial.


If you just rename (source and target in same file system), it is simply a rename of a directory entry. It either succeeds and the directory has new name, or fails in which case nothing changes *.

If the source and target are on different file systems the data needs to be copied by mv. Differences in file system features, such as maximum file size, limitations in file names, etc., can cause problems. To avoid issues, first copy files (cp, rsync, …) and after copy completes successfully, remove the files in the original location.

* However there are some corner cases, for example mentioned in the BUGS section in man 2 rename