debootstrap disk image
From Noah.org
Revision as of 07:37, 15 May 2014 by Root (talk | contribs) (Created page with 'Category:Engineering This creates a very minimal Debian Sid root filesystem with networking and OpenSSH Server. The root password is set to '''password'''. <pre> #!/bin/bas…')
This creates a very minimal Debian Sid root filesystem with networking and OpenSSH Server.
The root password is set to password.
#!/bin/bash DISK_NAME=$1 DISK_SIZE=$2 HOSTNAME=$3 DOMAIN=$4 IP=$5 NM=$6 GW=$7 NS=$8 LOOP=/mnt/loop dd if=/dev/zero of=${DISK_NAME} bs=1048576 count=$((1+${DISK_SIZE}/1048576)) of=${DISK_NAME} mkfs -F -t ext4 ${DISK_NAME} mkdir -p ${LOOP} mount -o loop ${DISK_NAME} ${LOOP} debootstrap sid ${LOOP} http://ftp.us.debian.org/debian/ sed -i -e 's/tty1/hvc0/g' ${LOOP}/etc/inittab echo root:password | chroot ${LOOP} chpasswd cp /etc/hosts ${LOOP}/etc/hosts cat > ${LOOP}/etc/network/interfaces <<EOF_INTERFACES # interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback auto eth0 iface eth0 inet static address ${IP} netmask ${NM} gateway ${GW} EOF_INTERFACES cat > ${LOOP}/etc/resolv.conf <<EOF_RESOLV_CONF search ${HOSTNAME}.${DOMAIN} nameserver ${NS} EOF_RESOLV_CONF mkdir ${LOOP}/root/.ssh chmod 700 ${LOOP}/root/.ssh chown 0:0 ${LOOP}/root/.ssh cat ~/.ssh/id_rsa.pub >> ${LOOP}/root/.ssh/authorized_keys chmod 600 ${LOOP}/root/.ssh/authorized_keys chown 0:0 ${LOOP}/root/.ssh/authorized_keys chroot ${LOOP} apt-get install -q -y --allow-unauthenticated openssh-server