Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to run a pre-seeded config with Debian Installer (d-i)?

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
_nobody_
Posts: 62
Joined: 2018-04-10 02:07

How to run a pre-seeded config with Debian Installer (d-i)?

#1 Post by _nobody_ »

Hello to everyone,

I would like to understand the following: How to run a pre-seeding configuration using the Debian Installer (d-i), so I can build/install non-interactively Debian distro (without Graphical help)?

As I understand, there are several ways how to do this:
[1] Having Debian distro with the pressed configuration (does such Debian distro flavour exist?)?
[2] Having Debian installer (d-i) out of box (where I can find d-i as independent binary)?
[3] Having USB distro with added pre-seed configuration?
[4] You name it (waiting for other proposals)!

But I am not certain. :idea:

Thank you,
_nobody_
Last edited by _nobody_ on 2018-04-28 07:10, edited 1 time in total.


_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeding config with Debian Installer (d

#3 Post by _nobody_ »

_nobody_ wrote:[2] Having Debian installer (d-i) out of box (where I can find d-i as independent binary)?
The easiest way would be to have Debian installer (d-i) in the form of the source code, as tarball (tar.bz2), unpack it, configure, make and then make install.

Could you, please, point to me to such a thing, if it does exist (it should, since the Debian is an Open Source)?

If not, any net source of d-i source code would be cool! :mrgreen:

Thank you,
_nobody_

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: How to run a pre-seeding config with Debian Installer (d

#4 Post by llivv »

which of the Examples in the Doc from the link provided by 4D696B65 above would best fit your plan?

FAI might be another option if you need enterprise strength imaging rollout.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeding config with Debian Installer (d

#5 Post by _nobody_ »

llivv wrote:which of the Examples in the Doc from the link provided by 4D696B65 above would best fit your plan?
Good question. I assessed the situation, and the following suites me the best (in RED), seems (I need to do more exploratory work here):
Loading the preseeding file from a webserver

Most install methods you can interrupt early on and add a URL to a preseed file, for an almost fully automated installations. Here exemplified with the graphical installer:

When the graphical installer boot menu appears, press ESC
(Type "help" if you want view generic help)

Type "auto url=http://webserver/path/preseed.cfg", replacing the URL with the address to your preseed configuration file

The "auto" command launches the installation in the automated mode, where the configuration of hostname, locale and keymap are postponed so that they can be answered from the preseed file loaded from the network. You could use "install url=..." but you'd have to answer these questions manually, regardless of what you have in the preseed config. If a server path isn't specified the path 'd-i/<codename>/preseed.cfg' will be tried, for example d-i/stretch/preseed.cfg.
In other words, I unpacked .iso with xarriso, and got the RD/WR .iso directory tree:
[

Code: Select all

vuser@localhost extracted]$ ls -al
total 36
drwxr-xr-x. 9 vuser vboxusers 4096 Apr 12 12:01 .
drwxr-xr-x. 4 vuser vboxusers 4096 Apr 12 12:34 ..
drwxr-xr-x. 3 vuser vboxusers 4096 Mar 10 12:39 boot
drwxr-xr-x. 3 vuser vboxusers 4096 Apr 12 12:10 d-i
drwxr-xr-x. 2 vuser vboxusers 4096 Mar 10 12:40 .disk
drwxr-xr-x. 3 vuser vboxusers 4096 Mar 10 12:40 dists
drwxr-xr-x. 2 vuser vboxusers 4096 Mar 10 12:40 isolinux
drwxr-xr-x. 2 vuser vboxusers 4096 Mar 10 12:39 live
drwxr-xr-x. 3 vuser vboxusers 4096 Mar 10 12:40 pool
[vuser@localhost extracted]$
So, if I cd to d-i/, I see that I need to create directory stretch/ (it does NOT exist), and there I need to pass https://www.debian.org/releases/stable/ ... reseed.txt as preseed.cfg. Then I need to pack back the whole tree back to modified .iso.

Now... I have few questions to this what I wrote above.
[question] If I unpack .iso, implant d-i/stretch/preseed.cfg, and pack it back as .iso, does this mean that if I run:
## Start Debian .iso for the first time!
VBoxManage startvm $vmname --type headless

The preseed.cfg will run automatically???

Does this, what I write here, make sense, llivv? :mrgreen:

There are other problems I have noticed, but let us go step by step! :idea:

Thank you,
_nobody_

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: How to run a pre-seeding config with Debian Installer (d

#6 Post by llivv »

It looks to me like you have sharpened your learning curve big time.

First you have to adjust your config to the virtual machine.
Next, you are looking at a headless install (which is at least twice as difficult as a normal install )
As if preseeding isn't difficult enough on it own.

here are some links that may help you sort things a bit

B.1.2. Limitations
https://www.debian.org/releases/stable/ ... imitations

after you read the Limitations scroll up to the top of the page and read the Introduction.
B.1. Introduction

Debian GNU/Linux Installation Guide
https://www.debian.org/releases/stable/ ... ex.html.en

After the 8 Chapters of How to Install And Configure Debian (the normal way) ----
There are the Advanced Features:

Section A
A. Installation Howto - is an Installation How To refresher that was initally covered in Chapters 2, 3 and 4
Section B
B. Automating the installation using preseeding
Shows the reader what is involved in automating a Debian installation

I read in this forum "once", that someone who asked about a preseed file, found a premade template file that worked for them somewhere else ( didn't mention where ) and it was many years ago.

It's a lot of reading THAT IS for sure, and as the Limitations hint at getting the preseed file RIGHT is not a trivial task.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeding config with Debian Installer (d

#7 Post by _nobody_ »

llivv wrote:It's a lot of reading THAT IS for sure, and as the Limitations hint at getting the preseed file RIGHT is not a trivial task.
It is tough... Very tough! :mrgreen:

Here is the structure I re-packed back in remastered .iso:

Code: Select all

drwxr-xr-x. 3 root  root       4096 Mar 10 12:39 boot
drwxr-xr-x. 3 root  root       4096 Mar 10 12:39 d-i
drwxr-xr-x. 2 root  root       4096 Mar 10 12:40 .disk
drwxr-xr-x. 3 root  root       4096 Mar 10 12:40 dists
drwxr-xr-x. 2 root  root       4096 Apr 23 15:19 isolinux
drwxr-xr-x. 2 root  root       4096 Apr 25 09:55 live
drwxr-xr-x. 3 root  root       4096 Mar 10 12:40 pool
-rw-r--r--. 1 root  root      18619 Apr 27 14:38 preseed.cfg
I read some of the documentation, and so far I was NOT able to run it?! Everything else I have upon my sleeves:
[1] I control isolinux/ directory, and I am able to boot with the Virtual Box legacy support: VboxManage modifyvm "vmname" --firmware BIOS ;
[2] I also control boot/ directory, and I am able to boot with the Virtual Box UEFI support: VboxManage modifyvm "vmname" --firmware efi !

And I decided to do the preceeding with the UEFI support.

So, here is the option I am executing using grub2.cfg:

Code: Select all

menuentry "Debian Installer" {
  linux  /d-i/vmlinuz  "${loopback}"
  initrd /d-i/initrd.gz
}
I tried to add to the command line the following, according to the: https://www.debian.org/releases/jessie/ ... 02.html.en
you need to tell the installer what file to use when you boot it. This is normally done by passing the kernel a boot parameter, either manually at boot time or by editing the bootloader configuration file (grub.cfg) and adding the parameter to the end of the append line(s) for the kernel.
And the given example:

Code: Select all

- if you're booting a remastered CD:
  preseed/file=/cdrom/preseed.cfg
So I had the following as command line in menuentry "Debian Installer":

Code: Select all

[1] linux /d-i/vmlinuz  "${loopback}" preseed/file=/cdrom/preseed.cfg
[2] linux /d-i/vmlinuz  "${loopback}" preseed/file=/preseed.cfg
[3] linux /d-i/vmlinuz  "${loopback}" preseed/file=preseed.cfg
I also places preceed.cfg in initrd, on the / directory, but this does not work as well?!

What I am doing wrong in the examples :shock:

_nobody_

_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeded config with Debian Installer (d

#8 Post by _nobody_ »

YES... YES! YES... I was able to prevail, to make it work! :idea:

My VM headless creation, as second stage of the very complex creation of the headless Debian VM over headless VBox, on ANY Linux Distro host, is somehow (VERY FAR from ideal) working! Amazingly, I am able to login into Debian Stretch headless VM creation! :D

But still, the previous topic on this thread I was NOT able to solve... I solved it by different means. :mrgreen:

Lot of work ahead of me. Imagine, at the end of the day if I am able to create 100,000 headless VMs in matter of an half of hour, on Cloud! What the computing power of this mad creation will be?! :twisted:

_nobody_

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: How to run a pre-seeded config with Debian Installer (d-

#9 Post by llivv »

Historically, that is one reason installation used to ( and still do on occasion ) fail.
The new order of disks and/or drives after a new installation, could/would leave a new installation non-booting ( after the disk/drive containing the installation media is removed from the machine).

Whichever boot loader one uses. that bootloader will not always see disk/drive order the same as the installer software saw the disk order during install.

That is also sometimes the case with the partitioning program as well.

UUID's were implemented to reduce that confusion to an extent but there was a trade off which meant the bootloader recovery became more difficult/complex.

Naturally, as one adds more layers of disk management and virtualization convenience to a machine the complexity of disk/drive order begins to grow exponentially.

Here's a good example of why Debian recommends not to use unetbootin as a bootloader.
http://forums.debian.net/viewtopic.php? ... 3&start=15
besides the irony of the linked thead being populated with posts mostly by members with a post count of one post,
it's also not a debootstrap error as the title of the thread suggests.
It does give another view of the confusion when an installation does not boot and some of the reasons why.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeded config with Debian Installer (d-

#10 Post by _nobody_ »

matador86 wrote:When I install debian using the preseeded file, I have a live USB stick mounted as sda1 and ssd drive as sdb1. So I install MBR to sdb1. But when USB stick is removed SSD drive becomes sda1. And /boot/grub/grub.cfg does not work any more. I added a late command in order to fix that according to the documentation. It is simple and works if I run it manually on machine but fails in preseed (after restart the grub config file still has paths to sdb1).

Code: Select all

d-i preseed/late_command string 
in-target sed -i 's/root\=\/dev\/sdb1/root\=\/dev\/sda1/g' /boot/grub/grub.cfg;
in-target update-grub;
[url=https://showbox.onl/][color=#000000]ShowBox[/color][/url] [url=https://vidmate.onl/][color=#000000]VidMate[/color][/url] [url=https://mobdro.onl/][color=#000000]Mobdro[/color][/url]
So what is wrong here from the perspective of preseed?
I did understand what you are talking here just yesterday. Since I hit the stumbling block in this area, so I needed to read in-depth and understand more than glancing. :mrgreen:

It is all about this command:

Code: Select all

d-i grub-installer/bootdev string /dev/sda
Unfortunately, I have no idea how to solve this problem during the actual installation. I have no idea how to fork in preseed.cfg (if it is at all possible, which I think it is not).

Googling around, I found the following:

Code: Select all

d-i preseed/late_command string \
    in-target sed -i 's/user: debian/user: gc3-user/g; s/^\( *name:\) debian/\1 gc3-user/g; s/disable_root.*/disable_root: 0/' /etc/cloud/cloud.cfg; \
    in-target sed -i 's/\(^ *GRUB_CMDLINE_LINUX_DEFAULT\) *=.*/\1="console=tty0 console=ttyS0"/g; s/^ *GRUB_TERMINAL=.*/GRUB_TERMINAL=console/g' /etc/default/grub; \
    in-target update-grub; \
    in-target sed -i 's/datasource_list.*/datasource_list: [ NoCloud, Ec2, OpenStack ]/g' /etc/cloud/cloud.cfg.d/90_dpkg.cfg; \
    echo "gc3-user	ALL=(ALL) NOPASSWD:ALL">>/target/etc/sudoers; \
    sed -i "s:exit.*::g" /target/etc/rc.local; \
    echo -e "for key in rsa dsa ecdsa; do keyfile=/etc/ssh/ssh_host_\${key}_key; [ -f \$keyfile ] || ssh-keygen -t \$key -q -N '' -f \$keyfile; done;\n" >> /target/etc/rc.local; \
    echo 'ifconfig -a | grep ^eth| sed "s/ .*//" | while read iface; do grep -q "^iface $iface" /etc/network/interfaces || (echo -e "auto $iface\niface $iface inet dhcp\n" >> /etc/network/interfaces; ifup $iface); done;' >> /target/etc/rc.local; \
echo -e '\nexit 0' >> /target/etc/rc.local
Thus, your string of the presented commands:

Code: Select all

d-i preseed/late_command string 
in-target sed -i 's/root\=\/dev\/sdb1/root\=\/dev\/sda1/g' /boot/grub/grub.cfg;
in-target update-grub;
Might be with syntax errors. You might try to correct the command, to be something like this:

Code: Select all

d-i preseed/late_command string \
    in-target sed -i 's/root\=\/dev\/sdb1/root\=\/dev\/sda1/g' /boot/grub/grub.cfg; \
    in-target update-grub
Please, let us know if this hint solves your problem? :idea:

Actually, I'll have also some questions about your setup? But... One step at the Time. :wink:

_nobody_

_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeded config with Debian Installer (d-

#11 Post by _nobody_ »

llivv wrote:Here's a good example of why Debian recommends not to use unetbootin as a bootloader.
http://forums.debian.net/viewtopic.php? ... 3&start=15
besides the irony of the linked thead being populated with posts mostly by members with a post count of one post,
it's also not a debootstrap error as the title of the thread suggests.
It does give another view of the confusion when an installation does not boot and some of the reasons why.
Hello llivv,

Do not use unetbootin (even I do not know what it is?)... :mrgreen:

I use always ONLY grub, for legacy 1.99. for UEFI 2.0.2

Basically, I solved both boots:

Code: Select all

[legacy] isolinux/isolinux.cfg
[UEFI] boot/grub/grub.cfg
Although I do everything as generic scripting, I have to have two distinct preseed.cfg files for legacy and for UEFI boots. Legacy is just subset of UEFI (there are few lines more added in UEFI preseed.cfg, namely to make /boot/efi partition as an addition to partman configuration)!

I need to solve just one more problem at the end of the stage [2] Debian VM preseed/headless configuration . :shock:

I actually have three stage rocket to launch Debian VM:

Code: Select all

•	[1] Virtual Box (VMM) headless configuration
•	[2] Debian VM preseed/headless configuration
•	[3] Debian VM provisioning 
So, basically, I need to finish stage 2, and make stage 3 working (I have it already, but I need to build cradle for it/provisioning script).

Well... I am closing, I guess, on these guys: https://www.hashicorp.com/ :twisted:

_nobody_

Manley369
Posts: 1
Joined: 2018-06-30 05:15

Re: How to run a pre-seeded config with Debian Installer (d-

#12 Post by Manley369 »

Put only a single space or tab between type and value: any additional whitespace will be interpreted as belonging to the value.

A line can be split into multiple lines by appending a backslash (“\”) as the line continuation character. A good place to split a line is after the question name; a bad place is between type and value. Split lines will be joined into a single line with all leading/trailing whitespace condensed to a single space.

For debconf variables (templates) used only in the installer itself, the owner should be set to “d-i”; to preseed variables used in the installed system, the name of the package that contains the corresponding debconf template should be used. Only variables that have their owner set to something other than “d-i” will be propagated to the debconf database for the installed system.

Most questions need to be preseeded using the values valid in English and not the translated values. However, there are some questions (for example in partman) where the translated values need to be used.

Some questions take a code as value instead of the English text that is shown during installation.

Start with #_preseed_V1

_nobody_
Posts: 62
Joined: 2018-04-10 02:07

Re: How to run a pre-seeded config with Debian Installer (d-

#13 Post by _nobody_ »

javimuro wrote:When I install debian using the preseeded file, I have a live USB stick mounted as sda1 and ssd drive as sdb1. So I install MBR to sdb1. But when USB stick is removed SSD drive becomes sda1. And /boot/grub/grub.cfg does not work any more. I added a late command in order to fix that according to the documentation. It is simple and works if I run it manually on machine but fails in preseed (after restart the grub config file still has paths to sdb1).
Interesting problem. Regarding text in RED, should you have it another way around: live USB stick as sdb1, and SSD drive as sda1? :?:

(I am back to the preseed domain, to learn more, since I needed some time to make living, and make some monies to pay the bills).

Thank you,
_nobody_

Post Reply