OpenVZ Forum


Home » General » Discussions » vpsautomount script
vpsautomount script [message #1060] Sun, 29 January 2006 06:42 Go to previous message
duswil is currently offline  duswil
Messages: 77
Registered: January 2006
Member
This script (attached) is a Perl script that will look at your VPS's .conf file to see if there is a specific set of options that request that specific locations on the host are mounted/bound to a specific location within the VPS itself.

The script is meant to be run on a cronjob.

# Automount any bindings for a VPS with mounting specified in its conf file
* * * * * /etc/sysconfig/vz-scripts/vpsautomount


In your VPS's .conf file, hand-edit it to add something like this:

CA_MOUNT_1_SRC="/mnt/hd/data"
CA_MOUNT_1_DEST="/mnt/data"
CA_MOUNT_2_SRC="/mnt/hd/snapshots"
CA_MOUNT_2_DEST="/mnt/snapshots"


What this will do is bind /mnt/hd/data (from the host) to /vz/root/<VEID>/mnt/data (within the VPS) to appear as /mnt/data to the processes running in the VPS. It'll do the same with the second pair. You can have an unlimited number of pairs. Just make sure the numbers match up. (1_SRC is paired with 2_DEST, 1231_SRC is paired with 1231_DEST) It doesn't matter if the numbers come in any order or if you skip over numbers.

This would be okay: (out of order and skipping ranges of numbers)

CA_MOUNT_927575_SRC="/mnt/hd/data"
CA_MOUNT_123_DEST="/mnt/snapshots"
CA_MOUNT_123_SRC="/mnt/hd/snapshots"
CA_MOUNT_927575_DEST="/mnt/data"


It will check to see if the VPS is running.

If it is running, it will check to see if the listed mount points are mounted. If they aren't, it will mount them. If they're already mounted, it'll leave them alone.

If it is not running, it will check to see if the listed mount points are mounted. If they are, it will unmount them. If they're not mounted, it'll just move on.

It's been working very nicely for my Samba installation that uses a shared data storage area (on a seperate drive that is shared between different VPSes). I've been using it for about a day now, so I don't claim to have it perfect. But hasn't failed once for me yet.

Let me know what you think and if there are any bugs or big problems that I haven't noticed.

ATTACHED:
vpsautomount (the script itself, it needs to be chmod 700, owned by root, and run as root (via cronjob or by hand))
1001.conf (the example .conf file, should be stored as /etc/sysconfig/vz-scripts/1001.conf)
  • Attachment: 1001.conf
    (Size: 1.63KB, Downloaded 518 times)
  • Attachment: vpsautomount
    (Size: 2.90KB, Downloaded 482 times)

[Updated on: Mon, 30 January 2006 04:50]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: banner use policy
Next Topic: hspc <-> openvz
Goto Forum:
  


Current Time: Sun Nov 17 13:33:47 GMT 2024

Total time taken to generate the page: 0.02861 seconds