I have three different linux partitions and need to create an alias...

Posted on 2005-05-06
Last Modified: 2010-04-20
For some reason, the person who allocated drives on my current server put everything on one drive with the least amount of available space (500MB).

There are two other partitions which each have over 30 gigs available.  However, the mysql database and files are installed on the 500MB partition.

My question is - is there a way to swap out space or even better, to create an alias for the mysql data, which I could then store and run from one of the other partitions with the extra space?

Question by:foreverdita
    LVL 40

    Expert Comment

    You can shutdown MySQL, move the data to another partition, and change the MySQL configuration to point to that location. Where the MySQL config file is located depends on what Linux you are running and whether you are using the Linux vendor's MySQL or one installed from else where. Could you elaborate?

    Author Comment

    OK, here is some better info on this problem:

    My partitions are as follows:

    Filesystem    Type    Size  Used Avail Use% Mounted on
    /dev/sdc2     ext3     15G   13G  1.5G  90% /
    /dev/sdc1     ext3     99M   13M   81M  14% /boot
    /dev/sda1     ext3    135G   92M  128G   1% /data0
    /dev/sdb1     ext3    135G   92M  128G   1% /data1
    none         tmpfs    2.0G     0  2.0G   0% /dev/shm
    /dev/sdc6     ext3     46G   84M   43G   1% /home
    /dev/sdc3     ext3    9.7G   55M  9.1G   1% /opt

    Right now, everything is under the /dev/sdc2 partition, including mysql.  MYSQL is the Linux Vendor's installation.

    I need to know how I can take advantage of the two partitions that each have 135G available.  I am running out of space on the / partition which is 90% used.

    LVL 87

    Accepted Solution

    First make sure the partition you want to use for the moved data mounts automatically on startup (you might have to edit the /etc/fstab file if it doesn't startup automatically).

    You will have folder in your root (/), like /var /usr etc. Now you can just copy the folder you want to move to one of your 135G drives (data0). Now rename the source folder you have copied to something like /varold. Now I allways use Midnight Commander (mc) to do that, because I can't remember the exact commands. Midnight Commander is usually already installed or at least included on the CDs of most distro's, so you just use your distro's installation tools to install it. You start it in a terminal by entering mc. One pane of MC is in the root (/). With the other pane I select the copied folder (/data0/var), and I make sure this is the active pane. Now I enter MC's menu, select File, then SymLink. You will now get a question similar to this:

    > Existing Filename (Filename SymLink will point to):

    > /data/var

    > Symbolic Link Filename:

    Here I make sure the filename will be called the way the original folder was called:


    That's it. Now you can test the system and if everything works OK, you can remove the renamed folder (/varold).

    The above should be done as root.

    In MC such "SymLinked" folders will have ~, so the above var will look like this:



    Author Comment

    OK, even though I am working remotely, I was able to bring up the mc program you wrote about.

    Now.  Starting from point #1, how can I tell if my other partition (sda1) mounts on startup?


    Author Comment


    Also, will this work for everything under the /var folder?  mysql databases and the entire website is under /var right now on the partition that is running out of space.

    Author Comment

    This is my current fstab file:

    # This file is edited by fstab-sync - see 'man fstab-sync' for details
    LABEL=/                 /                       ext3    defaults        1 1
    LABEL=/boot             /boot                   ext3    defaults        1 2
    LABEL=/data0            /data0                  ext3    defaults        1 2
    LABEL=/data1            /data1                  ext3    defaults        1 2
    none                    /dev/pts                devpts  gid=5,mode=620  0 0
    none                    /dev/shm                tmpfs   defaults        0 0
    LABEL=/home             /home                   ext3    defaults        1 2
    LABEL=/opt              /opt                    ext3    defaults        1 2
    none                    /proc                   proc    defaults        0 0
    none                    /sys                    sysfs   defaults        0 0
    LABEL=SWAP-sdc5         swap                    swap    defaults        0 0
    /dev/hdc                /media/cdrecorder       auto    pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
    /dev/fd0                /media/floppy           auto    pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0

    Author Comment

    So if I want to move my entire var file from the label / to the label /data0, should that work?

    LVL 87

    Expert Comment

    After you have booted your system, enter mount and you should see a list of all currently mounted devices. You should see /dev/sda1 in the list.

    In my example above I have selected the /var folder, because I assumed the MySQL database would be there, and in the above example I copied all that is in this folder to /data0 (dev/sda1). So yes, everything in the var folder would afterwards be on sda1. You can also use mc for copying the folder, it is done similarly like creating the symlink. Just select the /data0 folder as the destination (one of the window panes) and select /var in the other window pane, then press "F5" and the copying will start. I use it for almost all tasks.
    LVL 87

    Expert Comment

    I have just looked at your fstab file, and the "defaults" in that system is set to automount, so it should be OK.

    Author Comment

    You are absolutely brilliant, and I thank you so much.  I have started the copying process, which should take all night since there is so much stuff on there, but your advice is very clear, so hopefully I won't have any problems.  I pretty much understand your directions, so thanks for saving my a##!

    : )

    *big hugs*
    LVL 87

    Expert Comment

    No problem, thanks too.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    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…

    794 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

    18 Experts available now in Live!

    Get 1:1 Help Now