-1

I had a task of deploying Ubuntu Desktop 16.04 on multiple machines with Windows 10 on them. Of course, to accomplish the task efficiently, I needed to find a way to install automatically.

I asked Google, found various manuals, tried all of them... And that's where I stuck. No matter what I did, I always had the Choose installation type question. As a bonus, I learned that the official documentation is terribly outdated, that there are several types of syntax and all of them don't work at all...

In the end, I saw the light at the end of the tunnel. So as to let others to not have the same struggle as I had, here's the how-to. It's guaranteed to work, given the prerequisites are satisfied.

So:

A question:

How do I make a completely automatic installation of Ubuntu 16.04, if I have a computer or computers with an already installed system (Microsoft Windows, for example)? And how to make it install programms I need after the new system is ready?

1

Firstly, you need to satisfy the next conditions, otherwise there's no guarantee it'll work, if, say, you have a computer with two disks or will choose MBR mode:

  • Ubuntu 16.04;
  • The machine has only one disk;
  • You don't need the contents on it as all the data is going to be erased;
  • UEFI mode is choosed;
  • The machine is connected to the Internet by a wire. If not, it would install, but without drivers and updates.

Then:

  1. Download the image:

    wget http://releases.ubuntu.com/16.04.3/ubuntu-16.04.3-desktop-amd64.iso
    
  2. Extract it:

    cd folder
    xorriso -osirrox on -indev ubuntu-16.04.3-desktop-amd64.iso -extract / custom-iso
    
  3. Edit the config of GRUB, e.g. with nano:

    sudo nano boot/grub/grub.cfg
    

    and add the following:

    if loadfont /boot/grub/font.pf2 ; then  
      set gfxmode=auto  
      insmod efi_gop  
      insmod efi_uga  
      insmod gfxterm  
      terminal_output gfxterm  
    fi  
    
    set menu_color_normal=white/black  
    set menu_color_highlight=black/light-gray  
    set default=0  
    set timeout=1  
    
    menuentry "Install Ubuntu" {  
        set gfxpayload=keep  
        linux    /casper/vmlinuz.efi file=/cdrom/preseed/ks.seed  auto=true priority=critical debian-installer/locale=ru_Ru keyboard-configuration/layoutcode=us ubiquity/reboot=true languagechooser/language-name=Russian countrychooser/shortlist=RU localechooser/supported-locales=ru_RU.UTF-8 boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet splash noprompt noshell ---  
        initrd    /casper/initrd.lz  
    }  
    

    Pay attention to such parameters as locale, layoutcode, languagechooser and etc. and edit correspondingly.

  4. Create the config for the Ubuntu installer, e.g. with nano:

    sudo nano preseed/ks.seed
    

    and add the following:

    ubiquity partman-auto/disk string /dev/sda  
    ubiquity partman-auto/method string regular  
    ubiquity partman-lvm/device_remove_lvm boolean true  
    ubiquity partman-md/device_remove_md boolean true  
    ubiquity partman-auto/choose_recipe select atomic  
    
    d-i partman-partitioning/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  
    d-i partman-md/confirm_nooverwrite boolean true  
    d-i partman-lvm/confirm_nooverwrite boolean true  
    d-i partman-efi/non_efi_system boolean true  
    
    d-i debian-installer/locale string ru_RU  
    d-i console-setup/ask_detect boolean false  
    d-i console-setup/layoutcode string us  
    
    d-i netcfg/get_hostname string unassigned-hostname  
    d-i netcfg/get_domain string unassigned-domain  
    d-i netcfg/choose_interface select auto  
    
    d-i clock-setup/utc-auto boolean true  
    d-i clock-setup/utc boolean true  
    d-i time/zone string Europe/Moscow  
    d-i clock-setup/ntp boolean true  
    
    d-i mirror/country string RU  
    d-i apt-setup/multiverse boolean true  
    d-i apt-setup/restricted boolean true  
    d-i apt-setup/universe boolean true  
    
    d-i passwd/user-fullname string User  
    d-i passwd/username string user  
    d-i passwd/user-password-crypted password sOlSUKAdMoT5M  
    d-i passwd/user-default-groups string adm audio cdrom dip lpadmin sudo plugdev sambashare video  
    
    d-i grub-installer/grub2_instead_of_grub_legacy boolean true  
    d-i grub-installer/only_debian boolean true  
    d-i finish-install/reboot_in_progress note  
    
    ubiquity ubiquity/success_command \  
        string echo "auto enp0s3" >> /etc/network/interfaces; \  
               echo "iface enp0s3 inet dhcp" >> /etc/network/interfaces; \  
               ifup enp0s3; \  
               apt-get update -y; \  
               in-target apt-get install -y openssh-server;  
    

    By the way, pay attention to an unsaid feauture of Ubiquity. Just right before launching the success_command section it shutdowns the interfaces (amusing, right?), so to install something from the Internet you have to configure an interface first.

    And forgot to mention, the password to User here is 'qwerty123'. I strongly recommend to change it afterwards.

  5. Finally, compile a new image:

    sudo mkisofs -D -r -V "UNATTENDED_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ~/ubuntu/custom-http.iso ~/ubuntu/custom-iso/
    

    And you're good to go.

That's all. I hope that walkthrough would help to someone. Special thanks to Just_a_fake_account and the others from Linux Mint forum, who helped to solve the puzzle.

| improve this answer | |
  • But I've already done that. See, how indented the text in the answer is? – Mexanizator Feb 22 '18 at 15:19
  • @dessert Thanks to you guys too! :) By the way, isn't the code area supposed to be somehow outlined comparing to the text? You know, like a text when it's quoted. – Mexanizator Feb 22 '18 at 15:39
  • You may want to format the code in Step 5 as a one long string rather than three lines. This makes it easier to copy and paste. – user68186 Feb 22 '18 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.