Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu 20.04 uses a logical partition and can't be resized #1

Open
thomwiggers opened this issue Mar 22, 2021 · 3 comments
Open

Ubuntu 20.04 uses a logical partition and can't be resized #1

thomwiggers opened this issue Mar 22, 2021 · 3 comments

Comments

@thomwiggers
Copy link
Contributor

See e.g. https://listman.redhat.com/archives/libguestfs/2021-February/msg00018.html

Seems as if this is where we want to change things for a solution: https://github.com/rwmjones/guestfs-tools/blob/9ba454622b60d7550e892d8a49048014603b8e2a/builder/templates/ubuntu.preseed#L127-L161

@rwmjones
Copy link
Member

Is there a particular change?

@thomwiggers
Copy link
Contributor Author

thomwiggers commented Mar 22, 2021

I'm not exactly clear on what would work (I'm also having some trouble figuring out how to use the builder/ dir to make images).

The recipe that's selected (atomic) seems to be (from the partman-auto-134ubuntu13 package tarball, file recipes/atomic):

partman-auto/text/atomic_scheme ::

1 1 1 free
	$iflabel{ gpt }
	$reusemethod{ }
	method{ biosgrub } .

538 538 1075 fat32
	$reusemethod{ }
	$primary{ }
	method{ efi }
	format{ } .

512 1024 768 ext4
	$defaultignore{ }
	$lvmignore{ }
	method{ format }
	format{ }
	use_filesystem{ }
	filesystem{ ext4 }
	mountpoint{ /boot } .

900 10000 -1 $default_filesystem
	$lvmok{ }
	method{ format }
	format{ }
	use_filesystem{ }
	$default_filesystem{ }
	mountpoint{ / } .

100% 512 200% linux-swap
	$defaultignore{ }
	$lvmok{ }
	$reusemethod{ }
	method{ swap }
	format{ } .

We could use this recipe, but add $primary { } to the $default_filesystem recipe, and ignoring the $defaultignore ones:

1 1 1 free
	$iflabel{ gpt }
	$reusemethod{ }
	method{ biosgrub } .

538 538 1075 fat32
	$reusemethod{ }
	$primary{ }
	method{ efi }
	format{ } .

900 10000 -1 $default_filesystem
	$lvmok{ }
        $primary{ }
	method{ format }
	format{ }
	use_filesystem{ }
	$default_filesystem{ }
	mountpoint{ / } .

@detain
Copy link

detain commented Dec 25, 2021

Yes, starting with Ubuntu 20 they removed their installer in favor of some newer one with cooler features but completely incompatible .. anyways the point is it doesn't support preseed files
there is a way to do it though still.. the Ubuntu netboot image still uses the installer that supports preseed files, so basically you use the kernel image and initrd from the netboot image to start it instead ..

Here is an article about the change in the installer starting with 20.04 Understanding the Ubuntu 20.04 LTS Server Autoinstaller

you need to build a new base template like (apt install virtinst if you dont have virt-install)

virt-install --transient --name=vps --ram=2048 --cpu=host --vcpus=4 \
  --os-type=linux --os-variant=ubuntu20.04  \
  --initrd-inject=preseed.cfg \
  --extra-args='auto locale=en_US.UTF-8 file:/preseed.cfg console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH'  \
  --disk=disk.img,size=6,format=raw --serial=pty --nographics \
  --install kernel="http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/linux",initrd="http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/initrd.gz"

my preseed file i setup which included creating a gpt partition

d-i auto-install/enable boolean true
d-i debconf/priority string critical
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/supported-locales multiselect en_US.UTF-8, en_UK.UTF-8
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select ens3
d-i netcfg/get_hostname string vm-name
d-i netcfg/get_domain string vps.interserver.net
d-i netcfg/wireless_wep string
d-i mirror/http/mirror select us.archive.ubuntu.com
d-i mirror/http/proxy string
d-i passwd/root-login boolean false
d-i passwd/user-fullname string username
d-i passwd/username string username
d-i passwd/user-password password password
d-i passwd/user-password-again password password
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i clock-setup/utc boolean true
d-i time/zone string Etc/UTC
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
d-i preseed/early_command string umount /media || true
d-i live-installer/enable boolean false
d-i partman-auto/disk string /dev/vda
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-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select gpt-root-swap
d-i partman-auto/expert_recipe string \
   gpt-root-swap ::  \
       512     512     512       fat32  $primary{ }              method{ efi }    device{ vda } format{ } . \
      4000    4000    4000  linux-swap  $primary{ }              method{ swap }   device{ vda } format{ } . \
     50000   50000      -1        ext4  $primary{ } $bootable{ } method{ format } device{ vda } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ / } .
d-i partman-basicfilesystems/choose_label string gpt
d-i partman-basicfilesystems/default_label string gpt
d-i partman-partitioning/choose_label string gpt
d-i partman-partitioning/default_label string gpt
d-i partman/choose_label string gpt
d-i partman/default_label string gpt
d-i    debian-installer/quiet    boolean false
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 base-installer/install-recommends boolean true
d-i base-installer/kernel/image string linux-generic
tasksel tasksel/first multiselect ubuntu-server
d-i pkgsel/include string openssh-server vim
d-i pkgsel/upgrade select full-upgrade
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev  string /dev/vda
d-i grub-installer/with_other_os boolean true
d-i finish-install/reboot_in_progress note
d-i debian-installer/exit/poweroff boolean true

After you build the image you need to put it up on a web accessible dir and setup a /etc/virt-builder/repos.d/ubuntu20.conf file like

[ubuntu20]
uri=http://some.domain/libguestfs/index.asc
gpgkey=file:///etc/xdg/virt-builder/repos.d/ubuntu20.gpg

the index.asc file will need an entry like

[ubuntu-20.04]
name=ubuntu 20.04
osinfo=ubuntu-20.04
file=ubuntu-20.04.img.xz
arch=x86_64
checksum[sha512]=4b9c42e23b5dfff4f77e3e4909ceb1bb363d12eab31724d4d0c4ab5318a9b511ebe8138ef96182fb075dea508117a74d5720774fd40710f30cb9fd12082c6a51
revision=1
format=raw
size=6442450944
compressed_size=773015188
expand=/dev/vda3

use sha512sum on the image to get the hash and once the index file is created, you will need to sign it. if you have not prevoiusly used gpg to create your own key you should run gpg --gen-key to create a new key pair, afterwords you can (re)sign your index file like

gpg --sign index
gpg --detach-sign -o index.gpg index
gpg --clearsign -o index.asc index
rm index.gpg

after that when you run virt-builder to install ubuntu-20.04 it will use the base template you built which includes gpt and such.

sorry ive been u for like 5 days and my vision and thought processes are getting a bit wonky , but i think thats everything..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants