Unattended FreeBSD installation

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Unattended FreeBSD installation

Simon Ser
Hi all,

For the purposes of a CI service [1], I want to write a script that
generates a fresh qcow2 FreeBSD image. So far I've been using
bsdinstall(8) and this has been working well when testing locally [2].
However this doesn't work when run from SSH because bsdinstall(8) uses
dialog(1), which requires a TTY (or fails).

I've been wondering: you offer qcow2 images available for download on
your website, but how are these generated? I don't think I can use these
directly since I need to enable sshd, but I could probably re-use your
image generation script.

If it's not possible to use the same script, do you have suggestions to
make it work?

Thanks,

[1]: https://sr.ht
[2]: https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/master/images/freebsd/genimg

--
Simon Ser
https://emersion.fr


_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Unattended FreeBSD installation

Freddie Cash-8
On Tue, Feb 5, 2019 at 3:14 PM Simon Ser <[hidden email]> wrote:

> For the purposes of a CI service [1], I want to write a script that
> generates a fresh qcow2 FreeBSD image. So far I've been using
> bsdinstall(8) and this has been working well when testing locally [2].
> However this doesn't work when run from SSH because bsdinstall(8) uses
> dialog(1), which requires a TTY (or fails).
>

Have you tried with -t added to the ssh command?  -t will tell ssh to
allocate a pseudo-TTY:

    -t      Force pseudo-terminal allocation.  This can be used to execute
             arbitrary screen-based programs on a remote machine, which can
be
             very useful, e.g. when implementing menu services.  Multiple -t
             options force tty allocation, even if ssh has no local tty.

--
Freddie Cash
[hidden email]
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Unattended FreeBSD installation

Andrey Fesenko
In reply to this post by Simon Ser
On Wed, Feb 6, 2019 at 2:13 AM Simon Ser <[hidden email]> wrote:

>
> Hi all,
>
> For the purposes of a CI service [1], I want to write a script that
> generates a fresh qcow2 FreeBSD image. So far I've been using
> bsdinstall(8) and this has been working well when testing locally [2].
> However this doesn't work when run from SSH because bsdinstall(8) uses
> dialog(1), which requires a TTY (or fails).
>
> I've been wondering: you offer qcow2 images available for download on
> your website, but how are these generated? I don't think I can use these
> directly since I need to enable sshd, but I could probably re-use your
> image generation script.
>
> If it's not possible to use the same script, do you have suggestions to
> make it work?
>

What not use make vm-release https://adventurist.me/posts/0283

If you use openstack may be need patch
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213396
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Unattended FreeBSD installation

Eugene Grosbein-10
In reply to this post by Simon Ser
06.02.2019 6:12, Simon Ser wrote:

> Hi all,
>
> For the purposes of a CI service [1], I want to write a script that
> generates a fresh qcow2 FreeBSD image. So far I've been using
> bsdinstall(8) and this has been working well when testing locally [2].
> However this doesn't work when run from SSH because bsdinstall(8) uses
> dialog(1), which requires a TTY (or fails).
>
> I've been wondering: you offer qcow2 images available for download on
> your website, but how are these generated? I don't think I can use these
> directly since I need to enable sshd, but I could probably re-use your
> image generation script.
>
> If it's not possible to use the same script, do you have suggestions to
> make it work?

In fact, there is absolutely nothing sacral in generating bootable FreeBSD image.

Just create empty directory and use tar to extract two files
from ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/11.2-RELEASE/ there:
kernel.txz, base.txz (and optionally ports.txz).

Add local files and configs, maybe packages.
chroot(8) is handy if target arch is same as of build box
Don't forget to mount devfs before running commands with chroot: mount -t devfs devfs $mountpoint

Determine total size with "du -s" and create UFS image with makefs(8) using -s flag
to specify size of an image adding some spare space for future use.

Attach generated UFS image using mdconfig to get /dev/md0 and add bootstrap code to the image:
gpart bootcode -b /boot/boot /dev/md0

Finally, wrap generated image into your container of choice (qcow2 or MBR or GPT partitioning etc.)
Maybe you'll need to add primary bootstrap code depending on container type.
That would be "gpart bootcode -b /boot/mbr ..." in face of disk image with MBR partitioning
that also would need extra "gpart set -a active -i 1" call to mark partition bootable.

That's all.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Unattended FreeBSD installation

Simon Ser
On Wednesday, February 6, 2019 12:34 AM, Eugene Grosbein <[hidden email]> wrote:
> In fact, there is absolutely nothing sacral in generating bootable FreeBSD image.

Thanks for your suggestion! (Actually, thanks everybody for their
replies -- it's very helpful)

I finally managed to write a script to generate images, with a lot of
help from Dave Cottlehuber [1]. The full image generation script is
available at [2].

[1]: https://hackmd.io/s/SJRD7QRNE
[2]: https://git.sr.ht/~sircmpwn/builds.sr.ht/tree/master/images/freebsd/genimg
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Unattended FreeBSD installation

Austin Shafer
Hi Simon,

While I know this isn't exactly what your initial post was looking for,
I wrote a similar script a short while ago that would make custom iso
images (including unattended installs). I've linked it below in case you
(or anyone else) might find it useful.

https://github.com/ashaferian/packmule

- Austin Shafer
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"