9

I have a partition called sda4.

And I want to store the mysql data and xml files on that partition because the partition which mysql and domain are installed has little space.

So I'm planning to have two subfolders under the sda4, one for mysql and one for xml. Then I want to mount the subfolders respectively like this:

mount -t auto /dev/sda4/mysql /var/lib/mysql

mount -t auto /dev/sda4/xml /home/user/domain/public_html/xml

Is my plan doable? Can mount a partition to two mount points?

MadHatter
  • 78,442
  • 20
  • 178
  • 229
Pelang
  • 413
  • 5
  • 9
  • 15

1 Answers1

10

Short answer: no, you can't.

Longer answer: mount /dev/sda4 on one mount point, and do a soft link from the other mount point. Or mount it on a third, application-neutral point, and soft link from both the application points.

Edit: re a tutorial, try:

mount /dev/sda4 /mnt
ln -s /mnt/mysql /var/lib/mysql
ln -s /mnt/xml /home/user/domain/public_html/xml

NB: it is necessary that neither /var/lib/mysql or /home/user/domain/public_html/xml exist, or the ln -s will do something predictable but unexpected.

Edit 2: it's OK that that stuff exists, you'll need to move it to one side. Having mounted /dev/sda4 on /mnt (see above), try

mv /var/lib/mysql /var/lib/mysql.mark
mv /home/user/domain/public_html/xml /home/user/domain/public_html/xml.mark

(do the soft links, as above)

mv /var/lib/mysql.mark/* /var/lib/mysql
mv /home/user/domain/public_html/xml.mark/* /home/user/domain/public_html/xml

which should leave you with two empty .mark directories that can now be removed. Do not do this while the applications are running!

MadHatter
  • 78,442
  • 20
  • 178
  • 229
  • can you point me to a tutorial that have steps to accomplished your suggestion? Not familiar with soft links. Thanks. – Pelang Nov 22 '12 at 12:48
  • just a follow up do i need to create the subfolders(mysql and xml) under mnt? – Pelang Nov 22 '12 at 12:52
  • 2
    Assuming that `/dev/sda4` contains a brand-new, empty filesystem, then yes, you will need to create those subdirectories, and permission them appropriately. And if I may presume, because you're new on SF (welcome!), when you're happy with the answer to a question, local etiquette is that you accept that answer by clicking on the "tick" outline, which drives the reputation system for both you and the author of the answer. I apologise if you already know this. – MadHatter Nov 22 '12 at 12:52
  • the problem now is `/var/lib/mysql` and `/home/user/domain/public_html/xml` are existing because it is there upon installation of mysql and directadmin – Pelang Nov 22 '12 at 12:55
  • 1
    anoher thing I did was mount as bind `mount --bind /location/one /alias/mountpoint2` – Lord Loh. May 29 '21 at 00:23