Saturday, October 12, 2019

How to make an ubuntu install disk in linux

To build an ubuntu install disk usually programs such as rufus are used. I don't like to use extra programs because you cant always have them or they get old and become unsupported quickly. So I note here my experiences building an Xubuntu install disk. I assume this instructions should work with current flavors of ubuntu and maybe other linux distributions.

If we dont have an fat32 formatted disk first build one:
I assume disk is /dev/sdd and partition is /dev/sdd1
>fdisk /dev/sdd (in my case sdd, it may vary according to how your flashdisk is recognized as)
fdisk>o (create empty partititon table)
fdisk>n (create new primary partition and assign all space to it)
fdisk>a (assign as  boot partition)
fdisk>w (save)
fdisk>q (quit)
>mkdosfs -F32 -nDISKNAME /dev/sdd1 (format the partition you just made)

Now mount the partition we just made or use partition we already have
>mount /dev/sdd1 /mnt (mount partition)
>mkdir /mnt/syslinux (other directory names could also be used)
>cp /usr/lib/syslinux/bios/*.c32 /mnt/syslinux (copy c32 files)
>syslinux --directory /syslinux --install /dev/sdd1 (install bootloader to partition boot record and copy boot files to /syslinux)

->now extract iso image to /mnt

>cp /mnt/isolinux/*.cfg /mnt/syslinux
>cp /mnt/isolinux/*.pcx /mnt/syslinux
>cp /mnt/isolinux/*.png /mnt/syslinux
>cp /mnt/isolinux/*.jpg /mnt/syslinux
>cp /mnt/isolinux/bootlogo /mnt/syslinux
>mv /mnt/syslinux/isolinux.cfg /mnt/syslinux/syslinux.cfg

-> now open /mnt/syslinux/txt.cfg in your text editor  (source: https://askubuntu.com/questions/47076/usb-boot-problems)
replace "file=/cdrom/preseed/xubuntu.seed" (may be ubuntu.seed lubuntu.seed and so on)
with "live-media-path=/casper/  ignore_uuid"

>sync (write changes in cache to disk)
>umount /dev/sdd1 (unmount)

now you should be set. If nothing hapens when booting with  this disk you either forgot to assign partition as active (fdsik a) or mbr boot code of the disk is invalid. To write a correct mbr:
>dd if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sdd bs=440 count=1