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

Posted on 2004-11-19
Last Modified: 2010-04-20
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)
Question by:billmercer
    LVL 3

    Accepted Solution

    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.
    LVL 19

    Author Comment

    Terrific answer, gave me exactly what I needed. Thank you very much!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now