📜 ⬆️ ⬇️

Create your own Debian LiveCD boot disk

image

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

To begin with, I wanted to create my bootable cd disk for a long time, but my hands did not reach. Usually I just managed to dump the system if I wanted to make a copy of the working one. But every time you do everything with your hands - your hands wither. Moreover, not everyone will explain how to make a copy of the system, how to split and format the disk, make the disk bootable. Not everyone, you know, has a working Linux at hand. Well, my hands begged and tired of doing everything on the cheat sheets - kindergarten to God.

Let's go to practice. Install these great packages.
')
apt-get install xorriso live-build extlinux syslinux squashfs-tools 


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

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

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


Then we twist, we mount the necessary directories to emulate a working system. To generate a UUID, install dbus-uuidgen. Next, we put the kernel and the necessary utilities for live download. Well, then do not deny yourself anything, install everything you want. You can also install X and autoload these X under a user or root. Later, when you have already made a disk, you can test it on a virtual machine and if you don’t like to redo it immediately by entering the chroot folder in 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 .... passwd apt-get clean rm /var/lib/dbus/machine-id && rm -rf /tmp/* umount /proc /sys /dev/pts exit 


In short, the image of the system we have created. Next, create a folder for the live loader. 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 boot from 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 endtext 


All is ready! Now it only remains 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/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o remaster.iso binary 


The second time you start collecting a disk, delete the file binary / live / filesystem.squashfs, 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 in anticipation of a new rebuild.
I have a script in the livework folder that I run when I want to re-create the disc.

 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/boot.cat -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 disk mbr. Well, to boot, use extlinux instead of isolinux, if your partition is formatted with EXT. In the example, the disk is / dev / sda, and the system image is mounted in / 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 into another file, since now you aren’t ISO EXT.

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


Slightly away from the topic. Live ISO image is good because it is stable and does not change. It's bad that he loads the RAM. If you want to get rid of the compressed image, the download will change. So, if we have NOT a compressed image of the system and we just want to register its load, then we write such a config.
 nano /mnt/extlinux.conf 


File contents. Then replace ### uuid ### with yours or write root = / dev / sda1 , for example.
A full path is written to the kernel, links are not channeled. I repeat, here we have moved a little away from the topic, the config is needed not for a compressed system, but for a normal 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 LiveCD compressed system, copy the folder to a disk with a compressed file system.

 cp -R live /mnt 


I hope nothing messed up.

Source: https://habr.com/ru/post/242219/


All Articles