Linux Container File System Step

  

Linux Container referred to as LXC, compared with traditional virtualization technology, it has the advantages of low performance loss, no instruction level simulation, etc., and can also make file system, ie rootfs, the following small I will introduce you to the steps of making a file system for Linux Container.

First, create a file system mount table

1, ready directory

mkdir /lxc

then enter /lxc directory, Create a directory for the root file system

mkdir rootfs

Enter the /lxc/rootfs directory and create additional directories

1 mkdir bin dev etc lib lib64 proc sbin sys usr var< Br>

2, create a mount table

In the /lxc directory, create a new file fstab, edit the content 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 proc defaults 0 0

/sys /lxc/rootfs/sys sysfs defaults 0 0

The effect that the host operating system /bin /sbin /lib /etc directory like directory under corresponding loading /lxc /rootfs in.

Second, start lxc

1, edit lxc configuration file

Edit config file, the content is as follows

lxc.utsname = host_name

lxc.rootfs = /lxc/rootfs

lxc.mount = /lxc/fstab

2, start lxc, execute bash command

lxc-execute -n lxc1 - f config bash

This starts a Container named lxc1. Executing bash is equivalent to entering the Container. If the output is not normal at the terminal, use the command reset.

3, view lxc internal file system

bash-4.1# ls

bin data dev etc lib lib64 proc sbin sys usr var

We found only Can operate inside /lxc/rootfs.

The above is the introduction of the steps of the Linux Container file system. You need to create the file system and the mount table first, and then start the LXC and editor configuration files to implement the file system.

Copyright © Windows knowledge All Rights Reserved