mvallim / cloud-image-ubuntu-from-scratch

This procedure shows how to create a cloud image Ubuntu from scratch to run on Cloud environments (EC2, GCE, Azure, QEMU and VirtualBox).
https://mvallim.github.io/cloud-image-ubuntu-from-scratch/
GNU General Public License v3.0
80 stars 16 forks source link

cloud image for ubuntu 22.04 jammy #2

Closed nbari closed 1 year ago

nbari commented 2 years ago

Hi, I am trying to create an image for ubuntu 22, but I get this error: Couldn't identify type of root file system for fsck hook

To get sources and packages I did:

debootstrap \
   --arch=amd64 \
   --variant=minbase \
   --components "main,universe" \
   --include "ca-certificates,cron,iptables,isc-dhcp-client,libnss-myhostname,ntp,ntpdate,rsyslog,ssh,sudo,dialog,whiptail,man-db,curl,dosfstools,e2fsck-static" \
   jammy \
   $HOME/cloud-image/chroot \
   http://us.archive.ubuntu.com/ubuntu/

And sources:

cat <<EOF > /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse

deb http://us.archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
EOF

But I get an error, following the instructions after this step:

apt-get install -y \
    os-prober \
    ifupdown \
    network-manager \
    resolvconf \
    locales \
    build-essential \
    module-assistant \
    cloud-init \
    grub-pc \
    grub2 \
    linux-generic

I get this error

Processing triggers for linux-image-5.15.0-47-generic (5.15.0-47.51) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.15.0-47-generic
W: Couldn't identify type of root file system for fsck hook

Any ideas, or hint to build the image?

mvallim commented 1 year ago

Hi @nbari,

I tried to reproduce this problem, but I can't.

Setting up packagekit-tools (1.2.5-2ubuntu2) ...
Setting up software-properties-common (0.99.22.3) ...
Setting up linux-image-5.15.0-47-generic (5.15.0-47.51) ...
I: /boot/vmlinuz.old is now a symlink to vmlinuz-5.15.0-47-generic
I: /boot/initrd.img.old is now a symlink to initrd.img-5.15.0-47-generic
I: /boot/vmlinuz is now a symlink to vmlinuz-5.15.0-47-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.15.0-47-generic
Setting up linux-modules-5.15.0-47-generic (5.15.0-47.51) ...
Setting up grub-pc (2.06-2ubuntu7) ...

Creating config file /etc/default/grub with new version
Setting up grub-gfxpayload-lists (0.7) ...
Setting up grub2 (2.06-2ubuntu7) ...
Setting up linux-modules-extra-5.15.0-47-generic (5.15.0-47.51) ...
Setting up linux-image-generic (5.15.0.47.47) ...
Setting up linux-generic (5.15.0.47.47) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Processing triggers for rsyslog (8.2112.0-2ubuntu2) ...
Running in chroot, ignoring request.
Running in chroot, ignoring command 'try-restart'
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for dbus (1.12.20-2ubuntu4) ...
Processing triggers for resolvconf (1.84ubuntu1) ...
Processing triggers for initramfs-tools (0.140ubuntu13) ...
Processing triggers for linux-image-5.15.0-47-generic (5.15.0-47.51) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.15.0-47-generic
root@chroot:/# 

I followed all the steps exactly as described in the how to, just changing the bootstrap step and sources.list to jammy.

Do you have more information so I can help?

Best regards,

nbari commented 1 year ago

Hi @mvallim thanks for checking this out, I tried again but this time didn't use the sources, I am using the defaults:

deb http://us.archive.ubuntu.com/ubuntu jammy main universe

But I still get the warning:

update-initramfs: Generating /boot/initrd.img-5.15.0-25-generic
W: Couldn't identify type of root file system for fsck hook

Giving more context I am running this within a VM using ubuntu jammy, here is the output of losetup -a:

# losetup -a
/dev/loop1: [64768]:1315043 (/var/lib/snapd/snaps/core20_1623.snap)
/dev/loop4: [64768]:1320091 (/var/lib/snapd/snaps/snapd_16292.snap)
/dev/loop2: [64768]:1320090 (/var/lib/snapd/snaps/lxd_22923.snap)
/dev/loop0: [64768]:1324142 (/var/lib/snapd/snaps/core20_1611.snap)
/dev/loop5: [64768]:2752525 (/home/nbari/cloud-image-ubuntu-from-scratch/cloud-ubuntu-image.raw)
/dev/loop3: [64768]:1319048 (/var/lib/snapd/snaps/lxd_23541.snap)

Why in /etc/fstab you use sda(1|2) ?: (maybe by using the UUID could fix the warning) ?

 # <file system>         <mount point>   <type>  <options>                       <dump>  <pass>
/dev/sda2               /               ext4    errors=remount-ro               0       1
/dev/sda1               /boot           ext4    defaults                        0       2

Probably because of this the grub-pc menu doesn't appear, I continue with the setup and ended with:

#grub-install /dev/loop5
Installing for i386-pc platform.
Installation finished. No error reported.

# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-25-generic
Found initrd image: /boot/initrd.img-5.15.0-25-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done

I manage to create the qcow2:

qemu-img convert -f raw cloud-ubuntu-image.raw -O qcow2 ubuntu-image.qcow2

But when testing, after booting I get this:

Screenshot 2022-09-12 at 14 12 50

My goal is to create an image only with wireguard but disable cloud-init, I am testing this in Alicloud but I would like to prevent their system to add via cloud-init extra packages, any ideas about how to achieve this?

mvallim commented 1 year ago

Hi @nbari,

I run all steps again inside VM (jammy) and any warning or error reported.

vm@jammy:~/cloud-image-ubuntu-from-scratch$ sudo losetup -a
/dev/loop1: [64768]:1843238 (/var/lib/snapd/snaps/core20_1405.snap)
/dev/loop8: [64768]:2490879 (/home/vm/cloud-image-ubuntu-from-scratch/cloud-ubuntu-image.raw)
/dev/loop6: [64768]:1843244 (/var/lib/snapd/snaps/snapd_15177.snap)
/dev/loop4: [64768]:1843241 (/var/lib/snapd/snaps/gtk-common-themes_1534.snap)
/dev/loop2: [64768]:1843240 (/var/lib/snapd/snaps/gnome-3-38-2004_99.snap)
/dev/loop0: [64768]:1843239 (/var/lib/snapd/snaps/firefox_1232.snap)
/dev/loop7: [64768]:1843243 (/var/lib/snapd/snaps/snapd-desktop-integration_10.snap)
/dev/loop5: [64768]:1843242 (/var/lib/snapd/snaps/snap-store_575.snap)
/dev/loop3: [64768]:1843237 (/var/lib/snapd/snaps/bare_5.snap)
vm@jammy:~/cloud-image-ubuntu-from-scratch$ sudo debootstrap \
   --arch=amd64 \
   --variant=minbase \
   --components "main,universe" \
   --include "ca-certificates,cron,iptables,isc-dhcp-client,libnss-myhostname,ntp,ntpdate,rsyslog,ssh,sudo,dialog,whiptail,man-db,curl,dosfstools,e2fsck-static" \
   jammy \
   $HOME/cloud-image-ubuntu-from-scratch/chroot \
   http://us.archive.ubuntu.com/ubuntu/
root@jammy:/# grub-install /dev/loop8
Installing for i386-pc platform.
Installation finished. No error reported.
root@jammy:/# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-48-generic
Found initrd image: /boot/initrd.img-5.15.0-48-generic
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
done

Answering your question about cloud-init, so that nothing is installed through cloud-init, just don't install the cloud-init package.

root@jammy:/# apt-get install -y \
    os-prober \
    ifupdown \
    network-manager \
    resolvconf \
    locales \
    build-essential \
    module-assistant \
    grub-pc \
    grub2 \
    linux-generic

Did you try this?

Best regards,

mvallim commented 1 year ago

Issue closed due to lack of interaction