preseed/late_command ubuntu 14.04

preseed/late_command ubuntu 14.04

我正在使用 preseed 设置 Ubuntu 14.04 的自动安装。我使用虚拟机 (virtualBox 机器) 对此进行了测试。一切都安装正常,没有任何问题,但我不太明白如何使用 preseed 文件末尾的 late_command。

我第一次想要做的是运行start.sh脚本。

我尝试了几次:

代码如下:

d-i preseed/late_command string cp /cdrom/start.sh /target/home/user; in-target chmod 700 /home/user/start.sh; /home/user/start.sh

还:

d-i preseed/late_command string chroot /target; cp -f /cdrom/start.sh /home/user; chmod 700 /home/user/start.sh;

第三次尝试:

 d-i preseed/late_command string cp -f /cdrom/start.sh /home/user; in-target chmod +x /home/user/start.sh; in-target sh start.sh

脚本start.sh定义一个命令:

#! /bin/sh 
echo "bonjour" > /home/user/bonjour_file

我也尝试在新机器上安装后创建一个文件:

d-i preseed/late_command string in-target touch /etc/postinst_user.done

preseed preseed/late_command string in-target touch /etc/postinst_user.done

但它只是在安装的最后挂起了。安装功能正常,但脚本根本没有运行,文件“postinst_user.done”也没有创建。

新安装的文件系统是否安装在 /target 下?此时安装的环境是什么样的?正确的做法是什么?

这是名为“ubuntu.seed”的整个预置文件:

# Enable extras.ubuntu.com.
d-i apt-setup/extras    boolean true
# Install the Ubuntu desktop.
tasksel tasksel/first   multiselect ubuntu-desktop
# On live DVDs, don't spend huge amounts of time removing substantial
# application packages pulled in by language packs. Given that we clearly
# have the space to include them on the DVD, they're useful and we might as
# well keep them installed.
ubiquity    ubiquity/keep-installed string icedtea6-plugin openoffice.org
d-i  base-installer/kernel/altmeta   string lts-xenial
####################################################################
# General
####################################################################
# Once installation is complete, automatically power off.
# d-i finish-install/reboot_in_progress note
#d-i debian-installer/exit/poweroff boolean true
#d-i ubiquity/summary note
#ubiquity ubiquity/reboot boolean true
#ubiquity ubiquity/poweroff boolean true
# Once installation is complete, automatically power off.
# d-i finish-install/reboot_in_progress note
#d-i debian-installer/exit/poweroff boolean true
#d-i ubiquity/summary note
#ubiquity ubiquity/reboot boolean true
#ubiquity ubiquity/poweroff boolean true
####################################################################
# Partitioning
####################################################################
# Configure auto partitioner
#ubiquity partman-auto/init_automatically_partition select Guided - use entire disk
#ubiquity partman-auto/disk string /dev/sda
#ubiquity partman-auto/method string regular
#ubiquity partman-auto/choose_recipe select All files in one partition (recommended for new users)
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/choose_recipe select atomic
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
####################################################################
# Locale
####################################################################
d-i debian-installer/locale string en_US
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string fr
# Optionally specify additional locales to be generated
d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8
###################################################################
# Localizations / Timezone
####################################################################
### Keyboard selection ###
d-i keyboard-configuration/layoutcode string fr
d-i keyboard-configuration/variantcode string
### Clock and Timezone ###
#see the contents of /usr/share/zoneinfo/ for valid values
d-i time/zone select Europe/Paris
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean false

####################################################################
# User Creation
####################################################################
d-i passwd/user-fullname string user
d-i passwd/username string user
d-i passwd/user-password password xxxxxx
d-i passwd/user-password-again password xxxxx
#d-i passwd/user-default-groups string adm audio cdrom dip lpadmin sudo plugdev sambashare video
#d-i passwd/root-login boolean true
#d-i passwd/root-password-crypted password hPdFxI2FOMtZk
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
#d-i passwd/auto-login boolean false
####################################################################
#Network Configuration
####################################################################
#d-i netcfg/enable boolean false
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/choose_interface select auto
###################################################################
# Installation Sources: Packages, Mirrors, Image
####################################################################
d-i mirror/country string manual
d-i mirror/http/hostname  string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu/
d-i apt-setup/use_mirror boolean true
d-i apt-setup/mirror/error select Change mirror
d-i apt-setup/multiverse boolean true
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
d-i apt-setup/partner boolean true
####################################################################
# Grub
####################################################################
#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
d-i grub-installer/only_debian boolean true 
d-i grub-installer/with_other_os boolean true

# finish installation   
d-i finish-install/reboot_in_progress note  
d-i finish-install/keep-consoles boolean false  
d-i cdrom-detect/eject boolean true 
d-i debian-installer/exit/halt boolean false    
d-i debian-installer/exit/poweroff boolean false
####################################################################
# Customization 
####################################################################
#first attempt
d-i preseed/late_command string cp /cdrom/start.sh /target/home/user; in-target chmod 700 /home/user/start.sh; /home/user/start.sh
#second attempt
d-i preseed/late_command string chroot /target; cp -f /cdrom/start.sh /home/user; chmod 700 /home/user/start.sh;    
#Third attempt
d-i preseed/late_command string cp -f /cdrom/start.sh /home/user; in-target chmod +x /home/user/start.sh; in-target sh start.sh
#file creation
d-i preseed/late_command string in-target touch /etc/postinst_user.done
preseed preseed/late_command string in-target touch /etc/postinst_user.done

我正在编辑下面提供的 txt.cfg 文件(在 isolinux 目录下)。我正在编辑这一行append file=/cdrom/preseed/ubuntu.seed keyboard configuration/layoutcode=fr boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet

default live
label live
menu label ^Try Ubuntu Automated version By Emila
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/ubuntu.seed keyboard
configuration/layoutcode=fr boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet
label live-install
menu label ^Install Ubuntu
kernel /casper/vmlinuz
append  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash ---
label check
 menu label ^Check disc for defects
kernel /casper/vmlinuz
append  boot=casper integrity-check initrd=/casper/initrd.lz quiet splash ---
label memtest
 menu label Test ^memory
kernel /install/mt86plus
label hd
menu label ^Boot from first hard disk
localboot 0x80

先感谢您,

相关内容