Changing extra Swap space to /usr

I recently just installed a proxy server and its running great. However when I created the partitions and labels i messed up and created two swap partitions.

1. 4096M --- THE CORRECT SWAP I WANTED
2. 20480M --- THE PARTITION I WANTED AS /usr

My question is:
Is there a way to remove the 20480M swap and make /usr without rebuilding the box?

Please be kind, as you can probably tell, I am fairly new to FreeBSD.

Thanks in advace! :beergrin
Sean
 
Yes it is. I was hoping I could tar the entire /usr located on root and after /usr is created properly just untar it.

Thanks for the reply!
Sean
 
Let's see. If the partition you want to stop using as swap is ad0s1d, something like this might work:
Code:
swapoff ad0s1d
newfs /dev/ad0s1d
mount /dev/ad0s1d /mnt
cd /usr
pax -r -w * /mnt/
Then change /etc/fstab to mount it as /usr instead of swap, something like
Code:
/dev/ad0s1d             /usr            ufs     rw              2       2

That should be it.

If you want to reclaim the space, I'd suggest that you first test rebooting to see if this works, then if it does, go singleuser, umount /usr, and empty the old /usr.
 
It's also possible to use a single file as swapspace.

make a file of 500 MB filled with zero's:
# dd if=/dev/zero of=swapfile.swp bs=1m count=500

create a virtual disk device with swapfile.swp as storage space:
# mdconfig -a -t vnode -f swapfile.swp -u 10

enable your swap space:
# swapon /dev/md10
 
The good thing about a swap partition is that it's not a file system. It's "unused space", so the OS just writes bytes to it, keeping a sector map in memory. No directories, no vnode locking, no vfs, no nothing.
When using a file-backed swap, you get rid of these advantages. For desktop use, it's not such a biggy, but for servers, when the OS needs to swap cause of a peak load, you don't want extra slow-downs as it has the potential to snowball.
 
OK. I must have done something wrong. After I changed fstab, none of my commands worked anymore. The /usr directory was empty. I was under the gun so I just rebuilt the thing.

If I have time I will try to recreate this in my lab and post my results.

Thanks to all that helped!
:beergrin
 
Ah, right - "-p e" does seem essential. I was writing from a windows machine, but should have looked at the online man pages.
 
Back
Top