Difference between revisions of "Vserver"
(Created page with "=Creating a new guest= vserver sandbox build --context 100 --hostname sandbox --interface eth0:192.168.0.100/24 --initstyle gentoo -m template -- -d gentoo -t /vservers/stage3...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Creating a new guest= | =Creating a new guest= | ||
+ | Deploy the template: | ||
+ | <source lang="sh"> | ||
vserver sandbox build --context 100 --hostname sandbox --interface eth0:192.168.0.100/24 --initstyle gentoo -m template -- -d gentoo -t /vservers/stage3-amd64-20160317.tar.bz2 | vserver sandbox build --context 100 --hostname sandbox --interface eth0:192.168.0.100/24 --initstyle gentoo -m template -- -d gentoo -t /vservers/stage3-amd64-20160317.tar.bz2 | ||
+ | </source> | ||
+ | Install a service: | ||
+ | <source lang="sh"> | ||
+ | ROOT=/vservers/sandbox emerge -pv syslog-ng | ||
+ | chroot /vservers/sandbox | ||
+ | rc-update add syslog-ng default | ||
+ | </source> | ||
+ | Check vserver config files: | ||
+ | * /etc/vservers/sandbox/fstab | ||
+ | If you want autostart: | ||
+ | <source lang="sh"> | ||
+ | echo default > /etc/vservers/git/apps/init/mark | ||
+ | </source> | ||
+ | Start the guest: | ||
+ | <source lang="sh"> | ||
+ | vserver sandbox start | ||
+ | </source> | ||
+ | Check config files: | ||
+ | * /etc/portage/make.conf | ||
+ | |||
+ | =Bind mount a directory in a running guest= | ||
+ | source: http://linux-vserver.org/Frequently_Asked_Questions#How_do_I_bind_mount_a_host_directory_inside_a_running_guest.3F | ||
+ | |||
+ | Let's enter the management namespace of the guest (that's what -i 0 is for): | ||
+ | |||
+ | <source lang="sh"> | ||
+ | vnamespace -i 0 -e <guest-xid> -- /bin/bash | ||
+ | </source> | ||
+ | |||
+ | Now you have access to all host devices; mount the device that contains your directory wherever you want, but you may prefer to mount it in the same location you used on the host. (Note, though, that it's not even necessary for the device to be mounted in the host namespace at all.) | ||
+ | |||
+ | It's likely best to use mount -n lest your host /etc/mtab get polluted with mounts from other namespaces. | ||
+ | |||
+ | <source lang="sh"> | ||
+ | mount -n /dev/sr0 /media/cdrom | ||
+ | exit | ||
+ | </source> | ||
+ | |||
+ | We're now back in the host namespace. vmount can now be used to bind mount /media/cdrom/foo inside a running guest (in this example, under /foo inside the vserver root): | ||
+ | <source lang="sh"> | ||
+ | vmount guestname -- --bind /media/cdrom/foo /mnt/foo | ||
+ | </source> | ||
+ | |||
+ | =Resizing tmpfs in running guest= | ||
+ | <source lang="sh"> | ||
+ | vnamespace -e 11 chroot /data/vservers/sandbox mount -t tmpfs -o remount,size=4g none /tmp | ||
+ | </source> |
Latest revision as of 11:21, 7 May 2016
Creating a new guest
Deploy the template:
vserver sandbox build --context 100 --hostname sandbox --interface eth0:192.168.0.100/24 --initstyle gentoo -m template -- -d gentoo -t /vservers/stage3-amd64-20160317.tar.bz2
Install a service:
ROOT=/vservers/sandbox emerge -pv syslog-ng
chroot /vservers/sandbox
rc-update add syslog-ng default
Check vserver config files:
- /etc/vservers/sandbox/fstab
If you want autostart:
echo default > /etc/vservers/git/apps/init/mark
Start the guest:
vserver sandbox start
Check config files:
- /etc/portage/make.conf
Bind mount a directory in a running guest
Let's enter the management namespace of the guest (that's what -i 0 is for):
vnamespace -i 0 -e <guest-xid> -- /bin/bash
Now you have access to all host devices; mount the device that contains your directory wherever you want, but you may prefer to mount it in the same location you used on the host. (Note, though, that it's not even necessary for the device to be mounted in the host namespace at all.)
It's likely best to use mount -n lest your host /etc/mtab get polluted with mounts from other namespaces.
mount -n /dev/sr0 /media/cdrom
exit
We're now back in the host namespace. vmount can now be used to bind mount /media/cdrom/foo inside a running guest (in this example, under /foo inside the vserver root):
vmount guestname -- --bind /media/cdrom/foo /mnt/foo
Resizing tmpfs in running guest
vnamespace -e 11 chroot /data/vservers/sandbox mount -t tmpfs -o remount,size=4g none /tmp