Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # check inteernet connection
- if [[ ! $(curl -Is http://www.google.com/ | head -n 1) =~ "200 OK" ]]; then
- echo "Your Internet seems broken. Press Ctrl-C to abort or enter to continue."
- read
- fi
- # BRAZELLL!!111!!ONZE11!!
- loadkeys br-abnt2
- # create partition table
- parted -s /dev/sda mktable msdos
- # boot partition
- parted -s /dev/sda mkpart primary 0% 100m
- # root partition
- parted -s /dev/sda mkpart primary 100m 100%
- # /boot (no journaling needed)
- mkfs.ext2 /dev/sda1
- # / (better fs for better performance)
- mkfs.btrfs /dev/sda2
- # mouting partitions
- mount /dev/sda2 /mnt
- mkdir /mnt/boot
- mount /dev/sda1 /mnt/boot
- # rankmirrors to make this faster (though it takes a while)
- mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig
- rankmirrors -n 6 /etc/pacman.d/mirrorlist.orig >/etc/pacman.d/mirrorlist
- # enabled countrys
- declare -a Cnts=("United States" "Brazil" "Portugal")
- # output a file with each country
- for Cnt in "${arr[@]}"
- do
- awk -v GG=$Cnt '{if(match($0,GG) != "0")AA="1";if(AA == "1"){if( length($2) != "0" )print substr($0,2) ;else AA="0"} }' /etc/pacman.d/mirrorlist > /etc/pacman.d/$Cnt.newmirrorlist
- done
- # merge files
- awk 'FNR==1{print ""}1' *.newmirrorlist > /etc/pacman.d/mirrorlist.pacnew
- # rank each mirror
- rankmirrors /etc/pacman.d/mirrorlist.pacnew >/etc/pacman.d/mirrorlist
- # and remove tmp files
- rm *.newmirrorlist mirrorlist.pacnew
- # update pacman databases
- pacman -Syy
- # install
- pacstrap -i /mnt base base-devel
- # update fstab
- genfstab -U -p /mnt >> /mnt/etc/fstab
- # finally chroot
- arch-chroot /mnt pacman -S syslinux --noconfirm
- # copy ranked mirrorlist over
- cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
- # huge chroot calls here
- arch-chroot /mnt /bin/bash <<EOF
- # set initial hostname
- echo "archlinux-vm" >/etc/hostname
- # set initial timezone to America/Sao_Paulo
- ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
- # setup locale
- locale >/etc/locale.conf
- echo "en_GB.UTF-8 UTF-8" >>/etc/locale.gen
- echo "pt_BR.UTF-8 UTF-8" >>/etc/locale.gen
- # generate locale
- locale-gen
- # no modifications to mkinitcpio.conf should be needed
- mkinitcpio -p linux
- # install syslinux bootloader
- syslinux-install_update -i -a -m
- # update syslinux config with correct root disk
- sed 's/root=.*/root=\/dev\/sda2 ro/' < /boot/syslinux/syslinux.cfg > /boot/syslinux/syslinux.cfg.new
- mv /boot/syslinux/syslinux.cfg.new /boot/syslinux/syslinux.cfg
- # set root password to "root"
- echo root:batata | chpasswd
- # enable internet
- systemctl enable dhcpcd@eth0.service
- # no more chroot things
- EOF
- # unmount
- umount /mnt/{boot,}
- echo "Done! Unmount the CD image from the VM, then type 'reboot'."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement