Red Hat Bugzilla – Bug 457003
usermod failed if src and dst are different filesystem
Last modified: 2012-06-20 11:57:31 EDT
Description of problem:
usermod(8) failed to move contents of user's directory,
if the souce and destination are on different filesystem.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Original home directory (source) is on a separate
filesystem from destination.
# mount | grep /mnt
/dev/cciss/c0d3p1 on /mnt/user0001 type ext3 (rw)
/dev/cciss/c0d3p2 on /mnt/home_file_system type ext3 (rw)
1. # usermod -d /mnt/home_file_system/user0001 -m user0001
usermod: cannot rename directory /mnt/user0001 to /mnt/home_file_system/user0001
Destination Directory NOT exist.
# ll /mnt/home_file_system/user0001
ls: /mnt/home_file_system/user0001: No such file or directory
Original Source Directory IS exist, but all contents are gone.
# ll /mnt/user0001
User's home directory and its files should be moved without error.
strace shows an error.
8426 12:09:10.906312 rename("/mnt/user0001", "/mnt/home_file_system/user0001")
= -1 EXDEV (Invalid cross-device link)
EXDEV = old path and new path are not on the same mounted
Even though the EXDEV error happen, still usermod(8) continue
its job such as create destination directory, and delete
user's original file in source directory.
8426 12:09:10.906396 mkdir("/mnt/home_file_system/user0001", 0755) = 0
8426 12:09:10.907246 open("/mnt/user0001/test.txt", O_RDONLY|O_LARGEFILE) = 5
8426 12:09:10.907315 open("/mnt/home_file_system/user0001/test.txt",
O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0) = 6
8426 12:09:10.907563 read(5, "abc\n", 1024) = 4
8426 12:09:10.907632 write(6, "abc\n", 4) = 4
8426 12:09:10.908445 unlink("/mnt/user0001/test.txt") = 0
And at last, delete destination directory!
8426 12:09:10.909217 unlink("/mnt/home_file_system/user0001/test.txt") = 0
8426 12:09:10.909421 rmdir("/mnt/home_file_system/user0001") = 0
If this is a bug, it need to be fixed.
If this is a limitation, so you should document in man that
usermod(8) can not support between 2 different filesystem.
I can't reproduce this problem. :(
There are two different filesystems
# stat --format='%d\n' /home/foo /mnt/test/lost+found/
# usermod -d /mnt/test/foo -m foo
# stat /home/foo
stat: cannot stat `/home/foo': No such file or directory
# ls -a /mnt/test/foo/
. .. .bash_logout .bash_profile .bashrc .canna .emacs .gtkrc .kde .xemacs .zshrc
# rpm -q shadow-utils
strace error EXDEV is OK.
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life.
Please See https://access.redhat.com/support/policy/updates/errata/
If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.