User Tools

Site Tools


linux:debian:automatic-installation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:debian:automatic-installation [2013/06/20 05:38] – add note about preseed file CGI generator styblalinux:debian:automatic-installation [2013/06/25 05:06] (current) – finish up - foreword, conclusion and some other stuff stybla
Line 1: Line 1:
 ====== Debian - Automatic Installation ====== ====== Debian - Automatic Installation ======
  
-<note warning> +===== Foreword of sorts =====
-**WORK IN PROGRESS** +
- +
-NOTE to myself - preseed file can be supplied by DHCP +
-NOTE to myself - preseed generated by CGI script +
-</note>+
  
 As a pretty much any mainstream GNU/Linux distribution, even Debian allows you to automate  As a pretty much any mainstream GNU/Linux distribution, even Debian allows you to automate 
-system installation. You can either use Preseed or build a custom ramdisk and use debootstrap +system installation. You can either use Preseed or a custom built ramdisk and use debootstrap 
 directly. directly.
  
-No doubt each approach has its own pros and cons. Personally, think Preseed is sufficient for  +When I told my friend I'm looking into preseeding Debian he was like: //What's wrong with debootstrap?// 
-most cases and basic OS installation is what you (shouldwantAfter OS is sucessfully installed,  +The answer is there is nothing wrong with deboostrap and custom built ramdisk except it's a bit of work.  
-Ansible/Chef/Puppet will take over and finish the job. I really seek nothing else from OS  +So why not to use Preseeding if it can do the job? 
-installation. Preseed is capable of handling not only partitionsbut software RAID and LVM as well.  + 
-You can also run commands and do stuff, although admitingly in limited scope.+No doubt each approach has its pros and cons. I'm positive custom build ramdisk and deboostrap  
 +will be faster than installer. Also, you can add tools you need, eg. tools for HW RAID, but you  
 +can do a bit of scripting(and magic) as well, eg. assemble HW RAID prior to installation. Ramdisk can be used for  
 +rescue and debugging. As a con I see maintenance - you have to create it, script(automateit and keep it up-to-date. 
 + 
 +Preseeding has pretty much the same capabilities. It allows you to install base Debian which is, in my opinion,  
 +all you need and fine-tune the rest with Ansible/Chef/Puppet/or-alike after installation; install additional  
 +packages; support for LVM and Linux SW RAID; run additional commands; what have you. I'd almost forget you  
 +can use Preseed for installation from USB/DVD/CD as well! And it's all maintained for you. 
 +Now, here are some cons which, despite solveable, are a bit annoying. 
 + 
 +==== Cons of Debian Preseeding ==== 
 + 
 +=== Things don't always work out-of-the-box === 
 + 
 +For example I didn't have much of success with network console. It just kept segfaulting on me at "random" points. 
 +You might want to use different kernel, although replacing kernel should be the least warry and quite easy. 
 +Something can be or get broken or there is going to be some sort of regression. 
 + 
 +=== More than one Preseed configuration might be necessary === 
 + 
 +This might be due to the differences in hardware configuration. The thing isyou must specify target drive in case  
 +there is more than one drive present. And I'm sure this isn't uncommon case. However, this can be solved by simple  
 +CGI/script preseed generator which will return correct Preseed configuration file, eg. based on hostname. 
 + 
 +=== Missing tools === 
 + 
 +I believe you could easilly add whatever you want and pretty much modify netboot ramdisk in way you like
 + 
 +=== MD5 sum of Preseed config must be kept up to date === 
 + 
 +Yes, this is particularly annoying one. You can solve it in two ways. Don't use MD5 sum, however then you can't be sure  
 +about integrity of preseed file you've just downloaded. Or just integrate it into your script you have for updating TFTP  
 +boot configuration. I don't really think this is a hard one to do. 
 + 
 +=== Can't be used for rescue and/or debugging === 
 + 
 +I'm not entirely sure this is true. I also think with a bit of work and modification it very well could be. 
 + 
 +===== Conclusion of sorts =====
  
-On the other hand, customized ramdisk can provide you with universal solution - one rules them all.  +I find Debian Preseeding to be enough. It does basic Debian installation which is all I need, because after installation  
-You can add vendor specific toolsassemble HW RAIDsdebug/fix broken OSrun pre/post install tasks  +is finished, I hand it over to Ansible/Chef/Puppet/whatever to fine tune system for specific task. I don't mind the time it takes  
-via your favourite management tool etc. and create one ramdisk for OS install and rescue.+to install Debian via Installeralthough I will look into custom built ramdisk sooner or laterMore out of  
 +curiosity rather than actual needI guess. As I mentionednot every time things work out-of-the-box. However,  
 +the same can be said about everything and it's something you have to accept and be aware of - always.
  
-Now, you might argue every server(hardware configuration) is different and requires specific approach.  
-I'd counter-argue it's more about profiling and you end up with only couple profiles. I agree  
-stuff like HW RAID assembly and vendor specific tools to do that might be a problem. However, you can  
-modify Debian's netboot ramdisk and add these. Preseed allows you to run early command(s). Is it early  
-enough to assembly HW RAID? Would installer notice/update its device list? I don't know, I haven't tried. 
  
-I still think rolling with Preseed for basic OS installation is better and easier to maintain way than  
-having to maintain your customized ramdisk. Althouhg, once you automate its [ramdisk] creation, then  
-it won't matter that much. 
 ===== Customized ramdisk and debootstrap ===== ===== Customized ramdisk and debootstrap =====
  
Line 43: Line 71:
 a way it boots into shell instead of installer, add stuff you need want, remove stuff you don't need,  a way it boots into shell instead of installer, add stuff you need want, remove stuff you don't need, 
 pack it, run with it. pack it, run with it.
 +
 +
 ===== Preseeding ===== ===== Preseeding =====
  
Line 48: Line 78:
  
   * TFTP, DHCP, web server   * TFTP, DHCP, web server
 +  * [[linux:debian:apt-mirror|local Debian mirror]] can be handy, but isn't mandatory
   * time   * time
   * patience   * patience
 +
  
 ==== Example of preseed file ==== ==== Example of preseed file ====
 +
 +I've removed pretty much all comments. What's below is my preseed file. 
 +Please, see example preseed files/documentation for explanation, hints 
 +and, actually, more.
  
 <code> <code>
-Preseeding only locale sets languagecountry and locale.+### l18ni18n, keyboard
 d-i debian-installer/locale string en_US d-i debian-installer/locale string en_US
-# The values can also be preseeded individually for greater flexibility. 
 d-i debian-installer/language string en d-i debian-installer/language string en
 d-i debian-installer/country string CZ d-i debian-installer/country string CZ
-# Keyboard selection. 
 # keymap is an alias for keyboard-configuration/xkb-keymap # keymap is an alias for keyboard-configuration/xkb-keymap
 d-i keymap select us d-i keymap select us
  
 ### Network configuration ### Network configuration
-# netcfg will choose an interface that has link if possible. This makes it +# netcfg will choose an interface that has link if possible.
-# skip displaying a list if there is more than one interface.+
 d-i netcfg/choose_interface select auto d-i netcfg/choose_interface select auto
-If you have a slow dhcp server and the installer times out waiting for +In case of a slow dhcp server
-# it, this might be useful.+
 d-i netcfg/dhcp_timeout string 60 d-i netcfg/dhcp_timeout string 60
-Any hostname and domain names assigned from dhcp take precedence over +despite defined here, it must be preseeded via cmd line as well
-# values set here. Howeversetting the values still prevents the questions +
-# from being shown, even if values come from dhcp.+
 d-i netcfg/get_hostname string unassigned-hostname d-i netcfg/get_hostname string unassigned-hostname
 d-i netcfg/get_domain string unassigned-domain d-i netcfg/get_domain string unassigned-domain
-# Disable that annoying WEP key dialog.+
 d-i netcfg/wireless_wep string d-i netcfg/wireless_wep string
-If non-free firmware is needed for the network or other hardware, you can +load non-free firmware without asking
-# configure the installer to always try to load it, without prompting. Or +
-# change to false to disable asking.+
 d-i hw-detect/load_firmware boolean true d-i hw-detect/load_firmware boolean true
  
Line 86: Line 114:
 d-i mirror/protocol string http d-i mirror/protocol string http
 d-i mirror/country string cz d-i mirror/country string cz
-d-i mirror/http/hostname string debian.mirror.dkm.cz +d-i mirror/http/hostname string test-deb-01.vm.zeratul.czf
 d-i mirror/http/directory string /debian d-i mirror/http/directory string /debian
 d-i mirror/http/proxy string d-i mirror/http/proxy string
Line 98: Line 126:
  
 ### Clock and time zone setup ### Clock and time zone setup
-# Controls whether or not the hardware clock is set to UTC. 
 d-i clock-setup/utc boolean true d-i clock-setup/utc boolean true
-# You may set this to any valid setting for $TZ; see the contents of 
-# /usr/share/zoneinfo/ for valid values. 
 d-i time/zone string UTC d-i time/zone string UTC
-# Controls whether to use NTP to set the clock during the install 
 d-i clock-setup/ntp boolean true d-i clock-setup/ntp boolean true
-# NTP server to use. The default is almost always fine here. 
 d-i clock-setup/ntp-server ntp.vm.zeratul.czf d-i clock-setup/ntp-server ntp.vm.zeratul.czf
  
 ### Partitioning ### Partitioning
-## Partitioning example +this must be set in case you have more than one HDD present 
-# If the system has free space you can choose to only partition that space. +d-i partman-auto/disk string /dev/vda 
-# This is only honoured if partman-auto/method (below) is not set+possible values: regularlvmcrypto
-#d-i partman-auto/init_automatically_partition select biggest_free +
- +
-# Alternatively, you may specify a disk to partition. If the system has only +
-one disk the installer will default to using that, but otherwise the device +
-# name must be given in traditional, non-devfs format (so e.g. /dev/hda or +
-# /dev/sda, and not e.g. /dev/discs/disc0/disc). +
-# For example, to use the first SCSI/SATA hard disk: +
-#d-i partman-auto/disk string /dev/sda +
-In addition, you'll need to specify the method to use. +
-# The presently available methods are: +
-# - regular: use the usual partition types for your architecture +
-# - lvm:     use LVM to partition the disk +
-# - crypto:  use LVM within an encrypted partition+
 d-i partman-auto/method string lvm d-i partman-auto/method string lvm
-# If one of the disks that are going to be automatically partitioned +
-# contains an old LVM configuration, the user will normally receive a +
-# warning. This can be preseeded away...+
 d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/device_remove_lvm boolean true
-# The same applies to pre-existing software RAID array: 
 d-i partman-md/device_remove_md boolean true d-i partman-md/device_remove_md boolean true
-# And the same goes for the confirmation to write the lvm partitions. 
 d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm boolean true
 d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-lvm/confirm_nooverwrite boolean true
-# You can choose one of the three predefined partitioning recipes: + 
-# - atomic: all files in one partition +possible values - atomichomemulti
-# - home:   separate /home partition +
-# - multi:  separate /home, /usr, /var, and /tmp partitions+
 d-i partman-auto/choose_recipe select atomic d-i partman-auto/choose_recipe select atomic
-# This makes partman automatically partition without confirmation, provided +
-# that you told it what to do using one of the methods above.+
 d-i partman-partitioning/confirm_write_new_label boolean true d-i partman-partitioning/confirm_write_new_label boolean true
 d-i partman/choose_partition select finish d-i partman/choose_partition select finish
 d-i partman/confirm boolean true d-i partman/confirm boolean true
 d-i partman/confirm_nooverwrite boolean true d-i partman/confirm_nooverwrite boolean true
-# This makes partman automatically partition without confirmation. 
 d-i partman-md/confirm boolean true d-i partman-md/confirm boolean true
 d-i partman-partitioning/confirm_write_new_label boolean true d-i partman-partitioning/confirm_write_new_label boolean true
Line 166: Line 168:
 d-i grub-installer/only_debian boolean true d-i grub-installer/only_debian boolean true
 d-i grub-installer/with_other_os boolean true d-i grub-installer/with_other_os boolean true
-d-i grub-installer/bootdev string (hd0,0) 
  
 ### Finishing up the installation ### Finishing up the installation
 # Avoid that last message about the install being complete. # Avoid that last message about the install being complete.
 d-i finish-install/reboot_in_progress note d-i finish-install/reboot_in_progress note
-This will prevent the installer from ejecting the CD during the reboot, +don't eject CD as there isn't any
-# which is useful in some situations.+
 d-i cdrom-detect/eject boolean false d-i cdrom-detect/eject boolean false
 # Setup SSH keys for root; the last command to be run before reboot # Setup SSH keys for root; the last command to be run before reboot
-d-i preseed/late_command string wget http://test-deb-01.vm.zeratul.czf/set-ssh-keys.sh; sh set-ssh-keys.sh;+d-i preseed/late_command string wget http://test-deb-01.vm.zeratul.czf/preseed/set-ssh-keys.sh; sh set-ssh-keys.sh;
 </code> </code>
  
Line 187: Line 187:
   APPEND initrd=img/debian64-7.1.0-wheezy-initrd.img \   APPEND initrd=img/debian64-7.1.0-wheezy-initrd.img \
     auto \     auto \
-    url=http://test-deb-01.vm.zeratul.czf/preseed.cfg \+    url=http://test-deb-01.vm.zeratul.czf/preseed/preseed.cfg \
     preseed-md5=299d7a67793464e7e1e013a79660b64e \     preseed-md5=299d7a67793464e7e1e013a79660b64e \
     fb=false \     fb=false \
Line 214: Line 214:
   * **netcfg/dhcp_timeout** - just for sure   * **netcfg/dhcp_timeout** - just for sure
   * **netcfg/get_hostname**, **netcfg/get_domain** - despite set from DHCP, installer kept asking for confirmation unless defaults were passed as kernel param   * **netcfg/get_hostname**, **netcfg/get_domain** - despite set from DHCP, installer kept asking for confirmation unless defaults were passed as kernel param
 +
 +Turning off Frame Buffer(''fb'') in installer is usefull when eg. ''curses'' is used instead of ''SDL'' to display VGA output. 
 +However, turning Frame Buffer off means graphics in installer will go wonky from time to time even when running in SDL window.
 +
 +
 +==== How to configure network-console, how can it be used? ====
 +
 +<code>
 +### Network console
 +# Use the following settings if you wish to make use of the network-console
 +# component for remote installation over SSH. This only makes sense if you
 +# intend to perform the remainder of the installation manually.
 +d-i anna/choose_modules string network-console
 +d-i network-console/authorized_keys_url string http://test-deb-01.vm.zeratul.czf/preseed/authorized_keys
 +#d-i network-console/password password r00tme
 +#d-i network-console/password-again password r00tme
 +</code>
 +
 +This happens before APT repository is configured. You're presented with instructions and I believe as long 
 +as you don't click //Continue// installer will wait indefinitely. Then you can login via SSH as user 
 +''installer'' and either continue installation(I believe Preseed will be used), you can continue installation 
 +manually, or switch into shell.
 +
 +Note, however, network-console has segfaulted(Wheezy 7.1) on my on several occasions. The first was when 
 +I attempted to get into shell and second when I've clicked //Continue// in installer and tried to log-in 
 +via SSH when installation proceeded.
 +
 +
 +==== When is ''early_command'' being executed? ====
 +
 +Before APT repository is configured.
 +
 +
 +==== When is ''late_command'' being executed? ====
 +
 +Just before machine is about to be rebooted. However ''/target'' is still mounted.
  
  
Line 219: Line 255:
  
 It may, and probably will over the time, happen you'll be asked some unusual question during installation.  It may, and probably will over the time, happen you'll be asked some unusual question during installation. 
-What you should do depends whether system boots after installation is finished. I mean, I've encountered  +What you should do depends whether system boots after installation is finished. I've encountered quite weird  
-quite weird and unusual GRUB problem when I updated Debian Wheezy netboot from 7.0.0 to 7.1.0. I've failed  +problem with GRUB when I downloaded Jessie(at the time of this writing under development) netboot instead of  
-to solve it, simply because of lack of time, and I've fallen back to 7.0.0 which works just fine and confirmed  +Wheezy 7.1 and wasn't able to get the system working in the sane ammount of time. No biggie; only to demonstrate  
-problem isn't in preseed file.+it can happen - something gets changed or doesn't work out. I've used working configuration of Wheezy 7.0 to confirm  
 +there is nothing wrong with Preseed file.
  
-Ok, that was one variant - fall back to the last known working configuration. If system boots after installation +Falling back to the last known working configuration is one optionHowever, if system boots after installation 
 is finished, you can run the following command and "guess" what question(s) you were asked and add responses to  is finished, you can run the following command and "guess" what question(s) you were asked and add responses to 
-your preseed file. Don't forget to update checksum of preseed file!+your preseed file. No worries, there are comments to ease the search. Don't forget to update checksum of preseed file!
  
 <code> <code>
linux/debian/automatic-installation.1371724704.txt.gz · Last modified: 2013/06/20 05:38 by stybla