Multi-distro LiveUSB
From ParabolaWiki
1 Introduction
This howto shows how to create a liveusb that can:
- contain more than one iso.
- contain other partitions
2 Howto
This howto was tested on qemu, adapt it for real hardware.
- convert The isos to be able to run on a partition
# isohybrid --partok trisquel_6.0.1_i686.iso
parabola-2013.09.01-dual.iso seems to be already converted.
- create the image, I used qemu for testing so I created a loop file.
# qemu-img create -f raw ./usd.img 3780M
- find the isos size with size.sh
# ./size.sh trisquel_6.0.1_i686.iso +708608K
- create partitions with fdisk, for example:
# fdisk ./usd.img Welcome to fdisk (util-linux 2.25). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xb94f94ec. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): First sector (2048-7741439, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-7741439, default 7741439): +32M Created a new partition 1 of type 'Linux' and of size 32 MiB. Command (m for help): p Disk ./usd.img: 3.7 GiB, 3963617280 bytes, 7741440 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb94f94ec Device Boot Start End Sectors Size Id Type ./usd.img1 2048 67583 65536 32M 83 Linux Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (2-4, default 2): First sector (67584-7741439, default 67584): Last sector, +sectors or +size{K,M,G,T,P} (67584-7741439, default 7741439): +708608K Created a new partition 2 of type 'Linux' and of size 692 MiB. Command (m for help): p Disk ./usd.img: 3.7 GiB, 3963617280 bytes, 7741440 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb94f94ec Device Boot Start End Sectors Size Id Type ./usd.img1 2048 67583 65536 32M 83 Linux ./usd.img2 67584 1484799 1417216 692M 83 Linux Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p Partition number (3,4, default 3): First sector (1484800-7741439, default 1484800): Last sector, +sectors or +size{K,M,G,T,P} (1484800-7741439, default 7741439): +481280K Created a new partition 3 of type 'Linux' and of size 470 MiB. Command (m for help): p Disk ./usd.img: 3.7 GiB, 3963617280 bytes, 7741440 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb94f94ec Device Boot Start End Sectors Size Id Type ./usd.img1 2048 67583 65536 32M 83 Linux ./usd.img2 67584 1484799 1417216 692M 83 Linux ./usd.img3 1484800 2447359 962560 470M 83 Linux Command (m for help): n Partition type p primary (3 primary, 0 extended, 1 free) e extended (container for logical partitions) Select (default e): p Selected partition 4 First sector (2447360-7741439, default 2447360): Last sector, +sectors or +size{K,M,G,T,P} (2447360-7741439, default 7741439): Created a new partition 4 of type 'Linux' and of size 2.5 GiB. Command (m for help): Command (m for help): p Disk ./usd.img: 3.7 GiB, 3963617280 bytes, 7741440 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb94f94ec Device Boot Start End Sectors Size Id Type ./usd.img1 2048 67583 65536 32M 83 Linux ./usd.img2 67584 1484799 1417216 692M 83 Linux ./usd.img3 1484800 2447359 962560 470M 83 Linux ./usd.img4 2447360 7741439 5294080 2.5G 83 Linux Command (m for help): w The partition table has been altered. Syncing disks.
- check if there is already some dm-mapper loop partitions
# ls -l /dev/mapper/loop* ls: cannot access /dev/mapper/loop*: No such file or directory
If there is none, you're good
- Then add the partitions mapping
kpartx -a usd.img
- check if it worked:
ls -l /dev/mapper/loop*
# ls -l /dev/mapper/loop* lrwxrwxrwx 1 root root 7 Sep 7 12:54 /dev/mapper/loop0p1 -> ../dm-7 lrwxrwxrwx 1 root root 7 Sep 7 12:54 /dev/mapper/loop0p2 -> ../dm-8 lrwxrwxrwx 1 root root 7 Sep 7 12:54 /dev/mapper/loop0p3 -> ../dm-9 lrwxrwxrwx 1 root root 8 Sep 7 12:54 /dev/mapper/loop0p4 -> ../dm-10
- install grub on the boot partition:
# mkfs.ext4 /dev/mapper/loop0p1 mount /dev/mapper/loop0p1 /mnt cp -a /boot/grub/ /mnt/ umount /mnt mount /dev/mapper/loop0p1 /boot grub-install ./usd.img umount /boot
- Add the isos:
ddrescue trisquel_6.0.1_i686.iso /dev/mapper/loop0p2 -f ddrescue parabola-2013.09.01-dual.iso /dev/mapper/loop0p3 -f
- Add the data partition:
mkfs.ext4 /dev/mapper/loop0p4
# kpartx -d ./usd.img # dmsetup remove /dev/mapper/loop0p4 # dmsetup remove /dev/mapper/loop0p3 # dmsetup remove /dev/mapper/loop0p2 # dmsetup remove /dev/mapper/loop0p1 # sync
Now you have the image ready, I tested with qemu like that:
qemu-system-i386 -enable-kvm -serial stdio -m 2047M -hda ./usd.img
Then in grub I did:
set root=hd0,msdos2 syslinux_configfile /isolinux/isolinux.cfg
And the trisquel menu appeared. I then could boot trisquel
3 grub.cfg
menuentry 'Trisquel' { set root=hd0,msdos2 syslinux_configfile /isolinux/isolinux.cfg } menuentry 'Parabola' { }