Skip to content

Instantly share code, notes, and snippets.

@jpic
Created January 26, 2011 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpic/797765 to your computer and use it in GitHub Desktop.
Save jpic/797765 to your computer and use it in GitHub Desktop.
I use this script to install a fresh arch linux system on sda1 or sda2 from an existing arch linux system
# cat bin/newarch_rebuild.sh 14:21 ROOT@tina:~
#!/bin/bash
sdx="$1"
newroot="/$sdx"
#pacman="pacman --cachedir $newroot/var/cache/pacman/pkg -r $newroot"
pacman="pacman --noconfirm -r $newroot"
cd
umount $newroot/{proc,sys,dev,srv}
umount /dev/$sdx
mkfs.ext4 /dev/$sdx || kill $$
mount /dev/$sdx $newroot
mkdir -p $newroot/var/lib/pacman
$pacman -Sy
$pacman -S base
cd $newroot/dev
rm console ; mknod -m 600 $newroot/dev/console c 5 1
rm null ; mknod -m 666 $newroot/dev/null c 1 3
rm zero ; mknod -m 666 $newroot/dev/zero c 1 5
cp -L /etc/resolv.conf $newroot/etc
cp /etc/pacman.d/mirrorlist $newroot/etc/pacman.d
mount -t proc proc $newroot/proc
mount -t sysfs sys $newroot/sys
mount -o bind /dev $newroot/dev
$pacman -Rs dash jfsutils lvm2 mdadm nano pcmciautils ppp reiserfsprogs rp-pppoe vi wpa_supplicant xfsprogs
$pacman -S vim python2 zsh nginx postgresql screen openssh grub parted base-devel subversion git keychain ctags irssi setuptools mysql libxml2 libxslt apg
$pacman -U $HOME/builds/apache-tools/apache-tools-2.2.17-1-i686.pkg.tar.xz
rm -rf $newroot/root # see skel/root
cp -va /home/root/newarch_skel/* $newroot
chroot $newroot locale-gen
chroot $newroot mkinitcpio -p kernel26
#$pacman -U $HOME/builds/freedt/freedt-0.21-8-i686.pkg.tar.xz
cp -a $newroot/usr/lib/grub/i386-pc/* $newroot/boot/grub
if [ "x$sdx" == "xsda1" ]; then
echo 'root (hd0,0)' >> $newroot/boot/grub/menu.lst
echo /dev/sda1 / ext2 noatime 0 1 >> $newroot/etc/fstab
mkdir $newroot/sda2
echo /dev/sda2 /sda2 ext4 noatime 0 1 >> $newroot/etc/fstab
parted /dev/sda set 1 b on
grub --batch <<EOT
root (hd0,0)/boot
setup (hd0)
quit
EOT
else
echo 'root (hd0,1)' >> $newroot/boot/grub/menu.lst
echo /dev/sda2 / ext4 noatime 0 1 >> $newroot/etc/fstab
mkdir $newroot/sda1
echo /dev/sda1 /sda1 ext2 noatime 0 1 >> $newroot/etc/fstab
parted /dev/sda set 2 b on
grub --batch <<EOT
root (hd0,1)/boot
setup (hd0)
quit
EOT
fi
echo kernel /boot/vmlinuz26 root=/dev/$sdx ro >> $newroot/boot/grub/menu.lst
echo initrd /boot/kernel26.img >> $newroot/boot/grub/menu.lst
echo Port 2222 >> $newroot/etc/ssh/sshd_config
# untested
chroot $newroot easy_install-2.7 pip virtualenv flup psycopg2
chroot $newroot pip install http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
chroot $newroot chsh -s /bin/zsh root
chroot $newroot useradd -u 1000 -d /home/jpic -s /bin/zsh jpic
echo "Please type your desired jpic password"
chroot $newroot passwd jpic
echo "Please type your desired root password"
chroot $newroot passwd
# find newarch_skel 14:21 ROOT@tina:~
newarch_skel
newarch_skel/root
newarch_skel/srv
newarch_skel/srv/http
newarch_skel/srv/http/yourlabs.org
newarch_skel/etc
newarch_skel/etc/hosts.deny
newarch_skel/etc/rc.d
newarch_skel/etc/rc.d/sites
newarch_skel/etc/inittab
newarch_skel/etc/pam.d
newarch_skel/etc/pam.d/passwd
newarch_skel/etc/host.conf
newarch_skel/etc/default
newarch_skel/etc/default/passwd
newarch_skel/etc/locale.gen
newarch_skel/etc/hosts
newarch_skel/etc/nginx
newarch_skel/etc/nginx/conf
newarch_skel/etc/nginx/conf/nginx.conf
newarch_skel/etc/nginx/logs
newarch_skel/etc/nginx/html
newarch_skel/etc/mysql
newarch_skel/etc/mysql/my.cnf
newarch_skel/etc/fstab
newarch_skel/etc/conf.d
newarch_skel/etc/conf.d/postgresql
newarch_skel/etc/conf.d/sites
newarch_skel/etc/rc.conf
newarch_skel/etc/hosts.allow
newarch_skel/boot
newarch_skel/boot/grub
newarch_skel/boot/grub/menu.lst
newarch_skel/usr
newarch_skel/usr/lib
newarch_skel/usr/lib/build
newarch_skel/usr/lib/build/pip-delete-this-directory.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment