Create an LXC File System

Source: Internet
Author: User

Linux Container is Google's open-source lightweight virtualization solution, and is a resource Container, LXC for short. LXC can create its own file system, namely rootfs.

I. Create a file system and a mount table
1. Prepare the Directory
Mkdir/lxc

Then go to the/lxc directory and create the root file system directory.
Mkdir rootfs

Go to the/lxc/rootfs directory and create other directories.
1 mkdir bin dev etc lib lib64 proc sbin sys usr var

2. Create a mount table
In the/lxc directory, create a new file fstab and edit the file as follows:
/Bin/lxc/rootfs/bin none ro, bind 0 0
/Sbin/lxc/rootfs/sbin none ro, bind 0 0
/Lib/lxc/rootfs/lib none ro, bind 0 0
/Lib64/lxc/rootfs/lib64 none ro, bind 0 0
/Etc/lxc/rootfs/etc none ro, bind 0 0
/Usr/lxc/rootfs/usr none ro, bind 0 0
/Dev/lxc/rootfs/dev none rw, bind 0 0
/Dev/pts/lxc/rootfs/dev/pts none rw, bind 0 0
/Proc/lxc/rootfs/proc defaults 0 0
/Sys/lxc/rootfs/sys sysfs defaults 0 0

The general idea is to mount the/bin/sbin/lib/etc directory of the host operating system to the corresponding directory under/lxc/rootfs.

Ii. Start lxc
1. Edit the lxc configuration file
Edit the config file as follows:
Lxc. utsname = host_name
Lxc. rootfs =/lxc/rootfs
Lxc. mount =/lxc/fstab

2. Start lxc and execute bash commands.
Lxc-execute-n lxc1-f config bash

In this way, a lxiner named lxc1 is started. Executing bash is equivalent to entering the Container. If the output on the terminal is abnormal, use the reset command.
3. view the lxc internal File System
Bash-4.1 # ls
Bin data dev etc lib lib64 proc sbin sys usr var

We found that operations can only be performed within/lxc/rootfs.

Linux container technology-LXC-related technical knowledge

Linux container technology-Analysis of the execution process of creating a virtual machine in LXC

Use shell scripts to monitor applications in the LXC application container

Cgroup and LXC (Linux container) Installation Details (CentOS 6.2) System

Linux container Virtual Technology LXC Concise Manual

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.