Editing Physical to container
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 7: | Line 7: | ||
To make things easier you may like to first follow the basic instructions elsewhere and create a dummy container based on the same Linux distribution you want to migrate. That way you can take that dummy as a template and then copy to your new migrated container and modify. You can later discard this dummy. | To make things easier you may like to first follow the basic instructions elsewhere and create a dummy container based on the same Linux distribution you want to migrate. That way you can take that dummy as a template and then copy to your new migrated container and modify. You can later discard this dummy. | ||
− | |||
== Prepare a new “empty” container == | == Prepare a new “empty” container == | ||
For OpenVZ this would mean the following (assume you chose CT ID of 123): | For OpenVZ this would mean the following (assume you chose CT ID of 123): | ||
− | + | ||
mkdir /vz/root/123 /vz/private/123 | mkdir /vz/root/123 /vz/private/123 | ||
cat /etc/vz/conf/ve-basic.conf-sample > /etc/vz/conf/123.conf | cat /etc/vz/conf/ve-basic.conf-sample > /etc/vz/conf/123.conf | ||
− | |||
− | + | Hint: Now comes the dummy container handy mentioned above: Simply copy the xxx.conf file of the dummy to your new yyy.conf and modify it. | |
− | |||
− | |||
== Copying the data == | == Copying the data == | ||
Line 25: | Line 21: | ||
=== rsync === | === rsync === | ||
− | + | rsync example (run from the new HN): | |
− | + | rsync -arvpz --numeric-ids --exclude=/dev --exclude=/proc --exclude=/tmp -e ssh root@a.b.c.d:/ /vz/private/123/ | |
− | / | ||
− | / | ||
− | / | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | (Comment: I think one should add the "-H" option, so hardlinks will be preserved during sync. --[[Special:Contributions/194.95.66.21|194.95.66.21]] 12:05, 8 September 2011 (UTC)) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
'''Advantage:''' Your system doesn't really go down. | '''Advantage:''' Your system doesn't really go down. | ||
Line 81: | Line 58: | ||
You have to add <code>OSTEMPLATE=xxx</code> line to <code>/etc/vz/conf/123.conf</code> file, where <code>xxx</code> would be distribution name (like <code>debian-3.0</code>) for vzctl to be able to make changes specific for this distribution. | You have to add <code>OSTEMPLATE=xxx</code> line to <code>/etc/vz/conf/123.conf</code> file, where <code>xxx</code> would be distribution name (like <code>debian-3.0</code>) for vzctl to be able to make changes specific for this distribution. | ||
− | + | If you copied from the dummy container then this step is already accomplished. | |
=== IP address(es) === | === IP address(es) === | ||
Line 114: | Line 91: | ||
=== /etc/fstab === | === /etc/fstab === | ||
Since you do not have any real disk partitions in a container, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the lines for <code>/dev/pts</code>, <code>/proc</code>, <code>/sys</code> and such): | Since you do not have any real disk partitions in a container, /etc/fstab (or most part of it) is no longer needed. Empty it (excluding the lines for <code>/dev/pts</code>, <code>/proc</code>, <code>/sys</code> and such): | ||
− | + | ||
mv /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old | mv /vz/private/123/etc/fstab /vz/private/123/etc/fstab.old | ||
egrep '/dev/pts|/dev/shm|/proc|/sys' /vz/private/123/etc/fstab.old > /vz/private/123/etc/fstab | egrep '/dev/pts|/dev/shm|/proc|/sys' /vz/private/123/etc/fstab.old > /vz/private/123/etc/fstab | ||
− | |||
You can also mount a devpts in a running (but not fully functional) container: | You can also mount a devpts in a running (but not fully functional) container: | ||
vzctl exec 123 mount -t devpts none /dev/pts | vzctl exec 123 mount -t devpts none /dev/pts | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== /dev === | === /dev === | ||
− | |||
==== Introduction: static /dev ==== | ==== Introduction: static /dev ==== | ||
Line 145: | Line 111: | ||
Please pay attention to the access permissions of the device files being created: a default file mode for newly created files is affected by <code>umask</code> ([[w:umask]]). You can use --mode option for <code>mknod</code> to set the desired permissions. | Please pay attention to the access permissions of the device files being created: a default file mode for newly created files is affected by <code>umask</code> ([[w:umask]]). You can use --mode option for <code>mknod</code> to set the desired permissions. | ||
− | + | Hint: | |
+ | Now comes the dummy container handy mentioned above: Simply copy the entire /dev directory of the dummy to your new migrated container - worked in my case at least with Debian Etch. | ||
==== tty device nodes ==== | ==== tty device nodes ==== | ||
Line 186: | Line 153: | ||
===/proc=== | ===/proc=== | ||
− | |||
− | |||
Make sure the /proc directory exists: | Make sure the /proc directory exists: | ||
ls -la /vz/private/123/ | grep proc | ls -la /vz/private/123/ | grep proc | ||
Line 196: | Line 161: | ||
=== /etc/init.d services === | === /etc/init.d services === | ||
− | Some system services can (or in some cases should) be disabled | + | Some system services can (or in some cases should) be disabled. A few good candidates are: |
* acpid, amd (not needed) | * acpid, amd (not needed) | ||
Line 208: | Line 173: | ||
* lm_sensors (container does not have access to hardware sensors) | * lm_sensors (container does not have access to hardware sensors) | ||
* microcodectl (container can not update CPU microcode) | * microcodectl (container can not update CPU microcode) | ||
− | * netplugd (container does not have real Ethernet device | + | * netplugd (container does not have real Ethernet device) |
− | |||
− | |||
− | |||
− | |||
To see which services are enabled: | To see which services are enabled: | ||
Line 370: | Line 331: | ||
* RedHat Enterprise Linux 5 (rhel 5.6 - x86_64) 14:50, 18 November 2011 | * RedHat Enterprise Linux 5 (rhel 5.6 - x86_64) 14:50, 18 November 2011 | ||
* Debian 6.0.4 with DTC Hosting Contro Panel . 15:00, 14 May 2012 | * Debian 6.0.4 with DTC Hosting Contro Panel . 15:00, 14 May 2012 | ||
− | |||
− | |||
− |