Mysql under jailkit - Invalid cross-device link when linking mysqld.sock

Discussion in 'General' started by SupuS, Jan 24, 2011.

  1. SupuS

    SupuS Member HowtoForge Supporter

    Hi,

    I need enable mysql command for chrooted shell accounts on Ubuntu 10.04 server.

    I put /usr/bin/mysql to jailkit chrooted applications section under server configuration. mysql command were sucessfully added to chroot but without creating mysql socket. Here is part of /var/log/ispconfig/cron.log:

    Code:
    ln: creating hard link `/var/www/clients/client1/web2/var/run/mysqld/mysqld.sock' => `/var/run/mysqld/mysqld.sock': Invalid cross-device link
    As described on this thread the reason should be bad harddisk layout. On server are root, tmp and boot partitions but ubuntu adds tmpfs partition for /var/run.

    Here is output of mount:

    Code:
    rootfs on / type rootfs (rw)
    none on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
    none on /proc type proc (rw,nosuid,nodev,noexec,relatime)
    none on /dev type devtmpfs (rw,relatime,size=4091184k,nr_inodes=1022796,mode=755)
    none on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
    /dev/disk/by-uuid/501c4db5-c8fe-4462-9aa3-e3fd3a19926a on / type ext4 (rw,relatime,errors=remount-ro,barrier=1,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group)
    none on /sys/fs/fuse/connections type fusectl (rw,relatime)
    none on /sys/kernel/debug type debugfs (rw,relatime)
    none on /sys/kernel/security type securityfs (rw,relatime)
    none on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
    none on /var/run type tmpfs (rw,nosuid,relatime,mode=755)
    none on /var/lock type tmpfs (rw,nosuid,nodev,noexec,relatime)
    none on /lib/init/rw type tmpfs (rw,nosuid,relatime,mode=755)
    /dev/md3 on /tmp type ext4 (rw,nosuid,noexec,relatime,barrier=1,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group)
    
    Is some solution for creating mysql socket in chrooted environment in ubuntu 10.04?

    Any help will appreciated.

    SupuS
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Creating a hrd link is not possible from one partition to another. But maybe you can use the mount command to mount /var/run into the jail.
     
  3. SupuS

    SupuS Member HowtoForge Supporter

    Thank you till. It works. I mounted socket by:

    Code:
    mount --bind /var/run/mysqld /var/www/clients/clientX/webX/var/run/mysqld/
    this situation should be covered directly by ISPConfig because after reboot setting will lost.

    SupuS
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig has no daemon or start script which get started at boot time where you could add that. So it might be the best way if you create your own script for that.
     
  5. zion

    zion Member

    I'v created a new custom plugin which does two things when a new chroot is created:
    1. mount --bind /var/run/mysqld /home/clients/clientx/webxx/var/run/mysqld/
    2. add a new line to /etc/fstab for /var/run/mysqld

    My problem is when I delete a chroot site with ispconfig, because I have to umount /var/run/mysqld at first and I can delete files only after umount.

    So my question is:
    Can I create a delete function in my custom plugin which runs _before_ the main shelluser_jailkit_plugin.inc.php plugin? Is there a weight or something like that?

    Or can you recommend me any other way to handle mysql in jailkit chroot?
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    yes.Just ensure that the name of the plugin that contains this fubnction is first in alphabet.
     

Share This Page