Creating Boobstrap v1.2 Boot Images


Creating Boobstrap v1.2 Boot Images

After just a month After slow development, boobstrap v1.2 was released - a set of tools on the POSIX shell for creating boot images and drives.

Boobstrap allows you to do just one command:

  • Create an initramfs image including any GNU/Linux distribution.
  • Create bootable ISO images with any GNU/Linux distribution.
  • Create bootable USB, HDD, SSD drives with any GNU/Linux distribution.

The peculiarity is that after loading GNU/Linux will work either completely in pure tmpfs, or using Overlay FS and SquashFS images, your choice. You install any GNU/Linux distribution in a directory, make all the necessary settings (possibly in a separate directory), after which you create a boot device with just one command, be it an ISO image, USB, HDD, SSD drive, or you can create an initrd image with system. The system will always be in the same state and in the event of a breakdown, you can return to its original state by pressing one Reset button. Do you want to transfer the system to another host, or create a system from an existing container? Boobstrap will do it.

Among the key changes:

  • Added support for the syslinux bootloader, in addition to the already existing grub2. Now you can choose to use either grub2 or syslinux or both when creating a boot device or ISO image, which is the responsibility of the --legacy-boot syslinux and --efi grub2 options respectively, and you can also choose which modes downloads will support the ISO image.
  • Added --bootable option, which makes any block device bootable. To create ISO images, the --iso-9660 option must be used.
  • Added kernel boot options boobs.use-shmfs to copy the contents of all overlays to tmpfs, boobs.use-overlayfs to boot using Overlay FS, boobs.search-rootfs to select a source with the system, boobs.copy-to-ram to copy the system into memory and then turning off the device.
  • The only required dependency for boobstrap to work is cpio. The rest of the dependencies are optional: grub2, syslinux - required to create bootable media, cdrkit or xorriso to choose from - to create an ISO, squashfs-tools to create SquashFS, but nothing prevents you from using the -cpio option instead of -squashfs to package your distribution into an archive. busybox will only be used if it is installed, but if not, all necessary utilities from your system will be copied. Thus, boobstrap is guaranteed to work almost everywhere.

For example, the following command will create an initrd image including a gentoo-chroot/ system packaged as a SquashFS image, which will boot successfully after the initrd itself has loaded. Let me remind you that to use Overlay FS in conjunction with SquashFS, you must pass the boobs.use-overlayfs kernel option, otherwise the system will be unpacked into tmpfs. All additional settings can be made in a separate directory, for example gentoo-settings/

# mkdir initramfs/
# mkinitramfs initramfs/ --overlay gentoo-chroot/ --overlay gentoo-settings/ --squashfs > initrd

An initrd image with a system inside is convenient when you need to quickly deploy a system, for example, via PXE, or on a loaded system switch to initrd using the command kexec -l /boot/vmlinuz-* β€”initrd=./initrd && kexec -e, well or, being in the QEMU virtual machine interface (possibly even Proxmox), boot from a remote source using three IPXE commands: kernel http://[...]/vmlinuz, initrd http://[...]/initrd, boot. As you can see, even a regular initrd with your system inside has many uses.

The mkbootisofs command is used to create boot drives and images, for example, creating an ISO image with the --iso-9660 option using syslinux to boot in Legacy-mode (BIOS) and grub2 to boot in EFI-mode (UEFI) looks like this.

# mkdir initrd/
# mkinitramfs initrd/ > initrd
# mkdir isoimage/
# mkdir isoimage/boot
# cp /boot/vmlinuz-* isoimage/boot/vmlinuz
# cp initrd isoimage/boot/initrd
# mkbootisofs isoimage/ β€”iso-9660 β€”legacy-boot syslinux β€”efi grub2 β€”output boot.iso
--overlay gentoo-chroot/ --overlay gentoo-settings/ --squashfs

You can specify one of the boot modes, or not specify them at all, the corresponding ISO image will be successfully created.

Installation on any drive and subsequent booting from it is performed using the --bootable option. You need to create partitions on the drive yourself (fdisk) and format them (mkdosfs, mke2fs, etc.), and then mount the device into a directory.

# mount /dev/sdb1 /mnt/drive/
# mkbootisofs /mnt/drive/ --bootable --legacy-boot grub2 --efi grub2
--overlay gentoo-chroot/ --overlay gentoo-settings/ --squashfs

Caution! The --bootable option determines which block device the directory is mounted from and installs the bootloader on this device. If you forget to mount the device or mistakenly specify a directory that is located, for example, on /dev/sda, the bootloader on /dev/sda will be overwritten accordingly. Use --bootable with caution.

Installing any GNU/Linux system is reduced to just one command. Installation can be done on any HDD, SSD, and so on. It is worth recalling that this is still a system running from Overlay FS / SquashFS, or loading entirely into tmpfs, your choice.

Among other things, boobstrap has a number of interesting features and additional capabilities!

For example, you can create a proprietary boobstrap initrd with the mkinitramfs `mktemp -d` > /boot/initrd command and boot into your system with this initrd by specifying the boobs.use-overlayfs boobs.search-rootfs=/dev/sda1 kernel options. In this case, /dev/sda1, where your home system is installed, will be mounted as a read-only Overlay FS layer, and any changes you make will be written only temporarily to tmpfs. You can add the boobs.copy-to-ram option and then your entire system will be copied to RAM, and the hard drive can be disconnected from the computer. It is handy when you need to break something, and you can roll back the changes simply by rebooting. πŸ™‚

But what if you still need to save all the changes in the system? For example, you installed software or something else. When working in pure tmpfs, this is unfortunately impossible, but if you booted using Overlay FS, then all changes that occur in the system are saved in a separate tmpfs directory: /mnt/overlayfs/rootfs-changes! The usage scenario is very simple. You booted into your system from a USB device, did some work, and wanted to save everything that was changed, then create a cpio archive and put it here, on the same USB device.

# cd /mnt/overlayfs/rootfs-changes
# find . -print0 | cpio --create --format "newc" --null --quiet > /mnt/drive/rootfs-changes.cpio
# cd $OLDPWD

You can put the archive next to other SquashFS and cpio β€œlayers”, then upon subsequent loading the archive will be connected as just another read-only layer. To continue working with changes, use the upload option boobs.rootfs-changes=/rootfs-changes.cpio. The boobs.rootfs-changes option enables the specified layer with change access. The layer can be a block device, for example you can specify /dev/sdb1, then all changes made in Overlay FS will simply be saved to /dev/sdb1.

Boobstrap, despite the wide possibilities available, is still at the development stage, all your comments and suggestions are taken into account!

Source: linux.org.ru

Add a comment