0

If I do an mv command from the command line in OneFS (Isilon, FreeBSD based), what exactly happens in the background and on the disks?

Will the data be physically moved from sectors to other sectors on the disks, or is it just a change to the links to those files in the files system? Does the data on the physical disk stay where they are? How are inodes involved here?

I am asking because I have a huge directory which contains over 50 TB of data, and it is shared on the network. I need to mv this directory under another directory within the same file system. I wanted to stop sharing and mv it and then share it again. I am not sure if this will be as simple as I thought.

Any inputs?

Kusalananda
  • 333,661
Root Loop
  • 103

1 Answers1

3

No, there are no copy of the whole file. Each file is described by a structure (on most UNIX file system, it is called an inode). This structure contains the informations about the file (length, date, where to find its blocks, right permission...), excepted the name.

The name of a file is in a directory which does the mapping between file names and inodes. If you move a file, you are just suppressing a mapping on a directory and create on other on a different directory.

Some filesystems may have some differences (on FAT file systems, the file informations are in the directory, but the system will transfer all the informations - a few bytes - from one directory to an other). But you have the whole scheme.

On typical UNIX filesystems, the file structure is separated from the directory, and this allow you to use multiple names (eventually from different directories) for a single file (using the ln command).

  • Unless you are moving a file from one file system to another - in which case you do a physical copy followed by a removal of the original location. – Jeremy Boden Mar 31 '23 at 14:47
  • 1
    Yes, the operating system (the kernel) don't know how to move a file from a file system to an other. Then the mv command first tries the move. The system returns an error (different FS). Then the mv command copy the whole file (each block) and remove the first file. – Frédéric Loyer Mar 31 '23 at 14:55