Solved how to move /usr folder to another disk by tar

Hi,

My system is 11.0-RELEASE-p12.

I am trying to move /usr folder to a new disk.

what I did is to boot as single user and mount the new partition to /newd/ then


cd /newd/

dump 0af - /usr | restore rf -


I got this mistake:

dump: /usr: unknown file system
Tape is not a dump tape

May I know how to do for it?
 
Is this a ZFS system? dump(8) and restore(8) only work on UFS filesystems. Also note that they work on entire filesystems, not directories. If /usr/ is not a separate filesystem you cannot dump(8) it.

This will pretty much always work:
tar -C /usr -cf - * | tar -C /newd -xvf -
The above command will copy the contents of /usr/ to /newd/ while keeping things like hard and softlinks, permissions and ownerships the same.
 
Is this a ZFS system? dump(8) and restore(8) only work on UFS filesystems. Also note that they work on entire filesystems, not directories. If /usr/ is not a separate filesystem you cannot dump(8) it.

This will pretty much always work:
tar -C /usr -cf - * | tar -C /newd -xvf -
The above command will copy the contents of /usr/ to /newd/ while keeping things like hard and softlinks, permissions and ownerships the same.

I run that command under /

Got error message:

x bin/svnlitefsfs: Can't create 'bin/svnlitefsfs'
x bin/unstrtar: : Can't create 'bin/unstr'boot: Cannot stat
: No such file or directory
tar: INTERNAL ERROR: Function 'archive_read_disk_open' invoked with archive structure in state 'header', should be in state 'new/closed': Unknown error: -1
 
Oh, oops. The * screws things up. It's being expanded and swallowed by the shell before the command is executed. I've tried various combinations of quotes and escapes but always end up with an error. What does work though is if you make sure you're in /usr/. The shell's expansion of * will do the right thing in that case.
 
Oh, oops. The * screws things up. It's being expanded and swallowed by the shell before the command is executed. I've tried various combinations of quotes and escapes but always end up with an error. What does work though is if you make sure you're in /usr/. The shell's expansion of * will do the right thing in that case.

error message again:

$ sudo tar -C /usr -cf - * | tar -C /newd -xvf -
x bin/: Can't create 'bin'
x bin/pkill: Can't create 'bin/pkill'
x bin/pgrep: Can't create 'bin/pgrep'
 
The sudo(8) only operates on the first bit of the command, not the stuff after the pipe. That bit runs as your user and probably has no write access to /newd. Adding write access isn't going to help either because a user account is not allowed to create root owned files. Run the whole thing as root.

$ sudo -i
enter your password
# cd /usr/
# tar -C /usr -cf - * | tar -C /newd -xvf -

(yeah, yeah, bad things happen running as root. Nothing wrong with doing it this way though. It's not much different than running every single command through sudo(8))
 
  • Thanks
Reactions: hdc
The sudo(8) only operates on the first bit of the command, not the stuff after the pipe. That bit runs as your user and probably has no write access to /newd. Adding write access isn't going to help either because a user account is not allowed to create root owned files. Run the whole thing as root.

$ sudo -i
enter your password
# cd /usr/
# tar -C /usr -cf - * | tar -C /newd -xvf -

(yeah, yeah, bad things happen running as root. Nothing wrong with doing it this way though. It's not much different than running every single command through sudo(8))

Thanks, it is working fine.
 
Back
Top