Find the answer to your Linux question:
Results 1 to 6 of 6
I've run in to a surprising problem. I am sure I am missing something simple. I am just trying to move a directory with the mv command, but I get ...
  1. #1
    Linux Newbie
    Join Date
    Aug 2005
    Location
    Sterling, VA
    Posts
    100

    Move Directories

    I've run in to a surprising problem. I am sure I am missing something simple.

    I am just trying to move a directory with the mv command, but I get a "directory not empty" error.

    There are hundreds of subdirectories, and thousands of files. Certainly I am not expected to move each one, one at a time.

    It is 300 GB and I don't have the space to copy them all, and then delete. What is the solution for this? It doesn't seem like it should be such a problem.

    Thanks,

    Dave
    - EndianX -

  2. #2
    Just Joined!
    Join Date
    Feb 2011
    Posts
    1
    Using "mv" to relocate a large directory is a good way to end up needing to restore something from backup. I'd try to find spare disk space from anywhere to rsync this to, remove the dir and then rsync back. You are in effect doing a backup anyway, so if you have something like Netbackup, a backup and restore is also recommended. So long as whatever services are sharing those files have been shut down.

  3. #3
    Just Joined!
    Join Date
    Apr 2010
    Location
    Bangalore, India.
    Posts
    12
    mostly mv command should work, and also u can use force move command "mv -f". or else might be problem with file system errors try to reboot ur system with "shutdown -Fr" for force fsck ..

  4. #4
    Linux Newbie
    Join Date
    Aug 2005
    Location
    Sterling, VA
    Posts
    100
    antony_pradeep, you are right. I just did the following as a test.

    mkdir test
    touch test/file1
    touch test/file2
    mv test test2

    That worked fine. I will try a fsck and let you know how that goes. Thanks.
    Last edited by EndianX; 02-22-2011 at 01:20 PM.
    - EndianX -

  5. #5
    Just Joined!
    Join Date
    Feb 2011
    Posts
    8
    Quote Originally Posted by shokk View Post
    Using "mv" to relocate a large directory is a good way to end up needing to restore something from backup.
    How so? Is this filesystem specific?

    I mean, I've been moving literally hundreds of gigabytes with "mv" for many years without any problems.

  6. #6
    Just Joined!
    Join Date
    Jan 2009
    Location
    Kolkata, India
    Posts
    8
    Quote Originally Posted by EndianX View Post
    I've run in to a surprising problem. I am sure I am missing something simple.

    I am just trying to move a directory with the mv command, but I get a "directory not empty" error.

    There are hundreds of subdirectories, and thousands of files. Certainly I am not expected to move each one, one at a time.

    It is 300 GB and I don't have the space to copy them all, and then delete. What is the solution for this? It doesn't seem like it should be such a problem.

    Thanks,

    Dave
    Did you try
    $mv -f oldname/ newname/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •