What's the best way to swap the mount points of two partitions?

On my Mandrake 10 server I have /home pointing to a big partition that's sitting unused and a much smaller /var that's almost full. I want to basically swap the mount points so the /home is the smaller partition and the /var is the bigger one. What's the best procedure? (No gui available)
LVL 19
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

All of this should be done as root in single user mode. First make a temporary mount point for that /var

mkdir /tmpvar

Now swap the mount points

mount --bind /var /tmpvar
mount --bind /home /var
mount --bind /tmpvar /home

Now your /home is bound to /var and vice versa. Now move all the stuff to right directories. I'd probably try something like this:

tar zcvf /var/home.tar.gz /var/*
remove every homedir from /var
mv /home/* /var
mv /var/home.tar.gz /home
cd /home ; tar zxvf home.tar.gz

Then edit your /ect/fstab to match the new setup.

Try not to get confused with /var and /home. I know I did. Thankfully all this was just a mental rehearse for me.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
billmercerAuthor Commented:
Terrific answer, gave me exactly what I needed. Thank you very much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.