6

I am trying to move my /home directory following the steps described here in the Ubuntu help wiki.

Everything works fine until I reach the point where I have to move /home to /old_home.

When I issue the commands:

cd / && sudo mv /home /old_home && sudo mkdir /home

I get the error message:

mv: cannot move `/home' to `/old_home': Device or resource busy 

When I issue the command I am running a terminal and a browser. Should I log out and re-enter as root to issue the command?

7


I maybe a little late but I hope my solution will help someone who comes here now. I think the author of https://help.ubuntu.com/community/Partitioning/Home/Moving forgot to mention that the step Moving /home into /old_home will work only if /home is NOT IN ITS OWN PARTITION. mv /home /old_home will work if home is just another folder. Not if /home has its own partition.
If /home has its own partition, then your command mv /home /old_home will never work because fstab will mount that partition on boot and hence the error you are getting.
If you have /home as a separate partition, I would suggest ignoring this step. You dont need a backup because when you move to your newer, bigger home partition your old /home partition will just sit there unmounted. Once you are satisfied with your newer home partition, you can format it and reuse the space.
So bottomline is if you have /home in its own partition and you followed the steps mentioned in the link above all you have to do is comment out the older home partition in fstab. Otherwise your newer home partition will never be mounted.
That's it. Hope it helps someone.
Thanks.

| improve this answer | |
  • Thanks for the info on mounted partitions I totally forgot about that – somethingSomething Aug 14 '18 at 5:45
6

Should I log out and re-enter as root to issue the command?

Yes! Moving your /home while you're logged in is a very bad idea. Files are still open here.

  1. Log out.

  2. Go to a virtual terminal by pressing Ctrl+Alt+F1

  3. Log in using the command line.

  4. Use sudo -i to become completely root, including the environment variables.

  5. Check if no file is still open on /home and only continue if nothing's open:

    lsof -n | grep '/home/'
    
  6. Perform the actions.

  7. Go back to your graphical VT: Ctrl+Alt+F7

  8. Log back in.

Alternatively, run this in recovery mode to be very sure no file to a user is open:


I get the error message:

mv: cannot move /home' to/old_home': Device or resource busy

This is probably because not only files are open there, but also file systems are mounted by you in your /home/username/.gvfs/ somewhere. Logging out should unmount them. If not, inspect the current mounts with cat /proc/mounts.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.