Difference between revisions of "Archlinux Template creation"
(inital release) |
(VE0->CT0, formatting fixes, other minor fixes) |
||
Line 7: | Line 7: | ||
Edit settings of script "archbootstrap" : | Edit settings of script "archbootstrap" : | ||
− | + | ARCH="i686" | |
− | ARCH="i686" | + | IGNORE="rp-pppoe ppp wireless_tools xfsdump xfsprogs reiserfsprogs lshwd usbutils pciutils pcmciautils module-init-tools mdadm mkinitcpio libusb jfsutils lvm2 lilo cryptsetup device-mapper dhcpcd hwdetect dmapi gen-init-cpio grub" |
− | IGNORE="rp-pppoe ppp wireless_tools xfsdump xfsprogs reiserfsprogs lshwd usbutils pciutils pcmciautils module-init-tools mdadm mkinitcpio libusb jfsutils lvm2 lilo cryptsetup device-mapper dhcpcd hwdetect dmapi gen-init-cpio grub" | + | umark PACMAN_OPTS (remove '#') |
− | |||
− | |||
{{Note|I suggest to place the build for OpenVZ templates to /vz/template/, schema: /vz/template/$DIST/$VERSION/$ARCH/}} | {{Note|I suggest to place the build for OpenVZ templates to /vz/template/, schema: /vz/template/$DIST/$VERSION/$ARCH/}} | ||
− | |||
Built this OS-Template with: | Built this OS-Template with: | ||
− | + | {| class="wikitable" | |
− | + | || [[CT0]]_dist || Debian | |
− | + | |- | |
− | DIST | + | || [[CT0]]_ARCH || i386 |
− | VERSION | + | |- |
− | ARCH | + | || DIST || arch |
− | + | |- | |
− | + | || VERSION || 0.8 | |
+ | |- | ||
+ | || ARCH || depends on CT0 settings above | ||
+ | |} | ||
== bootstrapping Archlinux == | == bootstrapping Archlinux == | ||
Line 32: | Line 32: | ||
Syntax: | Syntax: | ||
− | + | CT0_# /usr/bin/archbootstrap /vz/template/$DIST/$VERSION/$ARCH/ [MIRROR] | |
− | |||
− | |||
+ | {{Note|Please use mirrors! A full list of Archlinux mirrors: http://wiki.archlinux.org/index.php/Mirror}} | ||
== enter the Build with chroot == | == enter the Build with chroot == | ||
Line 41: | Line 40: | ||
All the commands below are executed from the root shell. I this howto "chroot" is used to enter as NEWROOT, a BUILD-VE must not be created! | All the commands below are executed from the root shell. I this howto "chroot" is used to enter as NEWROOT, a BUILD-VE must not be created! | ||
− | + | CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/ | |
− | |||
=== setting DNS server === | === setting DNS server === | ||
Line 48: | Line 46: | ||
For the chroot BUILD we also need to specify a DNS for it: | For the chroot BUILD we also need to specify a DNS for it: | ||
− | BUILD_# mv /etc/resolv.conf.pacorig /etc/resolv.conf | + | BUILD_# mv /etc/resolv.conf.pacorig /etc/resolv.conf |
− | |||
=== update and install packages === | === update and install packages === | ||
Line 55: | Line 52: | ||
Update (sync) pacman cache and update installed packages | Update (sync) pacman cache and update installed packages | ||
− | BUILD_# pacman -Syu | + | BUILD_# pacman -Syu |
− | |||
Install openssh (client and server) , quota-tools and iproute | Install openssh (client and server) , quota-tools and iproute | ||
− | BUILD_# pacman -S openssh quota-tools iproute | + | BUILD_# pacman -S openssh quota-tools iproute |
− | |||
=== fix /etc/mtab === | === fix /etc/mtab === | ||
Line 67: | Line 62: | ||
Add symlink /proc/mount /etc/mtab | Add symlink /proc/mount /etc/mtab | ||
− | BUILD_# ln -s /proc/mounts /etc/mtab | + | BUILD_# ln -s /proc/mounts /etc/mtab |
− | |||
=== fix /etc/inittab === | === fix /etc/inittab === | ||
− | Remove | + | Remove getty lines from inittab: |
− | |||
− | |||
+ | BUILD_# sed -i -e '/getty/d' /etc/inittab | ||
=== create device nodes === | === create device nodes === | ||
Line 81: | Line 74: | ||
Create device nodes at /dev, like console, full, null, zero, urandom, ptmx and fifo of initctl | Create device nodes at /dev, like console, full, null, zero, urandom, ptmx and fifo of initctl | ||
− | BUILD_# mknod -m 600 /dev/console c 5 1 | + | BUILD_# mknod -m 600 /dev/console c 5 1 |
− | + | BUILD_# mknod -m 666 /dev/tty c 5 0 | |
− | BUILD_# mknod -m 666 /dev/tty c 5 0 | + | BUILD_# mknod -m 666 /dev/full c 1 7 |
− | + | BUILD_# mknod -m 600 /dev/initctl p | |
− | BUILD_# mknod -m 666 /dev/full c 1 7 | + | BUILD_# mknod -m 666 /dev/null c 1 3 |
− | + | BUILD_# mknod -m 666 /dev/ptmx c 5 2 | |
− | BUILD_# mknod -m 600 /dev/initctl p | + | BUILD_# mkdir pts |
− | + | BUILD_# mknod -m 666 /dev/random c 1 8 | |
− | BUILD_# mknod -m 666 /dev/null c 1 3 | + | BUILD_# mknod -m 444 /dev/urandom c 1 9 |
− | + | BUILD_# mknod -m 666 /dev/zero c 1 5 | |
− | BUILD_# mknod -m 666 /dev/ptmx c 5 2 | ||
− | |||
− | BUILD_# mkdir pts | ||
− | |||
− | BUILD_# mknod -m 666 /dev/random c 1 8 | ||
− | |||
− | BUILD_# mknod -m 444 /dev/urandom c 1 9 | ||
− | |||
− | BUILD_# mknod -m 666 /dev/zero c 1 5 | ||
− | |||
=== sysinit script modification === | === sysinit script modification === | ||
Line 106: | Line 89: | ||
Remove deleting of /etc/mtab in /etc/rc.sysinit and add mounting of /dev/pts | Remove deleting of /etc/mtab in /etc/rc.sysinit and add mounting of /dev/pts | ||
− | BUILD_# nano /etc/rc.sysinit | + | BUILD_# nano /etc/rc.sysinit |
− | + | [...] | |
− | [...] | + | /bin/rm -f /etc/mtab |
− | /bin/rm -f /etc/mtab | + | [...] |
− | [...] | ||
− | |||
to | to | ||
− | + | [...] | |
− | [...] | + | #/bin/rm -f /etc/mtab |
− | #/bin/rm -f /etc/mtab | + | /bin/mount -t devpts none /dev/pts |
− | /bin/mount -t devpts none /dev/pts | + | [...] |
− | [...] | ||
− | |||
+ | === modify the main configuration file === | ||
− | + | BUILD_# nano /etc/rc.conf | |
− | |||
− | |||
# Localization | # Localization | ||
LOCALE="en_US.utf8" | LOCALE="en_US.utf8" | ||
Line 147: | Line 125: | ||
# Add openssh to DAEMONS, start at bootup ; ssh-keys are build on first VE start !!! | # Add openssh to DAEMONS, start at bootup ; ssh-keys are build on first VE start !!! | ||
DAEMONS=(syslog-ng network netfs crond ssh) | DAEMONS=(syslog-ng network netfs crond ssh) | ||
− | |||
− | |||
=== enable ssh connections === | === enable ssh connections === | ||
Line 154: | Line 130: | ||
{{Note|All connection are disabled to VE, see /etc/hosts.deny, only affected server built-in with libwrap}} | {{Note|All connection are disabled to VE, see /etc/hosts.deny, only affected server built-in with libwrap}} | ||
− | Allow ssh : | + | Allow ssh: |
− | |||
− | |||
− | |||
− | |||
+ | BUILD_# echo "ssh: ALL : ALLOW" >> /etc/hosts.allow} | ||
=== lock (disable) the root account === | === lock (disable) the root account === | ||
− | BUILD_# passwd -l root | + | BUILD_# passwd -l root |
+ | === exit the chroot to CT0 === | ||
− | + | BUILD_# exit | |
− | |||
− | BUILD_# exit | ||
− | |||
== build a exclude list == | == build a exclude list == | ||
Line 175: | Line 146: | ||
Shrink the OS-Template, so not all files needed in a VE - OS - TEMPLATE | Shrink the OS-Template, so not all files needed in a VE - OS - TEMPLATE | ||
+ | Remove unused pacman backup files: | ||
− | + | CT0_# find ./ -name '*.pacorig' > ../exclude.list-$ARCH | |
− | |||
− | |||
− | |||
− | /etc/resolv.conf is added by vzctl: | + | <code>/etc/resolv.conf</code> is added by vzctl: |
− | + | CT0_# echo "etc/resolv.conf" >> ../exclude.list-$ARCH | |
+ | Don't add downloaded pkg to ostemplate: | ||
− | + | CT0_# find ./var/cache/ -name '*.tar.gz' >> ../exclude.list-$ARCH | |
− | + | We dont need no logs and history: | |
+ | CT0_# find ./var/cache/ -name '*.tar.gz' >> ../exlcude.list-$ARCH | ||
+ | CT0_# find ./root/.bash_history >> ../exclude.list-$ARCH | ||
− | + | == create OS template == | |
− | + | CT0_# tar -X ../exclude.list-$ARCH -czf /vz/template/cache/arch-0.8-$ARCH-minimal.tar.gz ./ | |
+ | == use the OS template == | ||
− | + | CT0_# vzctl create <VEID> --ostemplate arch-0.8-$ARCH-minimal ... | |
+ | == update the OS template == | ||
− | + | To update a template is really easy, enter the build with chroot, performing upgrade task | |
− | + | CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/ 'pacman -Syu' | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Update the exclude list, and pack upgraded OS - Template | Update the exclude list, and pack upgraded OS - Template | ||
− | |||
== Links == | == Links == | ||
− | + | * [http://wiki.archlinux.org/index.php/Main_Page Archlinux wiki] | |
− | |||
[[Category: HOWTO]] | [[Category: HOWTO]] | ||
[[Category: Templates]] | [[Category: Templates]] |
Revision as of 11:59, 11 March 2008
Instructions manually create a minimal Archlinux (0.8) "Voodoo" OS Template.
Contents
Prerequisites
I used a modified archbootstrap script which can be found at http://forzza.systs.org/openvz-misc/
Edit settings of script "archbootstrap" :
ARCH="i686" IGNORE="rp-pppoe ppp wireless_tools xfsdump xfsprogs reiserfsprogs lshwd usbutils pciutils pcmciautils module-init-tools mdadm mkinitcpio libusb jfsutils lvm2 lilo cryptsetup device-mapper dhcpcd hwdetect dmapi gen-init-cpio grub" umark PACMAN_OPTS (remove '#')
Note: I suggest to place the build for OpenVZ templates to /vz/template/, schema: /vz/template/$DIST/$VERSION/$ARCH/ |
Built this OS-Template with:
CT0_dist | Debian |
CT0_ARCH | i386 |
DIST | arch |
VERSION | 0.8 |
ARCH | depends on CT0 settings above |
bootstrapping Archlinux
Syntax:
CT0_# /usr/bin/archbootstrap /vz/template/$DIST/$VERSION/$ARCH/ [MIRROR]
Note: Please use mirrors! A full list of Archlinux mirrors: http://wiki.archlinux.org/index.php/Mirror |
enter the Build with chroot
All the commands below are executed from the root shell. I this howto "chroot" is used to enter as NEWROOT, a BUILD-VE must not be created!
CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/
setting DNS server
For the chroot BUILD we also need to specify a DNS for it:
BUILD_# mv /etc/resolv.conf.pacorig /etc/resolv.conf
update and install packages
Update (sync) pacman cache and update installed packages
BUILD_# pacman -Syu
Install openssh (client and server) , quota-tools and iproute
BUILD_# pacman -S openssh quota-tools iproute
fix /etc/mtab
Add symlink /proc/mount /etc/mtab
BUILD_# ln -s /proc/mounts /etc/mtab
fix /etc/inittab
Remove getty lines from inittab:
BUILD_# sed -i -e '/getty/d' /etc/inittab
create device nodes
Create device nodes at /dev, like console, full, null, zero, urandom, ptmx and fifo of initctl
BUILD_# mknod -m 600 /dev/console c 5 1 BUILD_# mknod -m 666 /dev/tty c 5 0 BUILD_# mknod -m 666 /dev/full c 1 7 BUILD_# mknod -m 600 /dev/initctl p BUILD_# mknod -m 666 /dev/null c 1 3 BUILD_# mknod -m 666 /dev/ptmx c 5 2 BUILD_# mkdir pts BUILD_# mknod -m 666 /dev/random c 1 8 BUILD_# mknod -m 444 /dev/urandom c 1 9 BUILD_# mknod -m 666 /dev/zero c 1 5
sysinit script modification
Remove deleting of /etc/mtab in /etc/rc.sysinit and add mounting of /dev/pts
BUILD_# nano /etc/rc.sysinit
[...] /bin/rm -f /etc/mtab [...]
to
[...] #/bin/rm -f /etc/mtab /bin/mount -t devpts none /dev/pts [...]
modify the main configuration file
BUILD_# nano /etc/rc.conf
# Localization LOCALE="en_US.utf8" HARDWARECLOCK="localtime"
# example : German KEYMAP and Timezone to Berlin TIMEZONE="Europe/Berlin" KEYMAP="de-latin1-nodeadkeys"
CONSOLEFONT= CONSOLEMAP= USECOLOR="yes"
# Network settings HOSTNAME="localhost"
# DAEMONS # Add openssh to DAEMONS, start at bootup ; ssh-keys are build on first VE start !!! DAEMONS=(syslog-ng network netfs crond ssh)
enable ssh connections
Note: All connection are disabled to VE, see /etc/hosts.deny, only affected server built-in with libwrap |
Allow ssh:
BUILD_# echo "ssh: ALL : ALLOW" >> /etc/hosts.allow}
lock (disable) the root account
BUILD_# passwd -l root
exit the chroot to CT0
BUILD_# exit
build a exclude list
Shrink the OS-Template, so not all files needed in a VE - OS - TEMPLATE
Remove unused pacman backup files:
CT0_# find ./ -name '*.pacorig' > ../exclude.list-$ARCH
/etc/resolv.conf
is added by vzctl:
CT0_# echo "etc/resolv.conf" >> ../exclude.list-$ARCH
Don't add downloaded pkg to ostemplate:
CT0_# find ./var/cache/ -name '*.tar.gz' >> ../exclude.list-$ARCH
We dont need no logs and history:
CT0_# find ./var/cache/ -name '*.tar.gz' >> ../exlcude.list-$ARCH CT0_# find ./root/.bash_history >> ../exclude.list-$ARCH
create OS template
CT0_# tar -X ../exclude.list-$ARCH -czf /vz/template/cache/arch-0.8-$ARCH-minimal.tar.gz ./
use the OS template
CT0_# vzctl create <VEID> --ostemplate arch-0.8-$ARCH-minimal ...
== update the OS template ==
To update a template is really easy, enter the build with chroot, performing upgrade task
CT0_# chroot /vz/template/$DIST/$VERSION/$ARCH/ 'pacman -Syu'
Update the exclude list, and pack upgraded OS - Template