{"id":19989664,"url":"https://github.com/wavesoft/cernvm-fork","last_synced_at":"2025-10-24T15:31:46.858Z","repository":{"id":26020882,"uuid":"29463665","full_name":"wavesoft/cernvm-fork","owner":"wavesoft","description":"A small utility that can \"fork\" the current uCernVM environment into a linux container","archived":false,"fork":false,"pushed_at":"2015-10-26T13:31:48.000Z","size":247,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T20:02:11.474Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wavesoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-19T09:37:48.000Z","updated_at":"2015-02-09T15:10:29.000Z","dependencies_parsed_at":"2022-08-24T14:19:29.218Z","dependency_job_id":null,"html_url":"https://github.com/wavesoft/cernvm-fork","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fcernvm-fork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fcernvm-fork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fcernvm-fork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2Fcernvm-fork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavesoft","download_url":"https://codeload.github.com/wavesoft/cernvm-fork/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241430321,"owners_count":19961635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:48:53.168Z","updated_at":"2025-10-08T00:32:23.296Z","avatar_url":"https://github.com/wavesoft.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# CernVM Environment Fork\n\nThis utility allows _forking_ of a booted micro-CernVM OS into a new linux container.\n\nThis can be very useful when you want to _isolate_ the execution of a particular application that is already fully compatible with a CernVM/RHEL6 distribution.\n\n# Usage\n\nThe `cernvm-fork ` utility accepts the following command-line parameters:\n\n    CernVM Environment Fork Script\n    Usage:\n    \n     cernvm-fork \u003cname\u003e [-n|--new] [-c|--nonic] [-d|--daemon] [-f|--fast]\n                        [-r|--run=\u003cscript\u003e] [-t|--tty=\u003cnumber\u003e]\n                        [-a|--admin=\u003cusername\u003e[:\u003cpassword\u003e]]\n                        [--init=\u003cscript\u003e] [--cvmfs=\u003crepos\u003e]\n                        [--log=\u003cfile\u003e] [--ip=\u003caddress\u003e] [-o \u003clxc-option\u003e]\n     cernvm-fork \u003cname\u003e -C [-t|--tty=\u003cnumber\u003e]\n     cernvm-fork \u003cname\u003e -D\n\nWhen creating a new CernVM fork, the following parameters are accepted:\n\n * `-n` or `--new` : Instructs cernvm-fork not to clone the environment, but rather to start with a clean uCernVM boot.\n * `-d` or `--daemon` : Instructs cernvm-fork not to attach a console after the container is created, but rather to let it run in the background.\n * `-c` or `--nonic` : Do not attach a network card.\n * `-f` or `--fast` : Don't use `/sbin/init` script for system boot, but rather a fast alternative script that just prepares network and mountpoints.\n * `-r \u003cscript\u003e` or `--run \u003cscript\u003e` : Run the specified script after the container is booted. This file can either point to a location in the host filesystem **OR** in the guest filesystem. The script will first check the guest filesystem and if the file does not exist, it will copy it from the host filesystem.\n * `-a \u003cuser\u003e[:\u003cpassword\u003e]` or `--admin \u003cuser\u003e[:\u003cpassword\u003e]` : Create the given user with sudo privileges. If a password is not specified, you will be prompted to enter it right before the container is booted.\n * `-t` or `--tty` : The TTY you want the console to attach to. This flag has no effect if `-d` was not specified.\n * `--init=\u003cscript\u003e` : The custom init script to use for booting the OS. This defaults to `/sbin/init`.\n * `--ip=\u003caddress\u003e` : The IP address to assign to the container. If this flag is not specified, a random new IP will be assigned.\n * `--log=\u003cfile\u003e` : The file where to write the debug log messages.\n * `--cvmfs=\u003crepository\u003e[,\u003crepository\u003e...]` : The names of the CVMFS repositories to bind-mount from the host OS to the guest OS before booting.\n * `-o \u003cconfig\u003e` defines additional arbitrary lxc-container configuration parameters to append in the config file.\n\nThe `cernvm-fork` utility also accepts the following commands:\n\n * `-C` : Connect to the console of the specified linux container.\n * `-D` : Destroy the specified forked linux container.\n\n# Examples\n\n## Cloning\n\nYou can snapshot the current state of the operating system and start a new fork of it using the following command:\n\n```sh\ncernvm-fork fork01\n```\n\n## Start from scratch\n\nYou can start a new fork of the same uCernVM version using the `--new` flag. In order to log-into the new system you should also define an admin user:\n\n```sh\ncernvm-fork fork02 --new --admin admin:s3cr3t\n```\n\nThe admin user has sudo privileges.\n\n## Lightweight isolated environment\n\nYou can start an application in an isolated environment with the minimum memory and disk footprint using pre-mounted CVMFS repositories and fast-booting.\n\nFor example, let's say that you want to run the application `/cvmfs/sft.cern.ch/my_app` in an isolated environment:\n\n```sh\ncernvm-fork fork03 --new --fast --cvmfs=sft.cern.ch --run=/cvmfs/sft.cern.ch/my_app\n```\n\n# Environment Preparation\n\nIn order to be able to run the `cernvm-fork` utility you will have to do the following:\n\n## 1. Install LXC tools\n\nYou can find pre-built binaries of the lxc-tools in the EPEL repository:\n\n```sh\n# Add EPEL repository\nrpm -ivh http://mirror.nl.leaseweb.net/epel/6/x86_64/epel-release-6-8.noarch.rpm\n\n# Install LXC tools\nyum -y install lxc lxc-libs lxc-templates bridge-utils libcgroup\n```\n\n**NOTE:** _The following steps are no longer required. The fork utility will try to automatically start the required services and create the missing files._\n\n## 2. Add a 'none' template\n\nWe are not using an LXC template, because of some limitations it imposes (namely it isolates changes in the filesystem and therefore we cannot mount CVMFS repositories):\n\n```sh\n# Create a dummy, 'none' template bootstrap script\ntouch /usr/share/lxc/templates/lxc-none\nchmod +x /usr/share/lxc/templates/lxc-none\n```\n\n## 3. Enable CGroups\n\nMake sure the `cgconfig` and `cgred` services are running:\n    \n```sh\n# Enable CGroups\nservice cgconfig start\nservice cgred start\nchkconfig --level 345 cgconfig on\nchkconfig --level 345 cgred on\n```\n\n## 4. Create a network bridge:\n\nWe are going to use a bridge called `lxcbr0` with subnet `192.168.25.0/24`:\n\n```sh\n# Create bridge\ncat \u003c\u003cEOF \u003e /etc/sysconfig/network-scripts/ifcfg-lxcbr0\nDEVICE=\"lxcbr0\"\nTYPE=\"Bridge\"\nBOOTPROTO=\"static\"\nIPADDR=\"192.168.25.1\"\nNETMASK=\"255.255.255.0\"\nEOF\n    \n# Start it\nifup lxcbr0\n```\n\n## 5. Enable IP forwarding:\n\nWe need NAT-based IP forwarding in order to enable network inside the guest:\n\n```sh\n# Enable masquerading on NAT\niptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE\nservice iptables save\n\n# Enable ip forwarding\nsed -i -E 's/^#?(net.ipv4.ip_forward)(.*)$/\\1 = 1/' /etc/sysctl.conf\nsysctl -p\n```\n\n# Technical Information\n\nThis utility uses the low-level Linux Container Utilities (lxc-utils) in order to start a new isolated linux container. For the root filesystem, it uses the same techniques with micro-CernVM in order to create a RW overlay on top of the RO operating system files fetched from CVMFS.\n\nThis utility is usable **only** inside a micro-CernVM environment, since it exploits the existing mouts and cache files used by micro-boot phase. \n\nWhen instructed to *Fork*, the utility will copy the current uCernVM RW cache, effectively 'cloning' the current state. It will then modify the network configuration in order to give it another IP.\n\nWhen instructed to perform a *Clean boot*, the utility will follow the same procedure, but start with a clean RW cache.\n\n# Incomplete features\n\n * The `--cvmfs` parameter even though it's properly functioning, should not be used if you are booting uCernVM with the default init process. That's because the guest OS will mount autofs on `/cvmfs` and will handle automatic mounting of any CVMFS repository as commonly used in CernVM. This parameter might be useful if you are using your own, lightweight init process. (The utility must be able to detect and disable the CVMFS bind-mount feature when using the default init).\n * If you start the script as a daemon and the guest OS powers off, the scratch folder and the linux container will remain until explicitly deleted with `cernvm-fork \u003cname\u003e -D`.\n\n# License\n\nCernVM Environment Fork Utility\n\nCopyright (C) 2014-2015  Ioannis Charalampidis, PH-SFT, CERN\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesoft%2Fcernvm-fork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavesoft%2Fcernvm-fork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesoft%2Fcernvm-fork/lists"}