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

Posted on 2005-05-06
Medium Priority
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
  • 6
  • 4
LVL 40

Expert Comment

ID: 13948926
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

ID: 13949444
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 88

Accepted Solution

rindi earned 2000 total points
ID: 13949540
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:


Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.


Author Comment

ID: 13949558
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

ID: 13949566

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

ID: 13949571
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

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

LVL 88

Expert Comment

ID: 13949589
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 88

Expert Comment

ID: 13949594
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

ID: 13949597
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 88

Expert Comment

ID: 13949601
No problem, thanks too.

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

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.

Join & Write a Comment

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Virtualization software lets you run different versions of Windows, Ubuntu Linux and other versions of Linux all at the same time, rather than running each one directly from your computer's hard drive.
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.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

624 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