OpenVZ Forum


Home » General » Support » *SOLVED* Shared vps files
*SOLVED* Shared vps files [message #6190] Mon, 11 September 2006 14:14 Go to next message
dagr is currently offline  dagr
Messages: 83
Registered: February 2006
Member
I know that in vserver project there is such thing like sharing files between different vps. Say you need common dirs like /bin /sbin in every vps - to save disk space you can make it sharable. Default centos vps takes 300 Mb which is not good in case of 100 VPS. Is there similar thing in openvz ?

[Updated on: Mon, 18 September 2006 07:33] by Moderator

Report message to a moderator

Re: Shared vps files [message #6191 is a reply to message #6190] Mon, 11 September 2006 14:56 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
This is possible with some tricks. This is what I've just done:

[myhwn]# vzctl create 30
Creating VPS private area: /vz/private/30
Performing postcreate actions
VPS private area was created

[root@dhcp0-174 ~]# vzctl create 31
Creating VPS private area: /vz/private/31
Performing postcreate actions
VPS private area was created

[root@dhcp0-174 ~]# rm -rf /vz/private/31/sbin/*

[root@dhcp0-174 ~]# cat > /etc/vz/conf/31.mount
#! /bin/bash
mount --bind /vz/private/30/sbin /vz/root/31/sbin

[root@dhcp0-174 ~]# chmod +x /etc/vz/conf/31.mount

[root@dhcp0-174 ~]# cat > /etc/vz/conf/31.umount
#! /bin/bash
umount /vz/root/31/sbin

[root@dhcp0-174 ~]# chmod +x /etc/vz/conf/31.umount


After that VE 31 should use the same /sbin, that uses VE30. Let's check, does it work:

[root@dhcp0-174 ~]# vzctl start 30
Starting VPS ...
VPS is mounted
Setting CPU units: 1000
VPS start in progress...
[root@dhcp0-174 ~]# vzctl start 31
Starting VPS ...
vzquota : (warning) Quota is running for id 31 already
VPS is mounted
Setting CPU units: 1000
VPS start in progress...
[root@dhcp0-174 ~]# vzctl enter 30
entered into VPS 30

-bash-3.00# ls /sbin/
MAKEDEV         clock        ether-wake   halt       insmod.static     kmodule      mkfs.ext2    netreport            poweroff     route       sulogin
addpart         consoletype  fdisk        hwclock    install-info      ldconfig     mkfs.ext3    nologin              ppp-watch    rtmon       swapoff
agetty          ctrlaltdel   findfs       ifcfg      ip                logsave      mkswap       pam_console_apply    pwdb_chkpwd  runlevel    swapon
arp             debugfs      fsck         ifconfig   ipmaddr           losetup      modprobe     pam_tally            quotacheck   runuser     sysctl
arping          delpart      fsck.cramfs  ifdown     iptables          lsmod        mount.cifs   pam_timestamp_check  quotaoff     service     syslogd
badblocks       dumpe2fs     fsck.ext2    ifenslave  iptables-restore  mii-diag     mount.smb    partx                quotaon      setsysfont  tc
blkid           e2fsck       fsck.ext3    ifup       iptables-save     mii-tool     mount.smbfs  pidof                rdisc        sfdisk      telinit
blockdev        e2image      fuser        init       iptunnel          mke2fs       nameif       pivot_root           reboot       shutdown    tune2fs
change_console  e2label      genhostid    initlog    killall5          mkfs         nash         plipconfig           rescuept     slattach    unix_chkpwd
chkconfig       elvtune      getkey       insmod     klogd             mkfs.cramfs  netplugd     portmap              resize2fs    sln

-bash-3.00# echo "qwe" > /sbin/check

-bash-3.00# exit
logout
exited from VPS 30

[root@dhcp0-174 ~]# vzctl enter 31
entered into VPS 31

-bash-3.00# ls /sbin/
MAKEDEV         chkconfig    elvtune      getkey     insmod            klogd     mkfs.cramfs  netplugd             portmap      resize2fs   sln
addpart         clock        ether-wake   halt       insmod.static     kmodule   mkfs.ext2    netreport            poweroff     route       sulogin
agetty          consoletype  fdisk        hwclock    install-info      ldconfig  mkfs.ext3    nologin              ppp-watch    rtmon       swapoff
arp             ctrlaltdel   findfs       ifcfg      ip                logsave   mkswap       pam_console_apply    pwdb_chkpwd  runlevel    swapon
arping          debugfs      fsck         ifconfig   ipmaddr           losetup   modprobe     pam_tally            quotacheck   runuser     sysctl
badblocks       delpart      fsck.cramfs  ifdown     iptables          lsmod     mount.cifs   pam_timestamp_check  quotaoff     service     syslogd
blkid           dumpe2fs     fsck.ext2    ifenslave  iptables-restore  mii-diag  mount.smb    partx                quotaon      setsysfont  tc
blockdev        e2fsck       fsck.ext3    ifup       iptables-save     mii-tool  mount.smbfs  pidof                rdisc        sfdisk      telinit
change_console  e2image      fuser        init       iptunnel          mke2fs    nameif       pivot_root           reboot       shutdown    tune2fs
check           e2label      genhostid    initlog    killall5          mkfs      nash         plipconfig           rescuept     slattach    unix_chkpwd

-bash-3.00# cat /sbin/check
qwe

-bash-3.00# exit
logout
exited from VPS 31

[root@dhcp0-174 ~]# vzctl stop 30
Stopping VPS ...
VPS was stopped
vzquota : (error) Quota off syscall for id 30: Device or resource busy
vzquota off failed [3]

[root@dhcp0-174 ~]# vzctl stop 31
Stopping VPS ...
VPS was stopped
VPS is unmounted


So it works! =)
The only problem is OpenVZ disk quota. This feature obviously will not work properly with such configuration.
You should turn it off.

BTW, Virtuozzo uses vzfs instead simfs (this one is used in OpenVZ), and vzfs accomplish file sharing very effectively.


Re: Shared vps files [message #6278 is a reply to message #6191] Wed, 13 September 2006 09:01 Go to previous messageGo to next message
n00b_admin is currently offline  n00b_admin
Messages: 77
Registered: July 2006
Location: Romania
Member
Thanks for the tip !
I was looking for something like this !
Re: Shared vps files [message #6359 is a reply to message #6278] Thu, 14 September 2006 20:48 Go to previous messageGo to next message
szocske is currently offline  szocske
Messages: 35
Registered: September 2006
Member
Hi there!

Would hardlinking the directorys from the host work?
Re: Shared vps files [message #6438 is a reply to message #6359] Mon, 18 September 2006 06:12 Go to previous message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Smile Hardlinking of directories is not permited in linux:

[host] $ ln /usr/ /tmp/
ln: `/usr/': hard link not allowed for directory

Previous Topic: Moving on to FreeVPS or Xen
Next Topic: *SOLVED* Transfer Problem (32bit --> 64bit)
Goto Forum:
  


Current Time: Mon Jul 15 06:24:59 GMT 2024

Total time taken to generate the page: 0.02500 seconds