# Comment créer une image DEBIAN en partant d'une Instance existante pour Le Mini-Cloud Outscale. # # # # http://marcfiasse.com/editeurs/cloud/ec2/outscale_debian.txt # # # Script MEMO outscale_debian.txt - LICENCE ----------------------------------------- [Copyright 2012 Marc Fiasse http://marcfiasse.com/ ] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 dec. 2012 # # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Reference document Outscale : http://wiki.outscale.net/display/DOCU/Debian # # # # Ouvrir l'interface TINA OS : https://portal.outscale.com/login # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # 1 - Créer et démarrer une instance sous Debian AMD 64 en offre gratuite MINI. # 2 - Créer un volume de 10 GB par l'interface TINA OS via le bouton "CREATE VOLUME" # 3 - Attacher le volume à l'instance par l'interface TINA OS en renseignant /dev/sdb # # # # 4 - Connexion avec Putty sur le Cloud. # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ cat > /etc/udev/rules.d/96-ds.rules <<_EOF_ KERNEL=="vd?*", PROGRAM="/bin/vd-sd %k %n", SYMLINK+="%c" _EOF_ cat > /bin/vd-sd < /etc/modules < vdb # # # # # # # Vérification des partitions avec fdisk : # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ fdisk -l # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Réponse attendue : # Disk /dev/vda: 10.7 GB, 10737418240 bytes # 16 heads, 63 sectors/track, 20805 cylinders # Units = cylinders of 1008 * 512 = 516096 bytes # Sector size (logical/physical): 512 bytes / 512 bytes # I/O size (minimum/optimal): 512 bytes / 512 bytes # Disk identifier: 0x00000000 # Device Boot Start End Blocks Id System # /dev/vda1 1 20805 10485719+ 83 Linux # Disk /dev/vdb: 10.7 GB, 10737418240 bytes # 16 heads, 63 sectors/track, 20805 cylinders # Units = cylinders of 1008 * 512 = 516096 bytes # Sector size (logical/physical): 512 bytes / 512 bytes # I/O size (minimum/optimal): 512 bytes / 512 bytes # Disk identifier: 0x00000000 # Disk /dev/vdb doesn't contain a valid partition table # # # # # # # Créer la partition avec fdisk : # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ fdisk /dev/sdb # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # option : p pour infos # option : n pour créer # option : w pour enregistrer et sortir # Command (m for help): n # Command action # e extended # p primary partition (1-4) # p # Partition number (1-4): 1 # First cylinder (1-19452, default 1): 1 # Using default value 1 # Last cylinder or +size or +sizeM or +sizeK (1-19452, default 19452): 20805 # w pour enregistrer et exit ... # # # # # # # Vérification des partitions avec fdisk : # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ fdisk -l # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Réponse attendue : # Disk /dev/vda: 10.7 GB, 10737418240 bytes # 16 heads, 63 sectors/track, 20805 cylinders # Units = cylinders of 1008 * 512 = 516096 bytes # Sector size (logical/physical): 512 bytes / 512 bytes # I/O size (minimum/optimal): 512 bytes / 512 bytes # Disk identifier: 0x00000000 # Device Boot Start End Blocks Id System # /dev/vda1 1 20805 10485719+ 83 Linux # Disk /dev/vdb: 10.7 GB, 10737418240 bytes # 16 heads, 63 sectors/track, 20805 cylinders # Units = cylinders of 1008 * 512 = 516096 bytes # Sector size (logical/physical): 512 bytes / 512 bytes # I/O size (minimum/optimal): 512 bytes / 512 bytes # Disk identifier: 0xeefdbbe4 # Device Boot Start End Blocks Id System # /dev/vdb1 1 20805 10485688+ 83 Linux # # # # Formatage de la partition sdb1 / vdb1 : # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ mkfs.ext3 /dev/vdb1 mount /dev/vdb1 /mnt/ df -h # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Montage d'un système complet avec debootstrap : # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ mkdir -p /mnt/dev/pts mount --bind /dev /mnt/dev debootstrap --arch=amd64 squeeze /mnt/ http://ftp.fr.debian.org/debian/ mount -t proc none /mnt/proc mount -t devpts none /mnt/dev/pts # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Installation des packages minimum # # Entrée dans le chroot /mnt/ # # Pour la configuration de Grub et du disque de démarrage : # ( Default ) Enter # ( Default ) Enter # ( Default ) Enter # par les flèches et la barre d'espace, choisir et sélectionner vdb comme disque de démarrage ! # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ chroot /mnt/ echo y > /etc/yes.txt echo y >> /etc/yes.txt apt-get install linux-image-amd64 < /etc/yes.txt apt-get install locales < /etc/yes.txt apt-get install curl < /etc/yes.txt apt-get install ntp < /etc/yes.txt apt-get install ssh < /etc/yes.txt apt-get install grub < /etc/yes.txt # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Configuration locales par défaut # # Modification fichier /etc/ssh/sshd_config # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ echo fr_BE.UTF-8 UTF-8 > /etc/locale.gen dpkg-reconfigure --priority=critical locales sed -i -e "s/^#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config /etc/init.d/ssh stop exit # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Modification des fichiers dans /mnt/ # # Pour vérifier après modifications : # nano /mnt/etc/inittab # nano /mnt/etc/default/grub # nano /mnt/etc/apt/sources.list # nano /mnt/etc/network/interfaces # nano /mnt/etc/modules # nano /mnt/bin/vd-sd # nano /mnt/etc/udev/rules.d/96-ds.rules # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ sed -i -e "s/2:23:respawn:\/sbin\/getty 38400 tty2/#2:23:respawn:\/sbin\/getty 38400 tty2/" /mnt/etc/inittab sed -i -e "s/3:23:respawn:\/sbin\/getty 38400 tty3/#3:23:respawn:\/sbin\/getty 38400 tty3/" /mnt/etc/inittab sed -i -e "s/4:23:respawn:\/sbin\/getty 38400 tty4/#4:23:respawn:\/sbin\/getty 38400 tty4/" /mnt/etc/inittab sed -i -e "s/5:23:respawn:\/sbin\/getty 38400 tty5/#5:23:respawn:\/sbin\/getty 38400 tty5/" /mnt/etc/inittab sed -i -e "s/6:23:respawn:\/sbin\/getty 38400 tty6/#6:23:respawn:\/sbin\/getty 38400 tty6/" /mnt/etc/inittab sed -i -e "s/GRUB_CMDLINE_LINUX_DEFAULT=\"quiet\"/GRUB_CMDLINE_LINUX_DEFAULT=\"elevator=deadline console=tty0 console=ttyS0,38400n8\"/" /mnt/etc/default/grub cat > /mnt/etc/apt/sources.list < /mnt/etc/network/interfaces <<_EOF_ # the loopback interface auto lo iface lo inet loopback # the public interface auto eth0 iface eth0 inet dhcp pre-up ifconfig eth0 mtu 9000 _EOF_ cat > /mnt/etc/modules < /mnt/bin/vd-sd < /mnt/etc/udev/rules.d/96-ds.rules < /mnt/etc/fstab <<_EOF_ # /dev/vda1 / ext3 defaults 1 2 _EOF_ chmod +x /mnt/bin/vd-sd # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Installation des scripts de clés dynamiques compatibles EC2 # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ chroot /mnt cd /etc/init.d/ wget http://marcfiasse.com/editeurs/cloud/ec2/getsshkey cd /etc/init.d/ wget http://marcfiasse.com/editeurs/cloud/ec2/ec2-run-user-data cp /etc/rc.local /etc/rc.local_back sed -i '/^exit 0/d' /etc/rc.local cat >> /etc/rc.local < /etc/hostname hostname -F /etc/hostname ls -la /dev/sda cp /etc/rc.local_back /etc/rc.local rm /etc/rc.local_back EOF chmod 755 /etc/init.d/getsshkey chmod 755 /etc/init.d/ec2-run-user-data update-rc.d getsshkey defaults update-rc.d ec2-run-user-data defaults # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Update et upgrade et nettoyage # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ cd /var/cache/apt/archives dir aptitude update aptitude safe-upgrade < /etc/yes.txt apt-get autoremove --purge apt-get clean apt-get autoclean cd /var/cache/apt/archives dir cd / sed -i -e 's/^set historylog/unset historylog/;s/^\(# \)*set tabsize .*/set tabsize 4/' /etc/nanorc rm -R lost+found rm initrd.img rm -rf /var/log/*.gz /var/log/{bootstrap,dpkg}.log /var/cache/apt/*.bin rm -rf /tmp/* rm /var/log/alternatives.log /var/log/apt/* rm /etc/yes.txt rm /var/lib/apt/lists/ftp* rm /var/lib/apt/lists/sec* aptitude update umount /dev/pts umount /proc exit rm /mnt/root/* find /mnt/var/log -type f -exec rm {} + rm /mnt/root/.bash_history rm /mnt/etc/hostname history -c # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # Retour sur l'interface TINA OS # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # 6 - Terminer l'instance en cours sur laquelle vient d'être fabriqué le debootstrap ! Elle n'est plus nécessaire. # 7 - Attendre que l'instance précédente soit terminée. Le volume initialement /dev/sdb redevient Utilisable sur l'interface TINA OS. # 8 - Créer un Snapshot avec ce volume qu'on nomme comme on veut. # 9 - Enregistrer le Snapshot en indiquant un nom, et en sélectionant X86_64, pour qu'il apparaisse dans la liste des images. # 10 - Effacer le volume de 10 Go. Seul le snapshot réalisé doit rester. Tester en lançant VOTRE nouvelle image. # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ # # # FIN # # # -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Script MEMO outscale_debian.txt - LICENCE ----------------------------------------- [Copyright 2012 Marc Fiasse http://marcfiasse.com/ ] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 11 dec. 2012 Marc Fiasse