cn:ccr:cloud:preparazione_immagini_per_debian_7.1_con_cloud-init
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cn:ccr:cloud:preparazione_immagini_per_debian_7.1_con_cloud-init [2013/09/19 08:31] – [S.O. e tools necessari] dorigoa@infn.it | cn:ccr:cloud:preparazione_immagini_per_debian_7.1_con_cloud-init [2013/09/27 10:09] (current) – dorigoa@infn.it | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Preparare immagine cloud di Debian 7.1 Wheezy (x86_64) ===== | ||
| + | * Alvise Dorigo (INFN Padova) | ||
| + | * Inspirato a: [[http:// | ||
| + | * Adattato da: [[http:// | ||
| + | * Altra fonte: [[http:// | ||
| + | ==== S.O. e tools necessari ==== | ||
| + | Le successive operazioni vanno eseguite come utente root da una macchina (reale o virtuale) che esegua un S.O. Debian7 | ||
| + | |||
| + | <code bash> | ||
| + | export IMAGELIBDIR=/ | ||
| + | mkdir -p $IMAGELIBDIR | ||
| + | export IMAGENAME=$IMAGELIBDIR/ | ||
| + | export MIRROR=ch | ||
| + | # il mirror può essere scelto dalla lista riportata qui | ||
| + | # http:// | ||
| + | # cambiando opportunamente il codice paese (nell' | ||
| + | # ho scelto ch, ma poteva essere " | ||
| + | # alla data di questa modifica (2013-09-19), | ||
| + | # | ||
| + | export MOUNTPOINT=/ | ||
| + | apt-get install --yes debootstrap syslinux parted | ||
| + | </ | ||
| + | ==== Creare il sistema operativo minimale ===== | ||
| + | |||
| + | == Creare un file immagine block device == | ||
| + | <code bash> | ||
| + | dd if=/ | ||
| + | mkfs.ext4 -F $IMAGENAME | ||
| + | </ | ||
| + | |||
| + | == Installare il S.O. == | ||
| + | <code bash> | ||
| + | mkdir -p $MOUNTPOINT | ||
| + | mount -o loop $IMAGENAME $MOUNTPOINT | ||
| + | debootstrap --arch amd64 wheezy $MOUNTPOINT http:// | ||
| + | </ | ||
| + | |||
| + | == Configurare il S.O. == | ||
| + | <code bash> | ||
| + | chroot $MOUNTPOINT | ||
| + | mount none -t proc /proc | ||
| + | mount -t devpts none /dev/pts | ||
| + | export HOME=/ | ||
| + | export LC_ALL=C | ||
| + | apt-get install dialog dbus --yes | ||
| + | dbus-uuidgen > / | ||
| + | apt-get update --yes | ||
| + | apt-get install --yes makedev vim locales | ||
| + | cd /dev | ||
| + | for dev in "zero null console generic std"; do MAKEDEV $dev; done | ||
| + | cd | ||
| + | </ | ||
| + | Editare il file /etc/fstab immettendo il seguente contenuto: | ||
| + | <code bash> | ||
| + | /dev/vda1 / ext4 defaults, | ||
| + | devpts / | ||
| + | tmpfs / | ||
| + | proc / | ||
| + | sysfs / | ||
| + | </ | ||
| + | |||
| + | Editare il file / | ||
| + | <code bash> | ||
| + | echo -e 'auto eth0\niface eth0 inet dhcp' >> / | ||
| + | rm -f / | ||
| + | </ | ||
| + | |||
| + | == Impostare la password di root (non obbligatorio) + customizzazione user == | ||
| + | Questo step può essere tralasciato se si intende accedere all' | ||
| + | <code bash> | ||
| + | passwd | ||
| + | # Creazione opzione di un utente se richiesto: | ||
| + | # useradd myuser | ||
| + | # passwd myuser | ||
| + | # chsh myuser | ||
| + | </ | ||
| + | |||
| + | == Installare kernel e altri tool necessari alla contestualizzazione == | ||
| + | <code bash> | ||
| + | apt-get install --no-install-recommends --yes linux-image-3.2.0-4-amd64 net-tools tcpdump python-cheetah python-requests python-six python python-boto python-oauth python-configobj python-prettytable python-yaml python-software-properties wget openssh-client openssh-server gparted rsync syslinux partclone python-crypto python-m2crypto python-paramiko initramfs-tools ntp ntpdate sudo curl | ||
| + | </ | ||
| + | |||
| + | == Installare i tools per la " | ||
| + | Aggiungere il repo necessario: | ||
| + | <code bash> | ||
| + | echo "deb http:// | ||
| + | apt-get update | ||
| + | </ | ||
| + | Installare i cloud tools: | ||
| + | <code bash> | ||
| + | apt-get install --yes cloud-init cloud-utils cloud-initramfs-growroot | ||
| + | </ | ||
| + | |||
| + | == Pulizia e uscita dalla sessione chroot == | ||
| + | <code bash> | ||
| + | rm -f / | ||
| + | apt-get clean | ||
| + | rm -rf /tmp/* | ||
| + | rm / | ||
| + | umount /proc | ||
| + | umount /dev/pts | ||
| + | exit | ||
| + | </ | ||
| + | |||
| + | == Estrarre kernel e initram da caricare in openstack == | ||
| + | <code bash> | ||
| + | cp $MOUNTPOINT/ | ||
| + | cp $MOUNTPOINT/ | ||
| + | umount -l $MOUNTPOINT | ||
| + | </ | ||
| + | ==== Importare in glance ==== | ||
| + | <code bash> | ||
| + | glance image-create --name " | ||
| + | ID_AKI=`glance image-list |grep Debian7-kernel|awk -F '| ' ' | ||
| + | |||
| + | glance image-create --name " | ||
| + | ID_ARI=`glance image-list |grep Debian7-ramdisk|awk -F '| ' ' | ||
| + | |||
| + | glance image-create --name=" | ||
| + | </ | ||
| + | |||
| + | Nota: L' | ||
