Centos 6 Template
Config 必須要有的 settings
# 沒有它 poweroff lxc 後不應再 start
# lxc_conf - conf.c:lxc_create_tty:3822 - Read-only file system - failed to create pty #0
lxc.cap.drop = sys_admin
OS 修改:
[1]
/etc/sysconfig/init (本身有)
由
ACTIVE_CONSOLES=/dev/tty[1-6]
改成
ACTIVE_CONSOLES=/dev/tty[1-4]
Remark
會透過 /etc/init/tty.conf 及 /etc/init/start-ttys.conf 啟動 /sbin/mingetty
[2] 修改 /etc/rc.sysinit
1)
# /sbin/start_udev
否則有 Error:
/sbin/start_udev: line 260: /proc/sys/kernel/hotplug: Permission denied
2)
## Set the hostname. #update_boot_stage RChostname #action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
[3] Guest 的 mount
> /etc/fstab
否則會 boot fail
Logical Volume Management disabled at boot. Checking filesystems fsck.ext4: Unable to resolve 'UUID=...' [FAILED]
ln -s /proc/mounts /etc/mtab
否則 df 會
df: cannot read table of mounted file systems
[4]
touch /.nolvm # Logical Volume Management disabled at boot.
[5] /etc/init
mkdir /etc/_bak
mv /etc/init/kexec-disable.conf /etc/_bak
mv /etc/init/aliyun-service.conf /etc/_bak # 云的 Service
[6]
echo "Welcome to LXC" > /etc/motd
/etc/ssh/sshd_config
Banner none
crontab -l
# Daily sync time #3 4 * * * /usr/sbin/ntpdate time.google.com &> /dev/null
[7] 加入 console Device
/etc/securetty
加入
#### LXC lxc/console lxc/tty1 lxc/tty2 lxc/tty3 lxc/tty4
[8] Disable IPv6
/etc/modprobe.d/blacklist.conf
# Disable IPv6 blacklist ipv6
[9] poweroff 時的 Service
/etc/init.d/halt
# Turn off swap, then unmount file systems.
#[ -f /proc/swaps ] && SWAPS=$(awk '! /^Filename/ { print $1 }' /proc/swaps)
[10] 停用 VMware Tools
rm -f /etc/modprobe.d/vmware-tools.conf
rm -f /etc/init/vmware-tools.conf
[11] 修改 log
/etc/rsyslog.conf
kern.* -/dev/null
[12] 刪除 70-persistent-net.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
建立 /etc/init/console.conf (新)
# console - getty # # This service maintains a getty on console from the point the system is # started until it is shut down again. start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn exec /sbin/mingetty console
停用 Service
chkconfig udev-post off chkconfig sendmail off chkconfig netfs off chkconfig lldpad off chkconfig rpcgssd off chkconfig fcoe off chkconfig portreserve off
NetFS
It is a boot-time script used to mount or unmount Network File System (NFS),
Samba (SMB/CIFS), and Netware (NCP) file systems.
lldpad
Link Layer Discovery Protocol
rpcgssd
This service manages RPCSEC GSS contexts for the NFSv4 client,
which provides support on the client side for RPCSEC_GSS protocol.
It will start rpc.gssd daemon to communicate with server-side rpcsec_gss daemon rpc.svcgssd.
If using NFSv4, it is needed.
fcoe
Fiber-Channel Over Ethernet (FCoE) Service
portreserve
aims to help services with well-known ports that lie in the portmap range
It prevents portmap from a real service’s port by occupying it itself
Centos6 的 /dev
crw--w---- 1 root tty 136, 22 Aug 24 09:14 console lrwxrwxrwx 1 root root 13 Feb 17 2012 fd -> /proc/self/fd drwxr-xr-x 2 root root 4096 Aug 24 09:09 hugepages prw------- 1 root root 0 Aug 24 08:39 initctl -rw-r--r-- 1 root root 30 Aug 24 09:12 kmsg srw-rw-rw- 1 root root 0 Aug 24 09:12 log lrwxrwxrwx 1 root root 13 Aug 24 09:09 MAKEDEV -> /sbin/MAKEDEV drwxr-xr-x 2 root root 4096 Aug 24 09:09 net crw-rw-rw- 1 root root 1, 3 Apr 13 2006 null crw-rw-rw- 1 root root 5, 2 Aug 24 09:12 ptmx drwxr-xr-x 2 root root 0 Apr 13 2006 pts lrwxrwxrwx 1 root root 4 Feb 17 2012 ram -> ram1 lrwxrwxrwx 1 root root 4 Feb 17 2012 ramdisk -> ram0 crw-r--r-- 1 root root 1, 8 Apr 13 2006 random drwxrwxrwt 2 root root 4096 Aug 24 08:39 shm lrwxrwxrwx 1 root root 15 Feb 17 2012 stderr -> /proc/self/fd/2 lrwxrwxrwx 1 root root 15 Feb 17 2012 stdin -> /proc/self/fd/0 lrwxrwxrwx 1 root root 15 Feb 17 2012 stdout -> /proc/self/fd/1 crw-rw-rw- 1 root root 5, 0 Apr 13 2006 tty crw-rw-rw- 1 root root 4, 0 Aug 24 08:39 tty0 crw--w---- 1 root tty 136, 6 Aug 24 09:12 tty1 crw--w---- 1 root tty 136, 9 Aug 24 09:12 tty2 crw--w---- 1 root tty 136, 20 Aug 24 09:12 tty3 crw--w---- 1 root tty 136, 21 Aug 24 09:12 tty4 crw-r--r-- 1 root root 1, 9 Apr 13 2006 urandom crw-rw-rw- 1 root root 1, 5 Apr 13 2006 zero
Troubleshoot
[1] Boot 時 eth0 不能自動設定 IP. ifup ethX 出 error
Device eth0 does not seem to be present, delaying initialization.
原因: ifup-eth 內的 is_available ${REALDEVICE} 失敗
(此 function 在 ./network-functions 內)
Fix: 系統要 mount /sys