mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-10-29 16:04:09 +00:00
To boot initrdless, the kernel supports a limited number of ways to specify the location of the root filesystem[1]. One of them is to use the PARTUUID (which will be different for every cloud-image), another is to use the PARTLABEL (partition name). To allow the use of PARTLABEL in the kernel command line and make our cloud-images more self-describing, set the PARTLABEL to cloudimg-rootfs which is the same label we use for the file system inside this partition. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/block/early-lookup.c#n217
98 lines
2.5 KiB
Bash
Executable File
98 lines
2.5 KiB
Bash
Executable File
#!/bin/bash -eux
|
|
case $ARCH in
|
|
ppc64el|powerpc)
|
|
;;
|
|
*)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
IMAGE_STR="# CLOUD_IMG: This file was created/modified by the Cloud Image build process"
|
|
FS_LABEL="cloudimg-rootfs"
|
|
# 2.4G GiB
|
|
# Since Plucky, ppc64el need more than the default 2.2GiB
|
|
IMAGE_SIZE=2576980378
|
|
|
|
. config/binary
|
|
|
|
. config/functions
|
|
|
|
create_partitions() {
|
|
disk_image="$1"
|
|
sgdisk "${disk_image}" \
|
|
--zap-all
|
|
sgdisk "${disk_image}" \
|
|
--new=2::+8M \
|
|
--new=1:
|
|
sgdisk "${disk_image}" \
|
|
--change-name=1:"$FS_LABEL" \
|
|
-t 2:4100 \
|
|
-t 1:"$(gpt_root_partition_uuid $ARCH)"
|
|
sgdisk "${disk_image}" \
|
|
--print
|
|
}
|
|
|
|
install_grub() {
|
|
mkdir mountpoint
|
|
mount_partition "${rootfs_dev_mapper}" mountpoint
|
|
|
|
chroot mountpoint apt-get -qqy update
|
|
chroot mountpoint apt-get -qqy install grub-ieee1275
|
|
chroot mountpoint apt-get -qqy remove --purge grub-legacy-ec2
|
|
chroot mountpoint apt-get autoremove --purge --assume-yes
|
|
|
|
# set the kernel commandline to use hvc0
|
|
mkdir -p mountpoint/etc/default/grub.d
|
|
cat << EOF > mountpoint/etc/default/grub.d/50-cloudimg-settings.cfg
|
|
${IMAGE_STR}
|
|
|
|
# Set the recordfail timeout
|
|
GRUB_RECORDFAIL_TIMEOUT=0
|
|
|
|
# Do not wait on grub prompt
|
|
GRUB_TIMEOUT=0
|
|
|
|
# Set the default commandline
|
|
GRUB_CMDLINE_LINUX_DEFAULT="console=hvc0 earlyprintk"
|
|
EOF
|
|
prep_partition="${loop_device}p2"
|
|
chroot mountpoint grub-install "${prep_partition}" \
|
|
--no-nvram \
|
|
--boot-directory=/boot \
|
|
--target=powerpc-ieee1275
|
|
|
|
divert_grub mountpoint
|
|
chroot mountpoint update-grub
|
|
replace_grub_root_with_label mountpoint
|
|
undivert_grub mountpoint
|
|
|
|
umount_partition mountpoint
|
|
rmdir mountpoint
|
|
}
|
|
|
|
disk_image=binary/boot/disk.ext4
|
|
|
|
create_empty_disk_image "${disk_image}"
|
|
create_partitions "${disk_image}"
|
|
mount_image "${disk_image}" 1
|
|
|
|
# Copy the chroot in to the disk
|
|
make_ext4_partition "${rootfs_dev_mapper}"
|
|
mkdir mountpoint
|
|
mount "${rootfs_dev_mapper}" mountpoint
|
|
cp -a chroot/* mountpoint/
|
|
|
|
# the image has been modified from its disk-image-uefi base so the manifest and filelist should be regenerated
|
|
chroot mountpoint dpkg-query -W > binary/boot/filesystem.packages
|
|
(cd mountpoint && find -xdev) | sort > binary/boot/filesystem.filelist
|
|
|
|
create_manifest "mountpoint/" "$PWD/livecd.ubuntu-cpc.disk-image.manifest" "$PWD/livecd.ubuntu-cpc.disk-image.spdx" "cloud-image-$ARCH-$(date +Y%m%dT%H:%M:%S)"
|
|
|
|
umount mountpoint
|
|
rmdir mountpoint
|
|
|
|
install_grub
|
|
|
|
clean_loops
|
|
trap - EXIT
|