You are not logged in.

#1 2011-01-18 13:41:19

Charles
Member
Registered: 2011-01-18
Posts: 12

Status of automated installation

Hi,

I am new to Archlinux and testing to use it in my lab. Quite neat so far smile

I manage to do a manual install. I would like to be able to do fully automatic installs now.

I downloaded the latest archiso, and archiso-pxe-server. PXE booting is working.

I would like to know if it is possible to start the automatic procedure install automatically. This thread mentioned a "boot option mechanism" but here, it's still in the todo list.

I wasn't able to find a solution. Can you please help ? Thanks

Charles

Offline

#2 2011-01-19 18:15:34

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Status of automated installation

Arch's official installer system; AIF, features support for both interactive and automated installations.

You need to setup an automated aif config file and then you start the install with 'aif -p automatic -c /path/to/config.

There are example automated config files under /usr/share/aif/examples/, or you can take them from the AIF git repository: https://github.com/Dieterbe/aif

Important parts from the AIF git repository:

README: https://github.com/Dieterbe/aif/blob/master/README
EXAMPLES: https://github.com/Dieterbe/aif/tree/master/examples

Offline

#3 2011-01-19 18:24:46

Charles
Member
Registered: 2011-01-18
Posts: 12

Re: Status of automated installation

Thanks for clarifying but this isn't my question.

I would like to be able to launch the command "aif -p automatic -c /path/to/config" automatically.

It could be possible with two syslinux options: one for the "-p" and one for the "-c" options.

Is something like that already implemented ?

Charles

Offline

#4 2011-01-19 22:40:55

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Status of automated installation

Haha, Sorry - I just reread your post and see that im obviously a moron!

Anyway, as far as I know this hasen't been enabled yet, however it's easy to fix this yourself, though.

In the arch iso you extract the squashfs image(squashfs-tools package) and add the aif command to '/etc/rc.local' and mksquashfs the image back and remake the iso.

If you're interested, then I can post a shell script which I have made which I always run before I need to reinstall.

The script is fully automated and does the following:

  • Downloads the latest iso release.

  • Mounts it and copies it's content to a temp folder.

  • Unsquash'es the squashfs image of the temp folder.

  • Adds the aif command + 'reboot' to the unsquashed /etc/rc.local and mksquash'es the image back.

  • Generates my aif config file to the temp folder.

  • Changes isolinux.cfg so as if you don't press return within 10 secs then the local hdd is loaded instead, which means you can pop in the disc/usb-stick, press return and then walk away and some time later when you come back, then the newly installed system is waiting for you at the login promt and then you can remove the medium...

  • Change isolinux.cfg so as ISOLABEL matches the label of the generated iso made in the next step. (the modified iso won't boot if it's label isn't matching the value of ISOLABEL in isolinux.cfg, and that value changes upon each new release, so I just set both to 'ARCH')

  • Remake the iso from the contens of the temp folder.

  • Runs isohybrid(syslinux package) on the generated  iso so as to enable usb booting.

Last edited by mhertz (2011-01-19 23:26:00)

Offline

#5 2011-01-20 11:33:46

Charles
Member
Registered: 2011-01-18
Posts: 12

Re: Status of automated installation

Can you please put it on github/bitbucket/(...) ?

Offline

#6 2011-01-20 19:09:25

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Status of automated installation

I don't want to bother making an account, so I will just post it here and you can then adapt it to your specific needs...

The script needs root priviliges and have cdrkit installed(for genisoimage. The other needed stuff is autoinstalled i.e. squashfs-tools and syslinux).

#!/bin/bash
wget ftp://mirrors.kernel.org/archlinux/iso/latest/*core-x86_64.iso
wget ftp://mirrors.kernel.org/archlinux/iso/latest/md5sums.txt
grep core-x86_64.iso md5sums.txt | grep -v torrent > md5sum.txt
md5sum -c md5sum.txt || exit
mkdir source
mount -o loop archlinux-*-core-x86_64.iso source
mkdir dest
cp -a source/* dest
umount source
pacman -S squashfs-tools syslinux --noconfirm
unsquashfs dest/root-image.sqfs
echo clear >> squashfs-root/etc/rc.local
echo aif -p automatic -c /bootmnt/aif.conf >> squashfs-root/etc/rc.local
echo reboot >> squashfs-root/etc/rc.local
rm dest/root-image.sqfs
mksquashfs squashfs-root dest/root-image.sqfs
sed -i "s|archisolabel=[^ ]*|archisolabel=ARCH|" dest/boot/isolinux/isolinux.cfg
sed -i 's/TIMEOUT 3000/TIMEOUT 100/' dest/boot/isolinux/isolinux.cfg
sed -i 's/ONTIMEOUT arch/ONTIMEOUT existing/' dest/boot/isolinux/isolinux.cfg
sed -i 's/KERNEL chain.c32/localboot -1/' dest/boot/isolinux/isolinux.cfg
sed -i '/APPEND hd0 0/d' dest/boot/isolinux/isolinux.cfg
echo SOURCE=cd > dest/aif.conf
echo FILE_URL=file:///src/core/pkg >> dest/aif.conf
echo SYNC_URL= >> dest/aif.conf
echo HARDWARECLOCK=UTC >> dest/aif.conf
echo TIMEZONE=Europe/Copenhagen >> dest/aif.conf
echo RUNTIME_REPOSITORIES= >> dest/aif.conf
echo RUNTIME_PACKAGES= >> dest/aif.conf
echo TARGET_GROUPS=base >> dest/aif.conf       
echo TARGET_PACKAGES_EXCLUDE= >> dest/aif.conf 
echo TARGET_PACKAGES= >> dest/aif.conf  
echo "worker_configure_system () {" >> dest/aif.conf
echo     prefill_configs >> dest/aif.conf
echo     "sed -i 's/^HOSTNAME=\"myhost\"/HOSTNAME=\"arch\"/' \$var_TARGET_DIR/etc/rc.conf" >> dest/aif.conf
echo         "sed -i 's/^KEYMAP=\"us\"/KEYMAP=\"dk\"/' \$var_TARGET_DIR/etc/rc.conf" >> dest/aif.conf
echo } >> dest/aif.conf
echo GRUB_DEVICE=/dev/sda >> dest/aif.conf
echo "PARTITIONS='/dev/sda 5000:ext4:+ 1000:swap *:ext4'" >> dest/aif.conf
echo "BLOCKDATA='/dev/sda1 raw no_label ext4;yes;/;target;no_opts;no_label;no_params
/dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params
/dev/sda3 raw no_label ext4;yes;/home;target;no_opts;no_label;no_params'" >> dest/aif.conf
name=$(ls *.iso)
rm -rf *.iso source md5sum* squashfs-root
genisoimage -l -R -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V ARCH -o $name dest
rm -rf dest
isohybrid $name

I don't have so much going on in my aif config, since I preffer to just install a clean base system, which I then make a complete backup off afterwards(also automated with a modified clonezilla iso run from another usb stick, which backups(or restores) the root partition and the home folder), and then just run another shell script which installs and sets everything up post-install, and then make another backup of the configured system..

I can then make changes to the post-install script when I change my mind about things, and then restore the clean base system and run the post-install script afterwards, or just restore the configured system whenever I need a clean slate...

Last edited by mhertz (2011-01-20 22:23:25)

Offline

#7 2011-01-21 17:07:19

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 1,970
Website

Re: Status of automated installation

we should think about a nice way to support this officially (that's also why it's in the todo list..)
maybe by building separate images for pxe booting or something


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#8 2011-01-21 17:39:33

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Status of automated installation

Yeah, it would be nice to have official support for that, and also for non-pxe images please.

E.g. in clonezilla, then there's a boot paramter in isolinux for loading custom scripts(so as we don't need to unpack/pack the squashfs image), or maybe you could add a check for e.g. aif.conf on /bootmnt and run that if available? Then noobs could just use e.g. isomaster to add the aif config to the root, if they don't know how to mount an iso...

I dunno: you're of course better to figure these things out cleanly...

Offline

#9 2011-01-21 17:59:29

Charles
Member
Registered: 2011-01-18
Posts: 12

Re: Status of automated installation

I would be glad if I don't have to modify any iso/squashfs images.

An option of the loader (which is easy to type by hand if you boot on USB or CD and to pass through PXE) would be a very good solution for me.

Offline

#10 2011-01-21 18:22:50

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Status of automated installation

Btw, there's also mkarchiso if you want an official script for making the iso from scratch with your chossen changes(the script used by the offical release engineers also), but as I only want to change a few things i.e. the aif autoloading part, and keep everything else as offically released, then I just remake the official iso instead.

Anyway, in the meantime, then it's a piece-of-cake with my script; either change the aif settings, or strip it out and replace them with a line that instead copies your own aif config to dest...

Btw, in my script then the reason for the sed-changing of: 'KERNEL chain.c32' to 'localboot -1' and the removal of the next line, is because else the local hdd won't boot after the install/reboot, when having the usb stick still connected. The doc states that most newer systems work with that parameter, and i've also checked it on two ~10 years old systems where it also works perfectly in addition to the 3 other new systems where it also works perfectly(the original parameters failed on all 5 systems; new and old!)...

Last edited by mhertz (2011-01-21 18:42:53)

Offline

#11 2011-01-21 18:41:16

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 1,970
Website

Re: Status of automated installation

mhertz wrote:

E.g. in clonezilla, then there's a boot paramter in isolinux for loading custom scripts(so as we don't need to unpack/pack the squashfs image), or maybe you could add a check for e.g. aif.conf on /bootmnt and run that if available? Then noobs could just use e.g. isomaster to add the aif config to the root, if they don't know how to mount an iso...

I dunno: you're of course better to figure these things out cleanly...

i'm not very familiar with the archiso/pxe stuff myself. I think (?) the perfect solution would be something like this:
in /etc/rc.local, call $script, if it exists
$script is not actually on the image, but could be put in place automatically when you boot over pxe.
as sysadmin you can then make $script execute an unattended autoinstall, or invoke the interactive one, or whatever logic you need.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#12 2011-01-21 18:48:36

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 681

Re: Status of automated installation

Sound nice indeed, mate! smile

Offline

#13 2011-01-23 22:40:59

Charles
Member
Registered: 2011-01-18
Posts: 12

Re: Status of automated installation

I followed your suggestion and I think a simple solution would be to add this function in the file /etc/rc.d/archiso (from overlay.sqfs):

do_startup_script ()
{
    script="$(cmdline_param script)"
    if [ -n $script ] ; then
        stat_busy "Adding $script to rc.local"
        if [[ $script =~ ^http:// || $script =~ ^ftp:// ]] ; then
            wget "$script" -q -O /tmp/startup_script >/dev/null
        else
            cp $script /tmp/startup_script
        fi
        if [ -s /tmp/startup_script ] ; then
            chmod 755 /tmp/startup_script
            echo "/tmp/startup_script" >> /etc/rc.local
        fi
        stat_done
    fi
}

Of course, do_startup_script has to be added to the start option in the same file.

To use it, a simple "script" option has to added (possibly in pxelinux.cfg/default).

Do you think it can be a good solution ?

Last edited by Charles (2011-01-24 11:18:27)

Offline

#14 2011-01-24 12:39:43

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 1,970
Website

Re: Status of automated installation

this looks pretty cool to me, but I don't know much about archiso.
get in touch with Gerardo (djgera on the forums), he might be able to give you more tips/advice.
or maybe Thomas (brain0)
either way, this is a feature - if done properly - i would like to merge into the official code


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#15 2011-01-24 18:20:20

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 722
Website

Re: Status of automated installation

@Charles: Thanks for contact me.

Seems to looks good. Another way to do this, instead of writing to rc.local file, is using the initscripts hooks. Your code can be executed at "multi_end" wink Maybe is "a bit clear".

Offline

#16 2011-01-24 18:35:12

Charles
Member
Registered: 2011-01-18
Posts: 12

Re: Status of automated installation

Sorry but you lost me smile Can you please explain ?

If this is trivial to do, could you please add it in the official code ?

Thanks

Offline

#17 2011-01-25 00:23:51

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 722
Website

Re: Status of automated installation

Yes, something like this:

This file must be located at /etc/rc.d/functions.d/automated_script for example

. /etc/archiso/functions

automated_script ()
{
    script="$(cmdline_param script)"
    if [ -n $script ] ; then
        stat_busy "Running $script"
        if [[ $script =~ ^http:// || $script =~ ^ftp:// ]] ; then
            wget "$script" -q -O /tmp/startup_script >/dev/null
        else
            cp $script /tmp/startup_script
        fi
        if [ -s /tmp/startup_script ] ; then
            chmod +x /tmp/startup_script
            /tmp/startup_script
        fi
        stat_done
    fi
}

add_hook multi_end automated_script

Not tested.

Offline

#18 2011-01-25 13:45:38

Charles
Member
Registered: 2011-01-18
Posts: 12

Re: Status of automated installation

You made me read this wiki page: https://wiki.archlinux.org/index.php/Arch_Boot_Process. Now I understand.

I think it is a good and nice solution. I tested it and it is working.

Inclusion time ?

Offline

#19 2011-01-28 01:28:01

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 722
Website

Re: Status of automated installation

I sent the patch [#1] to arch-releng [#2], if there are no objetions I will push to master in few days wink

[#1] https://github.com/djgera/archiso/commi … 74beac401d
[#2] http://mailman.archlinux.org/pipermail/ … 01423.html

Offline

Board footer

Powered by FluxBB