There are two ways:
Use debootstrap or minimal.squashfs through the terminal.
The two ways are the same in the procedures, the difference is with debootstrap you will download all the packages for the new system from the internet, while in the second way, you can prepare the system from the ISO file and/or use the internet to install or upgrade the packages. you can install grub in the new system or just update-grub in the current system. also, you can test any way from them to install the system in a folder and make *.squashfs reboot with a live session to test the system without installation on any partition or USB.
Can Ubuntu 24 be installed on an empty partition using minimal.squashfs through the terminal?
Install Ubuntu 24.04 by debootstrap
mkdir ~/test
sudo apt update
sudo apt install debootstrap
sudo debootstrap noble ~/test
sudo mount --bind /dev ~/test/dev
sudo mount --bind /run ~/test/run
sudo chroot ~/test
mount none -t proc /proc
mount none -t sysfs /sys
mount none -t devpts /dev/pts
export HOME=/root
export LC_ALL=C
dbus-uuidgen > /etc/machine-id
ln -fs /etc/machine-id /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
######all this below lines at EOF in one command#######
cat <<EOF > /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ noble-updates main restricted universe multiverse
EOF
##############
rm /etc/resolv.conf
echo nameserver 8.8.8.8 > /etc/resolv.conf
apt update
apt-get -y upgrade
apt-get install -y ubuntu-standard nano zstd initramfs-tools
apt-get install -y ubuntu-desktop
apt-get install -y gedit gparted dconf-editor gnome-shell-extension-manager nautilus-admin
apt-get install -y firmware-b43-installer #wireless driver for b43 you can change it
##########google chrome#######
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
apt-get update
apt-get install -y google-chrome-stable
######################################
apt-get install -y grub2
apt-get install -y --no-install-recommends linux-generic
apt-get install -y casper
adduser username #change it to your name
adduser username sudo
adduser username adm
echo "/dev/sda4 / ext4 errors=remount-ro 0 1" >> /etc/fstab #you can skip this or place the wright letters and numbers
update-grub #you can skip this
truncate -s 0 /etc/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
apt-get clean
rm -rf /tmp/* ~/.bash_history
umount /proc
umount /sys
umount /dev/pts
export HISTSIZE=0
exit
sudo umount ~/test/dev
sudo umount ~/test/run
sudo mksquashfs ~/test/* ~/noble.squashfs
Now you have noble.squashfs in your /home, make /casper directory in the root of the current system, copy initrd.img-6.8.0-38-generic and vmlinuz-6.8.0-38-generic from ~/test and noble.squashfs to /casper, add this menu entry to grub.cfg of the current system:
menuentry "ubuntu noble from squashfs" --class ubuntu {
insmod ext2
set root=hd0,msdos3 #change it to be appropriate with current Ubuntu partition
linux /casper/vmlinuz-6.8.0-38-generic boot=casper layerfs-path=noble.squashfs --
initrd /casper/initrd.img-6.8.0-38-generic
}
Reboot to test the new system in the live session. you can extract the noble.squashfs to empty partition, solve fstab and grub, or try to debootstrap on the empty partition directly.
Notes:
Google Chrome is not opened in the live session, don't try to fix this but it worked when installing the system on the empty partition.
Installing casper is needed to generate vmlinuz* and initrd* for the live session. remove casper if the system installed on the empty partition.
Whether in a live session or after extracting *.squashfs to a partition umount all partitions in /media folder and delete the /media/username folder or sudo chown -R username /media. this is not required when the system is installed on a partition.
If firefox does not appear, use snap info firefox, if disabled snap enable firefox, if not installed snap install firefox