You are not logged in.

#1 2019-11-29 03:12:58

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,217

Multiboot iso's and use all of the disk space on a thumb drive. :)

Ok fellows, as sharing is caring and I don't really have a gnu/Nix forum HQ. Some cool things a person can do with usb(thumb drives.) To me it's always seemed kind of silly to devote a multi-gig usb drive to one iso, ie: Bunsenlabs gnu/Nix one I had onhand is 1.1gbs, usb it was on is 14+gigs, this is no bueno. That's a lot of drive space sitting wasted. So having messed with multibooting iso's off a thumb drive before, decided to play around some more.

Let's do this ...

Insert your thumb drive, using gparted or similar, create a new partition table on it, type msdos, this is going to wipe everything off the usb drive. I then created one ext2 formatted partition on the whole thing. Gparted will tell you what your usb drive is called, using the "lsblk" command is good to know, as a usb drives sdX can/will change. Will deal with that later on though. Point is it's good to know "lsblk" will give you good info about attached block devices (such as a usb drive.) Now it's time to install grub onto the thumb drive. In my case at that time the usb drive was showing up as sdc and that ext2 formatted partition on it is sdc1 then. Follow these steps ...

Someone needs to create a mount point, a place to mount it. In my case I have a couple but keep one at /mnt/temp for this type of thing. Create a mount-pt.

sudo mkdir -p /mnt/temp

Mount the thumb drive there, again ... in this my thumb drive is sdc ...

sudo mount -t ext2 /dev/sdc1 /mnt/temp

Time to install grub to the thumb drive. Note: I don't currently have a uefi/gpt system, my old beastie laptop is bios/mbr so that's the version of grub I'm going with. On a uefi/gpt system, unlikely to boot without the CSM (legacy compatiblity thingy)set in your uefi/bios folks. Anyway, if you wish to create a hybrid (bios/mbr - uefi/gpt) bootable usb device there's plenty of info on that, so adapt as necessary. Getting back though, installing grub to the thumb drive.

sudo grub-install --force --removable --boot-directory=/mnt/temp/boot /dev/sdc

Note: I'm installing grub to the drive (sdc), not the first partition on the thing, yeppers that'd be sdc1 in my case.


Go ahead and launch your file-manager of choice with privileges and then navigate to System ( / /root directory), then the /boot directory, then click your way into the grub directory and copy the grub.cfg file you find here. Ok the thing (usb drive)is still mounted at /mnt/temp. So someone can navigate to the usb drive kay. smile Installing grub as per above is going to create /boot/grub on the thing, click your way into that location and paste the grub.cfg file you just grabbed from your working OS/install. While already here, create a new directory inside of the boot directory, name it iso and so far so good. If you're following along correctly, if you reboot your OS now and it's set to boot from usb as the first in boot order or you otherwise select this in whatever way it works on your system and choose to boot from the usb drive that was just setup. You'll be greated with a grub2 menu, listing all the OS's which were installed on the OS you copied the grub.cfg file from. Cool ... yep, you can select any of them and they'll boot from your systems hard drive.

Now to add some iso's onto the thumb drive and edit the grub.cfg on the thing so they can be booted too. Download all your favorite iso's, these can be system rescue, different gnu/Linux iso's, anti-virus etc etc. Of course I'm going to get you started with an example of Bunsenlabs gnu/Nix, in my case that's Hydrogen but doesn't matter as the same applies to others. The trick with this, is figuring out the magic grub menuentry for these iso's and am only going to get people started. So with your thumb drive plugged in and mounted to whichever mount point ie: /mnt/temp, open your file-manager with privileges again and navigate to the thumb drive, copy the iso's you're wanting to boot from it into that directory located at /boot/iso then open the grub.cfg file on the usb drive and scroll down it until finding this section.

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

As it says, this is where custom menuentries can be added. Here's what I used/added to boot Bunsenlabs gnu/nix Hydrogen.

menuentry "Bunsenlabs gnu/Nix 64bit" {
 set isofile="/boot/iso/bl64.iso"
 loopback loop $isofile
 linux (loop)/live/vmlinuz-4.9.0-8-amd64 boot=live config fromiso=/dev/disk/by-uuid/7a10842f-2935-46cd-8489-09c537d650ac/$isofile
 initrd (loop)/live/initrd.img 
}

This is the secret sauce here, if I used /dev/sdc1 or whatever, where it says fromiso='s ... that can/will change, however by using my thumb drives UUID it doesn't. So grub knows where to find the iso I want to boot, also I renamed the Bunsenlabs iso to be bl64.iso because it's much easier to work with that way, less typing, less chance of mistakes etc. You find your thumb drives(usb drives)UUID by plugging it in and using the "sudo blkid" command in a terminal. Mentioned it can be tricky or irritating to find the magic menuentry needed to successfully boot an iso but oh well, nothings perfect. Finding the correct one's are a mixture of science, coupled with black magic and extensive googling at times. smile Using the devices UUID is a dang good trick you just got freely.

Have mentioned google ie: "X-distro +iso +grub.cfg" etc to find menuentry's which work. Someone can extract the iso, which will create a directory where it's extracted and then dig through it for clues as to what to use, ie: In Hydrogen, there's a directory called live, inside of which were the vmlinuz (kernel) and initrd.img. Sometimes in other distro's-etc these can be named something else. People need to take that up with dear Google. smile

Other interesting stuff, an extracted iso or iso's in general can be customized and modified, adding/removing packages, the kernel version, changing config's etc. Then made back into an iso for use. In the case of Hydrogen, can rid it of that annoying "Welcome to Bunsenlabs" thing that pops up everytime I boot the iso (I KNOW I JUST BOOTED A HYDROGEN live session ... tyvm.) Changing default keybinds, getting rid of the conky telling me which keybinds do what etc.

OTHER STUFF: Ext2 is better than fat32 for many reasons(Oops edit: For me anyway). Don't need journaling, file size limitation is no longer a headache, isn't subject to fragmentation, supports gnu/Nix file permissions etc etc blahblahblah. Done this way I can use all my thumb drive space, storing stuff like OS backups or whatever else and another interesting possibility, can always shrink the partition down so I can fiddle around with adding persistence for whichever iso's later on. That's a wrap ... Sharing is caring, so whoever plays with this, nice if you'd sound off and share working grub menuentry's for whichever iso's, so others benefit.

I'll start ... This is one for Slitaz gnu/Nix, it's just a weird little distro and I haven't dorked with it in awhile.

menuentry "SliTaz Rol1ing core64 - LiveISO" {
	set isofile="/boot/iso/slitaz64.iso"
        loopback loop $isofile
        linux (loop)/boot/bzImage64  rw root=/dev/null video=-32 kmap=en-US autologin
        initrd (loop)/boot/rootfs.gz
}

Also ... Happy turkey day folks ! smile

Last edited by BLizgreat! (2019-11-29 03:47:29)

Offline

#2 2019-11-29 03:33:12

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,088
Website

Re: Multiboot iso's and use all of the disk space on a thumb drive. :)

This looks like fun. Busy today but will definitely try it soon.
Thanks!


John
--------------------
( a boring Japan blog, idle Twitterings and GitStuff )
In case you forget, the rules.

Offline

#3 2019-11-29 03:52:36

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,217

Re: Multiboot iso's and use all of the disk space on a thumb drive. :)

^ Welcome John-san, hope you and yours are having a good day-night. This junk does present some interesting possibilities. Of course isn't meant as the final word on the topic. Being gnu/Nix and tech associated there's just too much to about anything to even try. Though I'm happier not having a 14gb thumb drive only using 1.1gbs. Have 5-6 iso's on it and only using up 2.3gbs of the space. Errrr though so far only bothered getting 2 of them to boot as of yet, shrugs.

Are lotsa other cool things which come to mind for this too. Spent a BUNCH of time figuring out the dang device switcharoo junk that went on before discovering using UUID for this. Posting this in Hydrogen now. It's movie and relaxation time. smile

Offline

#4 2019-11-29 04:59:35

rbh
Member
From: Sweden/Vasterbotten/Rusfors
Registered: 2016-08-11
Posts: 88

Re: Multiboot iso's and use all of the disk space on a thumb drive. :)

For lazy ones. there is this python program: multiboot http://multibootusb.org/.

Support booting many distro isos and persistency.


// Regards rbh

Offline

#5 2019-11-29 05:58:52

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,217

Re: Multiboot iso's and use all of the disk space on a thumb drive. :)

^ Can sometimes be a good place to snag menuentry's too or interesting to study how they approach doing this type of thing. smile Nothing wrong with pointing out alternatives but I like doing it this way, even if yep, sometimes it's a PITA. Arghhhh ... doesn't matter it's like anything with learning and practice needless to say someone will get better and faster.

Wanted to point out something weird and sort of related. Someone can also do similar with a rw-cd/dvd of course. As one time use discs also annoy me personally and another thing about installing grub to such a media (cd-dvd) If someone finds themselves on a system which doesn't support usb booting, can work around it with a portable grubby media. Of course such hardware is increasingly rare anyway but this nonsense popped into my head and out of the keyboard. big_smile

Keeping a usb's grub.cfg file updated to reflect changes to your system can be good juju no doubt as well. As in the event of the one(bootloader)you've got controlling the systems bootup, should it ever get borked, easy enough to use this type of junk, boot it or one of the others if multibooting etc. Could play a role in getting into things and enabling someone to easily reinstall or unbork a bootloader (w/o chroot etc). Not that there aren't plenty of ways regardless. One of the iso's I like, it's called Supergrubdisk2 is fairly kickarse for such. Can apparently boot just about everything imaginable. However it appears it's going to take awhile for me to find the magic key to getting that baby to boot from usb via this method. hmm

Ah no worries, I've been exclusively gnu/Linux now for years so don't care about booting uefi/gpt Window$ ... blahblahblah. Bunch of cool things can be done with this junk. Ok ... later folks, it's several hours past movie/relax time !

Last edited by BLizgreat! (2019-11-29 06:00:43)

Offline

#6 2019-12-01 00:12:15

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,217

Re: Multiboot iso's and use all of the disk space on a thumb drive. :)

Just more babble, someone can no doubt mount the usb created via the normal methods and still use the disk space on the thumb drive fully. Bunsenlabs or whichever other thing kept on the thumb drive shouldn't care if there are extra directories/files on the drive as long as the right one's are in the correct places almost surely going to work just fine regardless. The ole in gnu/Linux everything is a file, YEP. Just as with an actual bare metal install, gnu/Linux doesn't care if there's an extra directory or file(s)kept here, there ... anywhere. Still going to run fine. Believe I've done what I'm describing here with usb drives in the past, though don't remember 100%. Point here is again, kind of foolish to waste an entire thumb drive for one thing eh. smile

Am just doing this nonsense as described in OP cause it's interesting and presents some cool possibilities. Though as noted there are existing multiboot tools readily available too. Haven't dorked with very many personally. So yeppers, make it a +1 to the nixer who mentioned it. There are of course options. Some of these buggers are wonky and getting them to boot via this method is indeed annoying at times, if even possible. One such being Puppy gnu/Linux, it's problematic figuring out for varied reasons. Might explore extracting it vs booting it as an .iso and see if that will enable the thing to run from usb drive. Only a matter of learning and experimenting enough and yay!, isn't learning fun !??! Nope, sometimes it's a friggin Pain In The Azz !!! tongue

Last edited by BLizgreat! (2019-12-01 00:15:20)

Offline

Board footer

Powered by FluxBB