{"id":20709036,"url":"https://github.com/difrex/boobstrap","last_synced_at":"2025-04-23T02:52:40.387Z","repository":{"id":71928725,"uuid":"271813868","full_name":"Difrex/boobstrap","owner":"Difrex","description":"A scripts complex to for GNU/Linux bootstrapping","archived":false,"fork":false,"pushed_at":"2020-07-17T15:39:26.000Z","size":1680,"stargazers_count":1,"open_issues_count":0,"forks_count":11,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T21:22:32.783Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Difrex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-12T14:11:37.000Z","updated_at":"2024-06-18T04:20:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"7fb056a6-01dc-4f3e-9b0f-d7fa84dc3046","html_url":"https://github.com/Difrex/boobstrap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Difrex%2Fboobstrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Difrex%2Fboobstrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Difrex%2Fboobstrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Difrex%2Fboobstrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Difrex","download_url":"https://codeload.github.com/Difrex/boobstrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250360259,"owners_count":21417718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T01:34:36.244Z","updated_at":"2025-04-23T02:52:40.374Z","avatar_url":"https://github.com/Difrex.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"GL HF\n\n# booty\n\nbooty is a scripts complex for creating bootable GNU/Linux images.\n\n\u003c!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --\u003e\n**Table of Contents**\n\n- [booty](#booty)\n    - [Installation](#installation)\n    - [Quick start](#quick-start)\n    - [Boot options](#boot-options)\n        - [boobs.use-shmfs](#boobs.use-shmfs)\n        - [boobs.use-overlayfs](#boobs.use-overlayfs)\n        - [boobs.search-rootfs](#boobs.search-rootfs)\n        - [boobs.copy-to-ram](#boobs.copy-to-ram)\n        - [boobs.rootfs-changes](#boobs.rootfs-changes)\n    - [Utilities](#utilities)\n        - [mkbootstrap](#mkbootstrap)\n        - [mkinitramfs](#mkinitramfs)\n        - [mkbootisofs](#mkbootisofs)\n        - [mkoverlayfs](#mkoverlayfs)\n        - [exportroot / importroot](#exportroot--importroot)\n    - [Use cases](#use-cases)\n    - [Examples](#Examples)\n        - [initrd as standalone linux system](#initrd-as-standalone-linux-system)\n        - [boot to any linux from the storage device](#boot-to-any-linux-from-the-storage-device)\n        - [MOAR](#moar)\n    - [Friendly Asked Questions](#friendly-asked-questions)\n\n\u003c!-- markdown-toc end --\u003e\n\n\nSo what booty can do?\n\n1. Installs \"chroots\" into the directory, it have native CRUX GNU/Linux\nsupport but for other distros booty just switching to using external\nbootstrap-wrappers like pacstrap, debootstrap, so you need to have it\ninstalled. For CRUX GNU/Linux its a simple pkgadd implementation using \"tar\"\nand my pkgadd can only installing packages into the \"chroot/\", nothing else.\n\n2. Creates INITRD images for boot using the host-system environment or can\nusing standalone directory as INITRD \"chroot\". INITRD images can including the\nfull system as directory, SquashFS-compressed image and so on... Then you\ncan share INITRD image via PXE or put it on any device. Also INITRD can\nboots to plain SHMFS (TMPFS, RAMFS) or using Overlay FS with SquashFS.\nbooty can use busybox but only if you have one, its optional feature.\n\nAaaaaand...\n\n3. Creating BIOS and UEFI compatible bootable ISO images. Thats it. Simple.\n\nSo...\n\nJust take 3 (three) simple steps and you'll get own bootable GNU/Linux distro!\nAnd then you will be able to boot it via a network (PXE) or CD-ROM / USB (bootable ISO).\n\n**Written in the pure POSIX shell. Confirmed by \"Dash\".**\n\nPersonally, I am living in tmpfs forever. All my \"enterprises\" are living in tmpfs.\nFor example, personally, I use GNU/Linux on my home PC-router with 2GB of RAM.\nYes, my \"enterprise\" is a PC-router with 2GB RAM running in tmpfs. HA-HA.\n\n* That's cool -- your system is in the tmpfs.\n* That's fast -- tmpfs means RAM.\n* That's smart -- set up only once, use forever.\n* That's secure -- if your system breaks, just push the \"RESET\" button.\n* That's NO backups -- back up only your data, not the system.\n\n* Don't be afraid to use \"root\".\n* Don't be afraid to break the system.\n* Don't be afraid to run shell-exploits.\n* Don't be afraid to do \"rm -rf /\".\n\nWhen my system breaks I push the \"RESET\" button and the system boots again.\n-- via PXE or from a USB-flash (ISO).\n\nSoftware included:\n\n* mkbootstrap -- Install \"chroot\" with any distro.\n* mkinitramfs -- Create an initrd / initramfs image.\n* mkbootisofs -- Create a bootable ISO from a directory.\n* mkoverlayfs -- Creates images for using with Overlay FS.\n* exportroot -- Creates archive from the \"chroot\" directory.\n* importroot -- Restores \"chroot\" directory from the archive.\n\nSoftware dependencies:\n\n* cpio\n* grub\n* grub-efi\n* dosfstools\n* squashfs-tools (optional)\n* xorriso\n\nAlso if you want to use SquashFS / OverlayFS, enable the following in your kernel:\n\n\tCONFIG_OVERLAY_FS=y\n\nand\n\n\tCONFIG_SQUASHFS=y\n\tCONFIG_SQUASHFS_XZ=y\n\nBut its optional. You can just use SHMFS if you have enough RAM for your system.\n\n\n## Installation\n\n* Generic GNU/Linux\n```sh\ngit clone https://github.com/sp00f1ng/booty.git\ncd booty\nmake install\n```\n\n* ArchLinux\n\nThere is an AUR package `booty-git`. Install it with your preferred tool, `pacaur` just for example.\n```sh\npacaur -S booty-git\n```\n\n## Quick start\n\nQuick Start (just run a test):\n\n```sh\n# booty/tests/crux_gnulinux-download-and-build\n# qemu-system-x86_64 -enable-kvm -m 1G -cdrom tmp.*/install.iso\n```\n\n## Boot options\n\nbooty's /init script can handle some kernel options (\"cheats\") while system boots.\n\n### boobs.use-shmfs\n\nAll system data will be extracted to the pure \"tmpfs\" filesystem and then continue booting.\n\nThis action may require a lot of RAM.\n\nExample, you have rootfs.cpio image with 1GB system stored in initrd image, and before\nsystem will be loaded completly they needed a 2GB of RAM: 1GB for rootfs.cpio and\none more 1GB for extracted data. Use this with carefully. But if your image stores on\nISO (not in initrd) you need only 1GB free of RAM.\n\n### boobs.use-overlayfs\n\nAll system data will be mounted as overlays. This is recommended usage option, but you\nshould enable the CONFIG_OVERLAY_FS=y in your kernel config.\n\n### boobs.search-rootfs\n\nOption required argument: `boobs.search-rootfs=file` or `boobs.search-rootfs=directory`.\n\nSearch selected file or the directory with overlays on storage devices while booting.\n\nBy default all created overlays stores in /system/overlays directory, but you can create\nown overlay with naming \"filesystem.squashfs\", put in root of your HDD and set this option:\n\n```sh\nboobs.search-rootfs=/filesystem.squashfs\n```\n\n### boobs.copy-to-ram\n\nWill copy overlays to the RAM before mounting.\n\nFor example, you can boot with USB and unplug your USB-stick after system boots.\n\n### boobs.rootfs-changes\n\nWhile using Overlay FS all your data stores in SHMFS (tmpfs, ramffs) by default, but you can\ncreate a empty file on your storage device, then create any supported by kernel filesystem on\nthis file (image) and use it as storage for your data, instead of storing data in temporarely SHMFS.\n\nExample `boobs.rootfs-changes=/dev/sda1` for using whole /dev/sda1 as storage for any changes.\nWhile reboots cache-data is keep. Storage (file with filesystem) must be created manually.\n\n## Utilities\n\nNow, let's talk about framework utilities.\n\n### mkbootstrap\n\n```\n# mkbootstrap \u003csystem\u003e \u003cdirectory\u003e [options] [packages]\n```\n\nThis command installs a \"chroot\" with the specified distro into a directory.\n\nWhere \u003csystem\u003e can be:\n\n* crux\\_gnulinux (internal)\n* archlinux\\_gnulinux (external!!!)\n* manjaro\\_gnulinux (external!!!)\n* debian\\_gnulinux (external!!!)\n* fedora\\_gnulinux (external!!!)\n* redhat\\_gnulinux (external!!!)\n* centos\\_gnulinux (external!!!)\n\n\n\u003e !!! Note: I wrote only crux_gnulinux wrapper, for other distros you must have\n\u003e pacstrap, basestrap, debootstrap, and other *straps installed.\n\ncrux_gnulinux options:\n\n```\n--ports-dir \u003cdirectory\u003e -- specify directory for search CRUX packages.\n\n[any packages] -- specify packages to install.\n```\n\nExample usage:\n\n1. Download a CRUX iso.\n2. Mount it to the \"./cruxmedia/\"\n\n\"./cruxmedia/\" contains directories with packages:\n\n\"./cruxmedia/crux/core\"\n\"./cruxmedia/crux/opt\"\n\"./cruxmedia/crux/xorg\"\n\nLet's install a full \"core\".\n\n```\n# mkbootstrap crux_gnulinux $(mktemp -d) \\\n    --ports-dir \"./cruxmedia/crux/core\"\n```\n\nOr install only some packages from the specified directories:\n\n```sh\n# mkbootstrap crux_gnulinux `mktemp -d`\t\\\n    --ports-dir \"./cruxmedia/crux/core\"\t\\\n    --ports-dir \"./cruxmedia/crux/opt\"\t\\\n    \"linux\" \"bash\" \"iputils\"\n```\n\nFilenames are allowed:\n\n```sh\n# mkbootstrap crux_gnulinux `mktemp -d`\t\\\n    \"./linux#5x-1.pkg.tar.xz\"\t\t\t\\\n    \"./cruxmedia/crux/core/bash#5.1-1.pkg.tar.xz\"\n```\n\nIf you choose another distro like debian_gnulinux, you must use \"debootstrap\"\noptions. mkbootstrap just switches to use the \"debootstrap\", nothing else.\n\n### exportroot / importroot\n\nFor saving and loading features you can run \"exportroot\" and \"importroot\".\n\nWell you have installed a \"chroot\" and you want to save the system state\nfor future use, so run:\n\n```sh\n# exportroot \"chroot/\" \u003e \"vanilla-system-state.rootfs\"\n```\n\nAnd then, when you want to setup another system from this \"chroot/\", run:\n\n```sh\n# importroot \"just-another-chroot/\" \u003c \"vanilla-system-state.rootfs\"\n```\n\nIt's usable when you only have one system state and many configurations.\n\nGo next.\n\n### mkinitramfs\n\n```sh\n# mkinitramfs \u003cdirectory\u003e [options]\n```\n\nThis command creates an initrd / initramfs image from the directory.\nYou can add overlays as well as directories or SquashFS images.\n\n* `--output` \"filename\" -- filename to output the image. Can output to a STDOUT.\n* `--standalone` -- create an initramfs image from the the directory \"as is\".\n* `--overlay` \"directory\" -- add an overlay usting the selected directory.\ncan be used so many times as you want.\n* `--as-directory` -- copy every overlay as directory.\n* `--as-cpio` -- creates cpio-archive from every overlay.\n* `--squashfs` -- creates SquashFS image for every overlay.\n* `--squashfs-xz` -- creates SquashFS image with XZ-compression for every overlay.\n\nExample:\n\nWe have installed a distro into \"chroot/\", let's make it bootable into a tmpfs.\n\n```sh\n# mkinitramfs $(mktemp -d) \\\n    --overlay \"chroot/\"\t  \\\n    --output \"initrd\"\n```\n\nIn this way the mkinitramfs compiles a \"chroot/\" directory into an \"initrd\" image \"as is\".\n\n```sh\n# mkinitramfs $(mktemp -d) \\\n    --overlay \"chroot/\"\t   \\\n    --squashfs\t\t   \\\n    --output \"initrd\"\n```\n\nIn this way the mkinitramfs creates from \"chroot/\" directory the SquashFS-image.\n\nYou can also specify as many overlays as you want. For example, you can have an overlay\nwith the system, an overlay with the configuration, an overlay with your home-data, and so on.\n\n```sh\n# mkinitramfs $(mktemp -d) \\\n    --overlay \"chroot/\"    \\\n    --overlay \"changes/\"   \\\n    --overlay \"/home\"      \\\n    --squashfs-xz          \\\n    --output \"initrd\"\n```\n\nEvery overlay will be compressed into a SquashFS image. Without --squash-xz it's\nstored as directories, by default mkinitramfs runs the \"cp -a\" command.\n\nAs an output, you have \"initrd\" image now. At this moment you can boot it via PXE.\nBoot your full system via PXE up and running in a tmpfs by one initrd-image!\n\nAlso you can create a bootable ISO image with included data.\n\n### mkbootisofs\n\nmkbootisofs just creating a BIOS / UEFI bootable ISO from the specified directory.\n\n```sh\n# mkbootisofs directory/ [options]\n```\n\nAvailable options:\n\n* `--output` \"filename\" -- filename to output the image. Can output to a STDOUT.\n\nAlso you can add overlays using the same options as in mkinitramfs, i.e.:\n\n* `--overlay` \"directory\" -- add an overlay usting the selected directory.\ncan be used so many times as you want.\n* `--as-directory` -- copy every overlay as directory.\n* `--as-cpio` -- creates cpio-archive from every overlay.\n* `--squashfs` -- creates SquashFS image for every overlay.\n* `--squashfs-xz` -- creates SquashFS image with XZ-compression for every overlay.\n\n\u003e !!! Note: Using the `--as-directory` for put it on ISO is not recommended.\n\nExample:\n\nFor ISO making you must create the ISO/ directory manually.\nPut a kernel and an initrd into it with your hands.\n\n```sh\n# mkdir ./ISO/\n# mkdir ./ISO/boot\n# cp /boot/vmlinuz ./ISO/boot/vmlinuz\n# cp ./initrd ./ISO/boot/initrd\n```\n\nNow you can just do mkbootisofs for create bootable ISO.\n\n```sh\n# mkbootisofs ISO/ \u003e bootable.iso\n```\n\nAnd then you can using \"dd\" to burn it on a USB-flash.\n\n```sh\n# dd if=./bootable.iso of=/dev/sdX status=progress\n```\n\nAlso you can create ISO image with some directories as overlays.\n\n```sh\n# mkbootisofs ISO/ \\\n    --overlay \"gnulinux-rootfs/\"    \\\n    --overlay \"rootfs-changes/\"   \\\n    --squashfs-xz          \\\n    --output \"boot.iso\"\n```\n\nSimple.\n\n### mkoverlayfs\n\n```sh\n# mkoverlayfs directory/ [options]\n```\n\nmkoverlayfs creates different archives from the selected directory.\nDon't use the `--overlay` option, use only one directory at time.\n\n* `--as-directory` -- Copy directory as directory. Nuff said.\n* `--as-cpio` -- Creates cpio-archive from directory.\n* `--squashfs` -- Creates SquashFS image from directory.\n* `--squashfs-xz` -- Creates SquashFS image with XZ-compression from directory.\n\nExample:\n\n```sh\nmkoverlayfs chroot/ \\\n    --squashfs-xz \\\n    --output chroot.squashfs \\\n```\n\nJust creates SquashFS XZ-compressed image from the \"chroot/\" directory.\n\n## Use cases\n\n1. Create a configuration once. Save it as a script. Use forever.\n\n   1. Living in tmpfs.\n   2. Just reboot upon system breaks.\n\n2. Update; just put a new vmlinuz and initrd to the production server and run:\n\n   `# kexec -l /vmlinuz --initrd=/initrd \u0026\u0026 kexec -e`\n\n   to reload new confgiuration \"on-the-fly\".\n\n   1. Edit it locally.\n   2. Reconfigure by one command or a script.\n   3. Test on a local QEMU or Bare-Metal.\n   4. Upload it to the remote server.\n   5. Do a kexec.\n\n3. Upgrade, from an existing GNU/Linux to the same but running in tmpfs.\n\n   1. Create your configuration by one command or a script.\n   2. Upload to the remote server (VDS or something).\n   3. `# kexec -l /vmlinuz --initrd=/initrd`\n   4. `# systemctl kexec` (a Debian-like way)\n   5. Create your own bootable ISO, upload it via the hoster's control panel.\n   6. Boot it every time from your own ISO with your configuration!\n   7. Format any existing /dev/vda disks, they are no more needed!\n   8. Use the full disk-space as encrypt-data storage, without any OS.\n\n4. Create your own portable GNU/Linux distro! Nuff said.\n\n## Examples\n\n### initrd as standalone linux system\n\nFor really good initrd do this step-by-step:\n\n* [ Download official CRUX GNU/Linux ISO ]\n* [ Mount it to ./cruxmedia ]\n\nThen run:\n\n* `./booty/bootstrap-templates/crux_gnulinux-embedded/crux_gnulinux-embedded.bbuild`\n\nAnd now you have \"crux_gnulinux-embedded.rootfs\" with ~160MB++ size.\n\n* `./booty/bootstrap-templates/crux_gnulinux-initrd/crux_gnulinux-initrd.bbuild`\n\nAnd now you have \"crux_gnulinux-initrd.rootfs\" with ~160MB++ size.\nIts a ready to boot initrd image, but 160MB...\n\n* `xz --check=crc32 --keep --threads=0 --best --verbose crux_gnulinux-initrd.rootfs`\n\nAnd now you have \"crux_gnulinux-initrd.rootfs.xz\" with 32MB size!\nCRUX GNU/Linux as initramfs with OpenSSH included!\nBoot and run \"ssh root@host-ip\" to login into initramfs! Enjoy!\n\n### boot to any linux from the storage device\n\nYou can boot to any Linux. For example I take the Gentoo GNU/Linux.\nSo got the Gentoo GNU/Linux, download stage3 first from the official web-site.\nDo it with your hands.\n\n```sh\n# wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/[...]/stage3-amd64-[...].tar.xz\n# mkdir gentoo/\n# tar xf stage3-* -C gentoo/\n```\n\nOptional do with your hands any configuration with \"chroot\". Any.\nNow create the SquashFS archive (overlay) with Gentoo's \"chroot\".\nPut it in everywhere... to the root of your storage device.\n\n```sh\n# mkoverlayfs gentoo/ --squashfs-xz --output /gentoo.squashfs\n```\n\nCreate a standlone initrd image.\n\n```sh\n# mkdir initramfs/\n# mkinitramfs initramfs/ \u003e /boot/initrd\n```\n\nAnd then setup your bootloader for booting by using this initrd with pass some\noptions to the kernel.\n\n```sh\nlinux /boot/vmlinuz boobs.use-overlayfs boobs.search-rootfs=/gentoo.squashfs\ninitrd /boot/initrd\n```\n\nOptional add the `boobs.copy-to-ram` option for booting to RAM and take out your\nstorage device.\n\nThats it. It can be USB storage or something else, you can setup your configuration\non the local machine, upload it to your KVM (VDS, VPS and so on) and boot! Enjoy.\n\n### MOAR\n\nJust see bootstrap-templates/ and bootstrap-systems/ for more examples.\n\nFor more examples how I use this look at the directories:\n\n* bootstrap-templates/\n* bootstrap-systems/\n\nTemplates - scripts for chroots creation and saving, nothing else.\n\nSystems -- scripts for production-ready images configuration and creation.\n\nFor example, run a template script:\n\n```sh\n# ./booty/bootstrap-templates/crux_gnulinux-embedded.bbuild\n```\n\nYou will get a \"crux_gnulinux-embedded.rootfs\" as a lightweight system for embedded use.\nNow you can use this template to configure all your embedded systems, adding\nsome packages, setting up config files, and so on.\n\nSo then, run a system script:\n\n```sh\n# ./booty/bootstrap-systems/crux_gnulinux-core/crux_gnulinux-core.bbuild\n```\n\nAnd now you will get a \"production-ready\" install.iso.\n\nGG\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdifrex%2Fboobstrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdifrex%2Fboobstrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdifrex%2Fboobstrap/lists"}