After just a month of leisurely development, the release of boobstrap v1.2 has occurred — a toolkit on POSIX shell for creating bootable images and drives.
Boobstrap allows you to:
- Create an initramfs image that includes 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 feature is that after booting, GNU/Linux will operate either entirely in a clean tmpfs or using Overlay FS and SquashFS images, as you choose. You install any GNU/Linux distribution in a directory, make all necessary configurations (can be in a separate directory), and then with just one command, create a bootable device, whether it's an ISO image, USB, HDD, SSD drive, or you can also create an initrd image with the system. The system will always be in a single state, and in case of failure, you can revert to the original state with the press of a Reset button. Want to move the system to another host or create a system from an existing container? Boobstrap will do it.
Key changes include:
- Support added for the syslinux bootloader, in addition to the existing grub2. Now you can choose to use either grub2, syslinux, or both together when creating a bootable device or ISO image, managed by the options —legacy-boot syslinux and —efi grub2 respectively, and you can also select which boot modes the ISO image will support.
- The —bootable option has been added, making any block device bootable. To create ISO images, the —iso-9660 option must be used.
- Kernel boot options boobs.use-shmfs for copying the contents of all overlays to tmpfs, boobs.use-overlayfs for booting with Overlay FS, boobs.search-rootfs for selecting the source with the system, and boobs.copy-to-ram for copying the system into memory with subsequent device disconnection have been added.
- The only mandatory dependency for the operation of boobstrap is cpio. Other dependencies are optional: grub2 and syslinux are required for creating bootable media, cdrkit or xorriso for creating ISO files, and squashfs-tools for creating SquashFS. However, nothing prevents the use of the —cpio option instead of —squashfs to package your distribution into an archive. busybox will only be used if it is installed; if not, all necessary utilities from your system will be copied. Thus, the operation of boobstrap is guaranteed almost everywhere.
For example, the following command will create an initrd image by including the gentoo-chroot/ system packaged as a SquashFS image, which will successfully boot after loading the initrd itself. Remember, to use Overlay FS along with SquashFS, you need to pass the option boobs.use-overlayfs to the kernel; otherwise, the system will unpack into tmpfs. Any additional configurations can be made in a separate directory, such as gentoo-settings/
# mkdir initramfs/
# mkinitramfs initramfs/ —overlay gentoo-chroot/ —overlay gentoo-settings/ —squashfs > initrd
An initrd image with a system inside is useful when you need to quickly deploy a system, for example, via PXE, or switch to initrd on an already loaded system using the command kexec -l /boot/vmlinuz-* —initrd=./initrd && kexec -e, or while in a 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 usage options.
To create bootable disks and images, the mkbootisofs command is used; for example, this is how to create an ISO image with the —iso-9660 option using syslinux for Legacy-mode (BIOS) booting and grub2 for EFI-mode (UEFI) booting.
# 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 with subsequent booting from it is performed with the —bootable option. You need to create the partitions on the drive yourself (fdisk) and format them (mkdosfs, mke2fs, etc.), after which you mount the device to the 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 defines from which block device the directory is mounted and installs the bootloader to that device. If you forget to mount the device or mistakenly specify a directory that is, for example, on /dev/sda, the bootloader on /dev/sda will be overwritten. Use —bootable with caution.
Installing any GNU/Linux system boils down to just one command. It can be installed on any HDD, SSD, and so on. It’s worth mentioning that it is still a system operating from Overlay FS / SquashFS, or fully loaded into tmpfs, whichever you choose.
In addition to everything, boobstrap has a number of interesting features and additional capabilities!
For example, you can create a custom boobstrap initrd with the command mkinitramfs `mktemp -d` > /boot/initrd and boot into your system with this initrd, specifying the kernel options boobs.use-overlayfs boobs.search-rootfs=/dev/sda1. In this case, /dev/sda1, where your home system is installed, will be mounted as a read-only layer of Overlay FS, and all changes you make will be written temporarily to tmpfs. You can add the option boobs.copy-to-ram, and then your entire system will be copied into RAM, allowing you to disconnect the hard drive from the computer. This is convenient when you need to break something, and you can simply reboot to revert the changes. 🙂
But what if you still need to save all changes to the system? For instance, you installed some software or something else. When working in a pure tmpfs environment, that unfortunately isn't possible, but if you booted using Overlay FS, then all changes occurring in the system are saved in a separate tmpfs directory: /mnt/overlayfs/rootfs-changes! The usage scenario is very simple. You booted your system from a USB device, worked on it, and wanted to keep everything that was modified; then create a cpio archive and place it back 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 place the archive alongside other SquashFS and cpio "layers"; then upon subsequent boot, the archive will be mounted as just another read-only layer. To continue working with changes, use the loading option boobs.rootfs-changes=\/rootfs-changes.cpio. The boobs.rootfs-changes option mounts the specified layer with write access. The layer can be a block device; for example, you can specify \/dev\/sdb1, in which case all changes made in Overlay FS will simply be saved to \/dev\/sdb1.
Boobstrap, despite its wide capabilities, is still in development; all your comments and suggestions are taken into account!
Source: linux.org.ru

