What is the easier way to move a directory to newly mounted drive

Example, if I have a directory called /example and mounted a new drive to /vol, how I can easily move /example to /vol

Since database data is stored in /example, if I copy the folder it might just get corrupted.


  • 1
    Why would the data get corrupted exactly?? – Chris S Oct 26 '10 at 16:31
  • 4
    Is this homework? – Chopper3 Oct 26 '10 at 16:36

mv /example /vol

(Works in Linux, BSDs, most Unix flavors, and Windows PowerShell)

  1. Shut down database (or any other service depending on /example)
  2. mv /example/* /vol/
  3. rm -rf /example
  4. Either reconfigure your database/applications to use /vol, or create a symlink with ln -s /vol /example

Moving the data directory should be ok as long as the database is shut down before the move occurs.

Move all files in /example into /vol:

mv /example/* /vol

Files will be directly under /vol.

Move /example directory inside /vol:

mv /example/ /vol

Files will be under /vol/example.

  • 1
    You've got the same command up there twice... – Chris S Oct 26 '10 at 16:39
  • His 2nd eg shouldn't have the /*. – Mark Wagner Oct 26 '10 at 17:23

Your Answer

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