To enable users manipulate partitions from inside of the virtual server, I wrote LLS (LXC+LVM+Snapshots) scripts.
LXC+LVM+Snapshots = LLS
LLS system is set of scripts that enable LVM partitions and snapshots to be managed from inside of LXC vservers. It is safer to allow developers to use the scripts, instead of giving them superuser access to the physical machine.
Architecture
The LLS scripts consist from two parts. The daemon script on the host and client scripts on the vservers. The clients communicate with the server over a named pipe in a shared (bind mount) directory /lls (lls - LXC+LVM+Snapshots). The /lls directory is actually a small partition that contains configuration file, the shell scripts and the named pipe used for communcation.
The daemon script does all the necessary low-level manipulations, both on the physical machine and on the LXC vservers.
UsageThe daemon script does all the necessary low-level manipulations, both on the physical machine and on the LXC vservers.
Each LLS vserver has /lls partition mounted. To preserve mounts across reboots, the /etc/rc.local file runs /lls/tools/lls_mount_on_boot.sh script.
There are several client scripts the /lls/tools partition that do various operations:
script name | Operation |
---|---|
lls_create_partition.sh | Create a partition |
lls_create_snapshot.sh | Create an LVM snapshot from an existing LVM partition |
lls_delete_partition.sh | Delete an LVM partition or snapshot |
lls_list_partitions.sh | List available LLS partitions and refresh /dev/mf directory |
lls_mount_on_boot.sh | Mount LLS partitions using configuration in the /etc/fstab file |
The scripts show informative Usage information when ran without arguments.
Developers are expected to operate the scripts by themselves. They are also expected to maintain the /etc/fstab file for mounts they want to survive reboot of their vserver. Unmounted snapshot is assumed to be not necessary anymore and might be deleted at any time.
Further work
As the LLS system is used, more features are asked by developers and system administrators. Here are some of them:
- Track unused (unmounted) LVM snapshots and delete them automatically
- Track disk space used/required by LVM snapshot and grow it automatically. Send email to sysadmin each time this happen.
- Have a way to enable/disable visibility of a LLS partition. This is useful while the LLS partition is under construction.
- Have a way to mark an LLS partition as non-mountable or mountable in read-only mode.
Download