Adding packages to the Lubuntu Alternate ISO Standalone Installer
Introduction
When creating stand-alone installation media for the automated installation of Lubuntu 14.04 using preseed , I was faced with the fact that I need to add packages to the installation media that are not in the original alternate distribution . I tried many different ways to create my own standalone distributions, but they turned out to be:
- or inappropriate ( LiveCDCustomization ), because I need not a LiveCD, but an installation preseed distribution;
- either very complex ( DebianCustomCD );
- either worked, not as expected ( Simple-CDD , DebianInstaller / Modify / CD ), or maybe I didn’t figure it out completely.
As a result, he settled on the method described in the Ubuntu community .
I want to talk about what I did.
Training
To complement the distribution, we need the original alternate distribution , to which we will add packages. As well as a computer running Ubuntu or Lubuntu on which we will do this.
Creating a directory structure and copying files
Create a directory in which we will work with this distribution:
mkdir -p /opt/cd-imageDownload the distribution kit:
wget http://cdimages.ubuntu.com/lubuntu/releases/trusty/release/lubuntu-14.04.1-alternate-i386.iso
Unzip the downloaded iso-image:
mkdir /mnt/iso
mount -o loop lubuntu-14.04.1-alternate-i386.iso /mnt/iso
cp -rT /mnt/iso /opt/cd-image
umount /mnt/iso
Create a directory for the packages we want to add to the distribution:
mkdir -p /opt/cd-image/pool/extras
tree -d -L 3 /opt
/opt
├── apt-ftparchive
├── build
│ └── ubuntu-keyring-2012.05.19
│ ├── debian
│ └── keyrings
├── cd-image
│ ├── boot
│ │ └── grub
│ ├── dists
│ │ └── trusty
│ ├── doc
│ │ └── install
│ ├── install
│ │ └── netboot
│ ├── isolinux
│ ├── pics
│ ├── pool
│ │ ├── extras
│ │ ├── main
│ │ └── universe
│ └── preseed
└── indicesPreparing Encryption Keys
If you do not have a public-private key pair, you will need to create it using gpg . The key is preferably set to a comment of the form “XXX Signing Key”.
gpg --gen-key
gpg (GnuPG) 1.4.16; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) "
Real name: Alexandr Petrenko
Email address: *********@gmail.com
Comment: My Signing Key
You selected this USER-ID:
"Alexandr Petrenko (My Signing Key) <*********@gmail.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.
We will use the private key to sign the release files of the repository. For the next steps, you will need the fakeroot package, install it if it is not on your system.
mkdir /opt/build
cd /opt/build
# Скачаем исходники действующего пакета с ключами
apt-get source ubuntu-keyring
# Импортируем ключи из пакета
cd ubuntu-keyring-2012.05.19/keyrings/
gpg --import < ubuntu-archive-keyring.gpg
# Для просмотра ключей, содержащих "Signing Key" в комментарии, введите
gpg --list-keys "Signing Key"
pub 1024D/437D05B5 2004-09-12
uid Ubuntu Archive Automatic Signing Key
sub 2048g/79164387 2004-09-12
pub 1024D/FBB75451 2004-12-30
uid Ubuntu CD Image Automatic Signing Key
pub 2048R/YOURKEYID 2015-01-28
uid My Signing Key <*********@gmail.com>
sub 2048R/KEYID 2015-01-28
# Добавьте свой ключ в связку
gpg --export FBB75451 437D05B5 YOURKEYID > ubuntu-archive-keyring.gpg
# Перейдите на уровень выше в каталог ubuntu-keyring-2012.05.19 и соберите пакет с вашим ключом
cd ..
dpkg-buildpackage -rfakeroot -m"Ваше имя " -kYOURKEYID
# И скопируйте полученный пакета в репозиторий на диске
cd ..
cp ubuntu-keyring*deb /opt/cd-image/pool/main/u/ubuntu-keyring
Copy files to repository
You can simply add several packages manually to the / opt / cd-image / pool / extras directory.
If you need to update the installer kernel modules, then this can be done like this:
cd /opt/cd-image/pool/main/l/linux/
wget -r -nd --no-parent --accept '*-modules-3.13.0-24*i386.udeb' ftp://security.ubuntu.com/ubuntu/pool/main/l/linux/
where instead of 3.13.0-24 * i386, you can specify the desired version of the kernel that you use to boot, and the architecture of the modules.
To download all the packages installed in the current OS on the reference computer, you can run this
#!/bin/bash
dpkg --get-selections | while read line
do
package=`expr "$line" : '\(.*\)install'`
echo $package
apt-get download $package
done
for i in *; do mv $i ${i/'1%3a'/''}; done
And add the downloaded packages from the apt cache to the repository.
Create a standalone local repository using apt-ftparchive
The apt-ftparchive utility is contained in the apt-utils package.
All settings are given for Lubuntu 14.04 Trusty and i386 architecture. If the version or architecture of your distribution is different, then you need to adjust the appropriate values in the configuration files and scripts.
Repository description for apt-ftparchive
The following configuration files must be created in the / opt / apt-ftparchive directory:
Settings for pockets main and universe:
Dir {
ArchiveDir "/opt/cd-image/";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/main" {
Packages "dists/trusty/main/binary-i386/Packages";
BinOverride "/opt/indices/override.trusty.main";
ExtraOverride "/opt/indices/override.trusty.extra.main";
};
BinDirectory "pool/universe" {
Packages "dists/trusty/universe/binary-i386/Packages";
BinOverride "/opt/indices/override.trusty.universe";
};
Default {
Packages {
Extensions ".deb";
Compress ". gzip";
};
};
Contents {
Compress "gzip";
};
Settings for the debian-installer installer modules in the main and universe pockets:
Dir {
ArchiveDir "/opt/cd-image/";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/main" {
Packages "dists/trusty/main/debian-installer/binary-i386/Packages";
BinOverride "/opt/indices/override.trusty.main.debian-installer";
};
BinDirectory "pool/universe" {
Packages "dists/trusty/universe/debian-installer/binary-i386/Packages";
BinOverride "/opt/indices/override.trusty.universe.debian-installer";
};
Default {
Packages {
Extensions ".udeb";
Compress ". gzip";
};
};
Contents {
Compress "gzip";
};
Settings for our extras pocket:
Dir {
ArchiveDir "/opt/cd-image/";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/extras" {
Packages "dists/trusty/extras/binary-i386/Packages";
};
Default {
Packages {
Extensions ".deb";
Compress ". gzip";
};
};
Contents {
Compress "gzip";
};
Settings for creating the repository release file:
APT::FTPArchive::Release::Origin "Ubuntu";
APT::FTPArchive::Release::Label "Ubuntu";
APT::FTPArchive::Release::Suite "trusty";
APT::FTPArchive::Release::Version "14.04";
APT::FTPArchive::Release::Codename "trusty";
APT::FTPArchive::Release::Architectures "i386";
APT::FTPArchive::Release::Components "main restricted extras";
APT::FTPArchive::Release::Description "Ubuntu 14.04 LTS";
Index loading
#!/bin/bash
cd /opt/indices/
DIST=trusty
for SUFFIX in extra.main main main.debian-installer universe universe.debian-installer; do
wget http://archive.ubuntu.com/ubuntu/indices/override.$DIST.$SUFFIX
done
Creating Packages and Release Repository Files
A script that starts the creation of Packages and Release repository files by the apt-ftparchive utility based on our settings, after which it signs the Release file and writes the checksums of the files to md5sum.txt:
BUILD=/opt/cd-image
APTCONF=/opt/apt-ftparchive/release.conf
DISTNAME=trusty
pushd $BUILD
apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-deb.conf
apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-udeb.conf
apt-ftparchive -c $APTCONF generate /opt/apt-ftparchive/apt-ftparchive-extras.conf
apt-ftparchive -c $APTCONF release $BUILD/dists/$DISTNAME > $BUILD/dists/$DISTNAME/Release
gpg --default-key "YOURKEYID" --output $BUILD/dists/$DISTNAME/Release.gpg -ba $BUILD/dists/$DISTNAME/Release
find . -type f -print0 | xargs -0 md5sum > md5sum.txt
Create and use an ISO image
Creating an ISO Image
IMAGE=custom.iso
BUILD=/opt/cd-image/
mkisofs -r -V "Custom Ubuntu Install CD" \
-cache-inodes \
--iso-level 3 -J -l -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot \
-boot-load-size 4 -boot-info-table \
-o $IMAGE $BUILDBooting from an ISO image
Now you can boot using the created ISO-image, burning the image to a CD / DVD-ROM, or from removable media.
Creating a bootable USB drive
To boot, you need to format the disk in FAT32. Install a bootloader on the disk, for example grub2:
sudo grub-install --no-floppy --root-directory=/media/multiboot /dev/sdb
where / media / multiboot is the path to the mounted partition of the bootable USB drive; / dev / sdb - boot disk device.
After that, configure the bootloader. Approximate grub2 config:
# таймаут меню
set timeout=10
# выбранный пункт по умолчанию
set default=0
# загружаем модули
insmod ext2
insmod loopback
insmod iso9660
insmod fat
insmod part_msdos
menuentry "Boot from first hard disk" {
set root=(hd1)
chainloader +1
}
set iso="/custom.iso"
menuentry "Custom.iso" {
linux /vmlinuz debconf/priority=high shared/ask_device=manual shared/enter_device=/dev/disk/by-label/DISKLABEL iso-scan/filename=$iso auto-install/enable=true debian-installer/language=ru debian-installer/locale=ru_RU.UTF-8 debian-installer/country=RU preseed/file=/cdrom/preseed/custom.seed DEBCONF_DEBUG=5 --
initrd /initrd.gz
}
You also need to add vmlinuz and initrd to the root of the USB drive .
In the udeb.list file, you can find out the versions of modules that are required by the kernel and which must be placed in the distribution kit (see above).
It remains to boot from the created disk, and start the installation of the OS.
- wiki.debian.org/DebianInstaller/Preseed
- help.ubuntu.com/community/Lubuntu/Alternate_ISO
- help.ubuntu.com/community/LiveCDCustomization
- wiki.debian.org/DebianCustomCD
- wiki.debian.org/Simple-CDD/Howto
- wiki.debian.org/DebianInstaller/Modify/CD
- help.ubuntu.com/community/InstallCDCustomization
- manpages.ubuntu.com/manpages/trusty/en/man1/apt-ftparchive.1.html
- manpages.ubuntu.com/manpages/trusty/en/man1/gpg.1.html