Create your own LiveCD Debian boot disk


    I decided to share this knowledge. All this I myself collected on the Internet. I tested and made sure that it works. I will give a few comments on this instruction to make it clearer.

    To begin with, I wanted to create my boot cd disk for a long time, but my hands did not reach. Usually I just got around the system dump if I wanted to make a working copy. But every time you do everything with your hands - your hands will dry out. Moreover, you will not explain to everyone how to make a copy of the system, how to split and format a disk, make a disk bootable. Not everyone, you know, has working Linux on hand. Well, then my hands were prayed and tired of doing everything on cribs - kindergarten, by golly.

    Let's move on to practice. Install these great packages.

    apt-get install xorriso live-build extlinux syslinux squashfs-tools

    xorriso to create a bootable
    syslinux image , extlinux to use the mbr boot
    squashfs-tools to create a compressed
    live-build file system to create the system itself, which will be clamped and placed into the iso image

    Create a directory for the image and unpack the minimal system with the selected architecture. chroot is the root folder where the image will be.

    mkdir ~/livework && cd ~/livework
    debootstrap --arch=i386 wheezy chroot

    Next, let’s go, mount the necessary directories to emulate the working system. To generate the UUID, set dbus-uuidgen. Next, put the kernel and the necessary utilities for live downloads. Well, then we don’t refuse anything to ourselves, we install everything we want. You can install Xs and make autoloading of these Xs as a user or root. Later, when you have already made the disk, you can test it on a virtual machine and, if you don’t like something, immediately redo it by logging in to the chroot folder.

    cd ~/livework
    chroot chroot
    mount none -t proc /proc
    mount none -t sysfs /sys
    mount none -t devpts /dev/pts
    export HOME=/root
    export LC_ALL=C
    apt-get install dialog dbus
    dbus-uuidgen > /var/lib/dbus/machine-id
    apt-get install linux-image-686 live-boot
    apt-get install dump bzip2 mc icewm ....
    apt-get clean
    rm /var/lib/dbus/machine-id && rm -rf /tmp/*
    umount /proc /sys /dev/pts

    In short, we created the image of the system. Next, create a folder for the live bootloader. We copy vmlinuz and inird kernels of your created system into it. And create a compressed file system from the chroot folder

    mkdir -p binary/live && mkdir -p binary/isolinux
    cp chroot/boot/vmlinuz-* binary/live/vmlinuz
    cp chroot/boot/initrd.img-* binary/live/initrd
    mksquashfs chroot binary/live/filesystem.squashfs -e boot

    Next, copy the files needed to download from the CD, edit the boot menu.

    cp /usr/lib/syslinux/isolinux.bin binary/isolinux/.
    cp /usr/lib/syslinux/menu.c32 binary/isolinux/.
    nano binary/isolinux/isolinux.cfg
    ui menu.c32
    prompt 0
    menu title Boot Menu
    timeout 300
    label live-686
    	menu label ^Live (686)
    	menu default
    	linux /live/vmlinuz
     	append initrd=/live/initrd boot=live persistence quiet
    label live-686-failsafe
    	menu label ^Live (686 failsafe)
    	linux /live/vmlinuz
    	append initrd=/live/initrd boot=live persistence config memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal

    All is ready! Now all that remains is to create a disk image.

    xorriso -as mkisofs -r -J -joliet-long -l -cache-inodes -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin -partition_offset 16 -A "Debian Live"  -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -o remaster.iso binary

    When you start collecting the disk for the second time, delete the binary / live / filesystem.squashfs file, otherwise the computer will find out for a long time what needs to be added to the gigabyte archive. And you will be nervous, scratching the back of your head while waiting for a new rebuild.
    I have a script in the livework folder that I run when I want to recreate the disk.

    rm binary/live/filesystem.squashfs
    mksquashfs chroot binary/live/filesystem.squashfs -e boot
    xorriso -as mkisofs -r -J -joliet-long -l -cache-inodes -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin -partition_offset 16 -A "Debian Live"  -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -o install.iso binary

    If you want to make the same system image on a flash drive, then there is nothing easier.
    The only difference is that you do not need to create a disk image, but instead you need to mark the partition with the system boot (fdisk) and write to the boot area of ​​the mbr disk. Well, to boot use extlinux instead of isolinux if your partition is formatted in EXT. In the example, the drive is / dev / sda, and the system image is mounted on / mnt

    extlinux -i /mnt && cat /usr/lib/extlinux/mbr.bin > /dev/sda
    cp /usr/lib/extlinux/*.c32 /mnt && cp /usr/lib/syslinux/vesamenu.c32 

    The boot menu can be copied from your ISO image but to another file, since now you have not ISO but EXT.

    cp isolinux/isolinux.cfg /mnt/extlinux.conf

    A little away from the topic. Live ISO image is good in that it is stable and not mutable. It's bad that he loads the RAM. If you want to free yourself from the compressed image, then your download will change. So, in case we have a NOT compressed image of the system and we just want to register its loading, then we write such a config.
    nano /mnt/extlinux.conf

    File contents. Here ### uuid ### replace with yours or write root = / dev / sda1 , for example.
    The full path is written to the kernel, links do not channel. I repeat, here we are a little off topic, the config is needed not for a compressed system, but for a regular one.

    ui vesamenu.c32
    prompt 0
    timeout 300
    menu title Boot Zagruzka
    menu color title 1;33;44
    menu color sel 7;37;40
    menu color unsel 33;44
    menu color border 33;44
    label Linux-Debian-686
            kernel /boot/vmlinuz-3.2.0-0.bpo.2-686-pae
            append initrd=/boot/initrd.img-3.2.0-0.bpo.2-686-pae root=UUID=###uuid### ro quiet
    label Linux-Debian-686 (rescue mode)
            kernel /boot/vmlinuz-3.2.0-0.bpo.2-686-pae
            append initrd=/boot/initrd.img-3.2.0-0.bpo.2-686-pae root=UUID=###uuid### ro single

    Well, actually, returning to the compressed LiveCD system, copy the folder to the disk with the compressed file system.

    cp -R live /mnt

    I hope I haven’t messed up anything.

    Also popular now: