Moving directories the right way

I need help with moving /usr /var /tmp from the / mount into newly created slices. I used gpart recover, add, and newfs to format the unused space. Here is my question. What are the proper steps to move the directories to the new slices? I want to avoid any unforeseen issues and I want to avoid any issues with performance so I'm asking the experts for a definitive answer. :) I've searched for a guide but it wasn't clear or didn't directly relate to my setup.

Code:
root@:/ # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2     36G    2.2G     31G     6%    /
devfs          1.0k    1.0k      0B   100%    /dev


Code:
root:/ # gpart show
=>       34  167772093  ada0  GPT  (80G)
         34        128     1  freebsd-boot  (64k)
        162   79691776     2  freebsd-ufs  (38G)
   79691938    4194109     3  freebsd-swap  (2G)
   83886047   20971520     4  freebsd-ufs  (10G)
  104857567    4194304     5  freebsd-ufs  (2.0G)
  109051871   58720256     6  freebsd-ufs  (28G)


Code:
var /dev/ada0p4
tmp /dev/ada0p5
usr /dev/ada0p6
 
You definitely want to do this from single user mode. You basically mount the new filesystem on /mnt/ and copy everything. I usually use tar(1) for this as it keeps ownership, permissions and doesn't mess up soft and hardlinks.

Something like this usually does the trick:
# tar -C /tmp -cf - * | tar -C /mnt -xvf -
(this copies everything from /tmp to /mnt)

Once everything is copied correctly you can clear out the old directories and edit /etc/fstab to mount the new filesystems in place.

NB. There's no real need to copy the contents of /tmp/. Just clear it out and mount a clean filesystem on it. The system will create any directories it needs during booting. I would also suggest using tmpfs(5) for /tmp/, especially if you have lots of memory.
 
Rereading, now I see you are splitting up a lone / into separate filesystems. For that, I would use rsync(1). Compile it with the FLAGS option on. Then:

# rsync -axHAXS --delete --fileflags --force-change [i]source dest[/i]

Comparing a filesystem copied that way to one copied with tar(1) might be interesting.
 
I'm trying to rsync /usr but I get the follwing:


Code:
> rsync: link "/mnt/bin/ypchfn" => bin/ypchsh failed: Operation not permitted (1)
> rsync: link "/mnt/bin/chpass" => bin/ypchsh failed: Operation not permitted (1)
> rsync: link "/mnt/bin/chsh" => bin/ypchsh failed: Operation not permitted (1)
> rsync: link "/mnt/bin/chfn" => bin/ypchsh failed: Operation not permitted (1)
> rsync: link "/mnt/bin/passwd" => bin/yppasswd failed: Operation not permitted (1)

Any ideas?
 
Yes. I do.

Code:
rsync-3.0.9_2       A network file distribution/synchronization utility

===>  Patching for rsync-3.0.9_2
===>  Applying extra patch /usr/ports/net/rsync/work/rsync-3.0.9/patches/fileflags.diff
===>  Configuring for rsync-3.0.9_2
 
Do I need to update /usr/ports? Hmmm... I think I should reinstall the OS with the partitioning I desire. This is taking way too long. I will setup a junk box to practice this some other time.

I thank you for your input though.
 
I updated ports and recompiled rsync

Code:
===>  Patching for rsync-3.0.9_3
===>  Applying extra patch /usr/ports/net/rsync/work/rsync-3.0.9/patches/fileflags.diff
===>  Applying extra patch /usr/ports/net/rsync/files/extrapatch-syscall.c
===>  Configuring for rsync-3.0.9_3

Thanks, again.
 
Got it set up correctly and compiled a custom kernel with tmpfs(5) as you suggested.

Code:
root@:/var/tmp # df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada0p2     35G    689M     32G     2%    /
devfs          1.0k    1.0k      0B   100%    /dev
/dev/ada0p4    9.7G    171M    8.7G     2%    /var
tmpfs          5.3G    4.0k    5.3G     0%    /tmp
/dev/ada0p6     27G    4.6G     20G    18%    /usr

Nice!
 
Back
Top