You are not logged in.
i am writing a very simple arch linux installation script
i am already very familer with how a regular installation works and all i want to do
is automate it so i can get it installed faster
here is the script:
#!/bin/bash
# partitioning and swap
mkfs.ext4 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2
# mount the partitions
mount /dev/sda1 /mnt
# install
pacstrap /mnt base
# generate fstab
genfstab -p -U /mnt >> /mnt/etc/fstab
# change root
arch-chroot /mnt
# set hostname
echo VirtualBox > /etc/hostname
# set timezone
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
# generate locale
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
echo "en_US ISO-8859-1" >> /etc/locale.gen
locale-gen
# create user
useradd -m -G wheel -s /bin/bash arch
# install base-devel
pacman -S --noconfirm base-devel
# install command line and ncurses programs
pacman -S --noconfirm vim vim-runtime
pacman -S --noconfirm mc
pacman -S --noconfirm sudo
pacman -S --noconfirm htop
# install xorg
pacman -S --noconfirm mesa
pacman -S --noconfirm xorg
pacman -S --noconfirm xorg-xinit
# install window manager
pacman -S --noconfirm awesome
pacman -S --noconfirm vicious
# install terminal emulators
pacman -S --noconfirm terminator
pacman -S --noconfirm xterm
# install graphical programs
pacman -S --noconfirm firefox
pacman -S --noconfirm pcmanfm
# install grub
pacman -S --noconfirm grub
# configure xinit
echo "exec awesome" > /home/arch/.xinitrc
# configure sudo
sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
# configure grub
grub-install --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
# let user know that the install finished
echo "Install Finished"
it assumes i have already partitioned the disks
and will manually handle setting passwords
my only problem is that it stops after running pacstrap
i am new to bash scripting so can anyone please help me
Last edited by blutechgirl (2015-10-24 20:39:14)
Offline
I suspect it actually stops after running genfstab which would be expected.
What do you think arch-chroot actually does? It launches a new interactive shell in the new root. So everything after that in the script would not be expected to run. And even if it did run, it would run in the live iso not in the newly installed system.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
is there a way to fix this?
Offline
ok so if it stops after running genfstab then what is it that makes it stop
Offline
It isn't actually stopping. The stuff after "arch-chroot /mnt" won't run in the chroot environment but until after the chroot closes in the host environment. What you want to do is have those commands called inside the chroot environment. The most straightforward way is to have a second script run those commands. It can either be copied by the first script or created by the first script.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
ok how will the second script be called though. the aim is for no user intervention other that before and after the installation
Offline
Through the arch-chroot command. Say you created the second script in /mnt/root/install-part2.sh. Then (I think) you would run arch-chroot /mnt /root/install-part2.sh. That should run the second script instead of opening a shell.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
thanks i will try it
Offline
i tried this and it say no such file or directory
i doubled checked where the second file was
so thats not the problem
Offline
arch-chroot -h
usage: arch-chroot chroot-dir [command]
-h Print this help message
If 'command' is unspecified, arch-chroot will launch /bin/sh.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
i did
arch-chroot /mnt ./Archchroot.bash
the second script is in the same directory as the first one
it still says no file or directory
is there another way to call the script inside the chroot with out manual intervention
Offline
The script has to be inside your chroot, so copy it to /mnt before launching it.
Last edited by Banton (2015-10-24 19:42:44)
Offline
i copied it to the root directory of the new install
and ran
arch-chroot /mnt ./Archchroot.bash
it works
now i just need to see how it works in the script
Offline
Other attempts at this have used a here-document to keep the entire script in one deployable file:
#!/bin/bash
# stuff here to do outside the chroot: partitioning to genfstab
# ...
# ...
cat <<EOF > /mnt/root/part2.sh
# stuff here to do inside the chroot
# ...
# ...
exit # to leave the chroot
EOF
arch-chroot /mnt /root/part2.sh
# Stuff here to do after exiting the chroot ... reboot perhaps.
# ...
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
i copied the second script to /mnt first
and then ran the chroot command
i implemented it in the script and it worked
Offline
here is what the script looks like now
#!/bin/bash
# partitioning and swap
mkfs.ext4 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2
# mount the partitions
mount /dev/sda1 /mnt
# install
pacstrap /mnt base
# copy the second script
cp Archchroot.bash /mnt/Archchroot.bash
# generate fstab
genfstab -p -U /mnt >> /mnt/etc/fstab
# change root
arch-chroot /mnt ./Archchroot.bash
anything after that is in the second script
Offline