centos5 rootfs (manual, rinse) (lxc template)

 

To use an OpenVZ container

 

全自動:

 

查看 Vsersion:

  • rinse --version
rinse release 1.9.1

設定檔在:

  • /etc/rinse/rinse.conf
[centos-5]
mirror       = http://mirror.bytemark.co.uk/centos/5/os/i386/CentOS/
mirror.amd64 = http://mirror.bytemark.co.uk/centos/5/os/x86_64/CentOS/

換成其他 mirror:

mirror       = http://mirror.centos.org/centos/5/os/i386/CentOS/
mirror.amd64 = http://mirror.centos.org/centos/5/os/x86_64/CentOS/

 

看有什麼 rpm system 可以安裝:

rinse --list-distributions

        centos-4
        centos-5   <-- 對應 /etc/rinse/centos-5.packages
        centos-6

          --directory    The directory to install the distribution within.
          --distribution The distribution to install.
          --arch         'amd64' | 'i386'
          --print-uris   Only show the RPMs which should be downloaded.

 

Example:

  • rinse --verbose --distribution centos-5 --arch i386 --directory ./centos5

如果安裝中途按過 Ctrl + C 中止, 那會影響以下地方

/var/cache/rinse/centos-5.i386/

  • rinse --clean-cache

 


人手

 

mkdir centos5

apt-get install rpm2cpio

http://mirrors.kernel.org/centos/5/os/i386/CentOS/

rpm2cpio centos-release-5-8.el5.centos.i386.rpm | cpio -idm

獲得

  •     etc/
  •     usr/

sed -i 's/$releasever/5/g' ./etc/yum.repos.d/*

setarch i386

yum --installroot=/centos5 groupinstall base

chroot centos5

# mkdir -p /dev/shm
# chmod 1777 /dev/shm
# mkdir -p /dev/pts
# chmod 755 /dev/pts
# rm -f /dev/null
# mknod -m 666 /dev/null c 1 3
# mknod -m 666 /dev/zero c 1 5
# mknod -m 666 /dev/urandom c 1 9
# ln -s /dev/urandom /dev/random
# mknod -m 600 /dev/console c 5 1
# mknod -m 660 /dev/tty1 c 4 1
# chown root:tty /dev/tty1

mtab

# rm /etc/mtab
# touch /etc/mtab

/etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

/etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=centos5

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp

/etc/fstab

/dev/root               /                       rootfs   defaults        0 0
none                    /dev/shm                tmpfs    nosuid,nodev    0 0

/etc/inittab

0:2345:respawn:/sbin/mingetty console
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

換成:

# System initialization.
si::bootwait:/etc/rc.d/lxc.sysinit

/etc/rc.d/lxc.sysinit

#! /bin/bash
rm -f /etc/mtab /var/run/*.{pid,lock} /var/lock/subsys/*
rm -rf {/,/var}/tmp/*
echo "/dev/root               /                       rootfs   defaults        0 0" > /etc/mtab
exit 0

 


問題:

passwd authentication token manipulation error centos

解決:

pwconv

問題:

Setting hostname centos5:  hostname: you must be root to change the host name  [FAILED]

        if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]; then
                ipaddr=$(ip addr show to 0/0 scope global | awk '/[[:space:]]inet / { print gensub("/.*","","g",$2) }')
                if [ -n "$ipaddr" ]; then
                        eval $(ipcalc -h $ipaddr 2>/dev/null)
                        #hostname ${HOSTNAME}
                fi
        fi

問題:

Mounting local filesystems:  mount: permission denied                          [FAILED]

        if [ "$READONLY" != "yes" ] ; then
                action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
        else
                action $"Mounting local filesystems: " mount -a -n -t nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev
        fi

 

 

 

 

Creative Commons license icon Creative Commons license icon