9

I've tried reading through guides for preseeding and customization, but I did not understand how and where to modify which options. I can only comfortably learn through practical examples, for which I ask this question.

I am looking into preseeding and customizing solution to just do a few specific tasks:

  • Completely rewrite the packages installed by default, much like minimal installs and with the --no-install-recommends flag of apt-get.
  • Add a few proprietary applications to the default install list
  • Automatically install and mount proprietary drivers on install and live session
  • Edit the default configuration files for applications installed by default
  • Specify partitions along with permission
  • Modify the package pool in the installer media (CD/DVD/USB), preferably using command line tools similar to apt-get and aptitude.

Can anyone please tell me how to configure preseed option to only do the above?

NB I do not understand the GPG part after adding/removing packages in the pool.

PS The third point is of particular importance.

Oxwivi
  • 17,589
  • 53
  • 136
  • 197

2 Answers2

6

For a reference preseed, you might like to refer to installation-guide-i386 which contains the following sample preseed:

  /usr/share/doc/installation-guide-i386/example-preseed.txt.gz
  • Completely rewrite the packages installed by default, much like minimal installs
  • Add a few proprietary applications to the default install list

To provide the list of packages you want installed, you might like to look for the following line:

  tasksel tasksel/first   multiselect ubuntu-desktop

Where "ubuntu-desktop" can be changed for an arbitrary number of packages or meta packages.

  • Automatically install and mount proprietary drivers on install and live session

Other that specifying the packages needed (for the proprietary drivers), I'm not sure how this would be accomplished. As a side note, you "mount" a partition, you "load" a kernel module/driver.

  • Edit the default configuration files for applications installed by default

To make those kind of scripted changes, you probably want to look into:

  d-i preseed/late_command string ...

Where the "..." can be replaced with arbitrary commands like sed -i for example.

  • Specify partitions along with permission

There's a partition section in the example preseed mentioned above.

Ubiquity with preseed

Casper supports preseed and ubiquity can have many values preseeded. Here are some of the variables that can be preseeded relevant to ubiquity:

ubiquity countrychooser/shortlist select US
ubiquity languagechooser/language-name select English
ubiquity localechooser/supported-locales multiselect en_US.UTF-8
ubiquity ubiquity/summary note
ubiquity ubiquity/reboot boolean true
ubiquity ubiquity/poweroff boolean true
ubiquity ubiquity/success_command string ...

Where "..." would contain the same as the late_command mentioned above, success_command is read by ubiquity and late_command by d-i.

komputes
  • 3,183
  • 5
  • 27
  • 31
  • Is there no way to change configuration files beforehand? How do I prevent the installation of recommended packages? How do I add proprietary packages for offline installation? – Oxwivi Mar 10 '11 at 18:16
  • Sounds like you want to create a custom image, as described here: https://help.ubuntu.com/community/LiveCDCustomization The image can also contain a preseed file where you can change configuration files as described before. Another approach is that you can also create your own packages for some of the customizations. – komputes Mar 11 '11 at 17:48
  • Okay, forget changing configuration, do I need to custom CD instructions to include packages not present in the disk by default? – Oxwivi Mar 11 '11 at 19:19
  • I mounted an image, copied the contents to a directory, modified Ubiquity parameters. How do I finalize it? – Oxwivi Mar 12 '11 at 18:45
  • To finalize/build the ISO image follow the chatter entitled "Producing the CD image" here: help.ubuntu.com/community/LiveCDCustomization – komputes Mar 14 '11 at 16:17
3

The following creates a modified boot image. Burn it to a CD, or insert the ISO into a VM to test it. You'll need cpio and genisoimage (that's the names of the packages and executables).

The following is in the form of a Makefile, but can be entered interactively. ${IN_ISO} refers to the original ISO image (I used the -alternative version, and I'd suggest you do the same), ${OUT_ISO} to the desired ISO name.

# Extract the ISO image to mount/ and copy it to cdroot/
cdroot:
    mkdir -p mount
    sudo mount -o loop ${IN_ISO} mount
    mkdir cdroot
    cd cdroot && tar cf - ../mount --transform 's,^mount/,,' | tar xf -
    sudo umount mount && rm -r mount
    chmod -R a+rw cdroot

# Copy new files to the disk. Content of those files is posted below
prepare: cdroot
    cp isolinux.cfg cdroot/isolinux/isolinux.cfg
    test -e ./initrd.orig.gz || cp cdroot/install/initrd.gz ./initrd.orig.gz
    mkdir -p initrd
    cd initrd && gunzip <../initrd.orig.gz | sudo cpio -i && cd ..
    cp preseed.cfg initrd/preseed.cfg
    cd initrd && find . | cpio -o --format=newc | gzip -9 > ../cdroot/install/initrd.gz && cd ..
    sudo rm -rf initrd

# Create the ISO image. Make sure to use extensions for lower-case filenames    
iso: cdroot prepare
    genisoimage -o ${OUT_ISO} \
        -force-rr -J \
        -b isolinux/isolinux.bin -c isolinux/boot.cat \
        -no-emul-boot -boot-load-size 4 -boot-info-table \
        cdroot

You need some additional files:

isolinux.cfg configures the boot loader. You want it to just boot, and automatically go through the installation process. It should look like this:

default install
label install
  menu label ^Install my custom Ubuntu
  kernel /install/vmlinuz
  append auto initrd=/install/initrd.gz --
# Leave 2 seconds to abort or debug
prompt 1
timeout 20

That's all the preparations we need before actually configuring the installation. Download the preseed example and name it preseed.cfg. Go through it and edit whatever you want. Important options are:

# Locale
d-i debian-installer/locale string en_US
d-i time/zone string US/Eastern

# Partitioning. The following settings WILL OVERWRITE ANYTHING
# Don't insert the CD into your boss' computer ...
d-i partman-auto/method string regular
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# To create a normal user account.
d-i passwd/user-fullname string Ubuntu User
d-i passwd/username string ubuntu
d-i passwd/user-password password insecure
d-i passwd/user-password-again password insecure
d-i user-setup/allow-password-weak boolean true

# Package selection. Don't include ubuntu-desktop to significantly reduce the content
tasksel tasksel/first multiselect standard

#d-i preseed/early_command string driver installation commands (stuff needed to boot)
#d-i preseed/late_command string driver installation commands, custom software, etc.

But I'd suggest you don't use the above as an example, but download Ubuntu's example and configure it to your needs with late_command, you can do anything from shell, including downloading and executing a script that installs and configures your custom software. For example, use this as late_command:

d-i preseed/late_command string in-target sh -c 'wget https://example.com/my/install.sh && sh install.sh'

Alternatively, you can place install.sh in the initrd above and execute it directly. Its content could look like this:

#!/bin/sh
aptitude install -y x11-apps any-package-you-want-installed
wget http://proprietary.com/drivers/for/ubuntu.tar.gz -O- | tar xf - && sh drivers/instal.sh

It really depends on how your proprietary driver installation routine works.

phihag
  • 435
  • 3
  • 11
  • Like I said in the question, I want guidance on how exactly to the tasks I listed; how do I rewrite the packages that's going to be installed? What about the auto installation of proprietary drivers? – Oxwivi Mar 09 '11 at 09:34
  • @Oxwivi Write a script that installs everything you want, and download and execute it with `late_command`. `Package selection` is the part you can use to install your own packages, but you can also do it in the script. – phihag Mar 09 '11 at 09:37
  • Updated with an example of package and proprietary driver installation. – phihag Mar 09 '11 at 09:43
  • Okay, I'm beginning to comprehend how it works but, I wanted the drivers to be automatically installed from the disk itself - I don't know if you are aware of it or not, but the proprietary drivers are available in the ISOs of Ubuntu images as I installed them without internet connection. – Oxwivi Mar 09 '11 at 10:00
  • Looks like I need to post another question on how to script installing and configuring proprietary drivers. – Oxwivi Mar 09 '11 at 10:01
  • @Oxwivi Sorry, I thought you wanted to install your own drivers, not the non-free Ubuntu ones. But that's no problem: Just add the package names in the `tasksel` section. Add `d-i mirror/udeb/components multiselect main, restricted, universe, multiverse` to the preseed file to enable proprietary Ubuntu repositories. Oh, and scripting installing and configuring is trivial: Just copy whatever you type in an interactive console to the install script (and set a few flags, i.e. `-y` for package managers, to suppress questions). – phihag Mar 09 '11 at 10:08
  • Example please? I learn best from practical examples as opposed to instructions. You having showed me examples and explained what they do made me finally understand how the aspects or preseeding I need works. Thanks! – Oxwivi Mar 09 '11 at 10:11
  • @Oxwivi I updated the answer with a schematic for that installation script. For example, if you want to install the package 2ping, add `aptitude install -y 2ping` to the configuration script. If you want to add a configuration, locate the configuration file in `etc`(let's say `/etc/2ping.conf`) and add the configuration option, like `echo "verbose-level 3" >> /etc/2ping.conf`. Sorry, but it really depends on what you want to install. – phihag Mar 09 '11 at 10:16
  • No, I want examples of how to install proprietary drivers. Argh, I wish it was more forum thread-like for drawn out discussions like these. Sorry for all the trouble. – Oxwivi Mar 09 '11 at 10:19
  • @Oxwivi Proprietary drivers are regular packages too, just built from binary sources. For example, to install the newest nvidia drivers, you would use `apt-get --purge remove xserver-xorg-video-nouveau && aptitude -y install nvidia-glx-new linux-restricted-modules` – phihag Mar 09 '11 at 10:28
  • In my case it's my wireless, not graphics card. I was not able to install it without `jockey` (Additional Drivers and it's command line counterpart), which I don't want to install just because of one single driver. And I'm a part of a(n unofficial) LoCo, so I was looking for a a generic way to install any kinds of proprietary drivers during installation. – Oxwivi Mar 09 '11 at 10:35
  • 1
    @Oxwivi You can install jockey and later remove it with `aptitude purge jockey` in a script. I'm not sure what you mean by a "generic way to install any kinds of proprietary drivers". This is a *generic way* to install any restricted drivers, just put the package of the driver you're installing into tasksel or after `aptitude install -y` in the script, and it will work. If you want your image to work on multiple machines, you'll probably have to find a way to ask jockey for all applicable proprietary drivers. ... – phihag Mar 09 '11 at 10:44
  • 1
    @Ocwivi ... However, installing all available proprietary drivers is generally a bad idea: Proprietary drivers are usually old, unsupported and require additional non-standard configuration. Also, you must make sure you're **legally allowed** to distribute non-free drivers. – phihag Mar 09 '11 at 10:47
  • Well, I trust the proprietary drivers that come with Ubuntu. And I want to install them if they're required. – Oxwivi Mar 09 '11 at 11:13
  • 1
    @Oxwivi That trust is unfounded, given that anyone can put anything in the non-free repositories. However, this discussion is far out of scope for this question (about preseeding). You should ask how one gets a list of applicable proprietary drivers for the current system. – phihag Mar 09 '11 at 13:17
  • I've done that, and found `jockey-common` is simply a wrapper for Python scripts - now to figure out which one does what... In any case, as soon as I've figured out everything I want on my installer, I'll be loaded with more questions, thanks for all the help and patience! – Oxwivi Mar 09 '11 at 13:58
  • Installing a distribution loads a Linux session, right? Do you know what applications are loaded and how to add applications to that list? – Oxwivi Mar 10 '11 at 16:27
  • @Oxwivi Yes, you could say that. However, applications are not "loaded" in the command-line environment, but executed (and normally only in sequential fashion). As I mentioned in my answer, you can make programs execute by adding them to the `late_command` option. For example, to calculate 1+1 and write it to the root directory, you'd add `in-target sh -c 'expr 1 + 1> /addition.result'` to `late_command`. – phihag Mar 10 '11 at 18:12
  • Well, what applications are there for me to use, and how I can add more? – Oxwivi Mar 10 '11 at 18:21
  • @Oxwivi All applications are available `in-target`, but only a very limited subset (a stripped-down `busybox` out of that). The only limitation is that some basic services (such as audio and graphical servers) are not available during installation. You can add more by adding the respective packages to `d-i pkgsel/include` or including the applications in your initrd. – phihag Mar 10 '11 at 18:39
  • I ran into a issue with preseed.cfg, I posted it as a new question (http://askubuntu.com/questions/85744/preseed-file-being-ignored-during-installation). Has anyone else ran into a issue with preseeding? – Curtis Hall Dec 06 '11 at 22:48