[SOLVED] Make a bootable iso thumb drive with second partition for files
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Make a bootable iso thumb drive with second partition for files
Been searching high and low with no joy. I tried formatting the thumb drive with two partitions and using dd to write the iso to the first partition, won't boot.
Any help? TIA
8bit
Last edited by eight.bit.al; 12-26-2020 at 12:24 PM.
You might be able to do this more easily with some of the software tools such as unetbootin, rufus, etc. but if you use dd to write the iso to a flash drive, attach the flash drive to a computer with a Linux OS and make sure the filesystem on the flash is not mounted. Shrink to just over the size of the iso with whatever partition manager you use (GParted)and then create a second partition and filesystem for storage.
Two things here, the iso you installed will be live so you can't save any changes unless you first boot it then create a mount point for the second partition and mount it on each boot. The second thing is if you want to use it with windows, you have to have a windows filesystem and it has to be on the first partition of the flash drive which complicates things.
If you have one of the Ubuntu derivatives, mkusb is a good tool. Not sure it is available in other distross.
An easy way to do this is with ventoy. You install ventoy to a USB drive, and it becomes bootable. You do a simple copy of as many .iso files as you like, and boot any one of them via a menu at boot. The entire drive is accessible, for saving any type file you like. There is no need for dd or anything else, it's just a simple copy. The ventoy app does everything necessary through running the install.
This is a general howto, without knowing what iso/distro, some modifications may be needed to get this to work.
The manual way:
Assuming the usb is /dev/sdb, change accordingly
Create a new dos partition table.
Create two partitions. The first partition large enough to hold the iso, formated fat32 and the boot flag set. The second partition the storage partition, formatted however you like.
Mount the first partition
Extract the contents of the live iso to the partition.
As root in a terminal run
Code:
mount /dev/sdb1 /mnt
grub-install --target=i386-pc --boot-directory=/mnt/boot --recheck /dev/sdb
If you get a "no i386-pc" error with the grub-install, you will need to install the proper grub-pc package then rerun the grub-install command.
This will get a live usb that will boot in both efi and legacy mode.
Last edited by colorpurple21859; 12-27-2020 at 09:50 AM.
if you use dd to write the iso to a flash drive, attach the flash drive to a computer with a Linux OS and make sure the filesystem on the flash is not mounted. Shrink to just over the size of the iso with whatever partition manager you use (GParted)and then create a second partition and filesystem for storage.
This is one of the things I tried. Neither gparted nor KDE Partition Manager could edit the read only ISO9660 partition.
Quote:
Originally Posted by sgosnell
An easy way to do this is with ventoy.
Ventoy worked, sort of. It would not boot KaOS, but did boot the several other distros I tried it with. Just happened it was KaOS I wanted to use for this project. NO distro, when booted from the Ventoy thumb drive, could read the additional files I put on the thumb drive. The files were available from the Ventoy thumb drive when plugged into any running system, just not when booted from the Ventoy thumb drive. So, mostly fail.
Quote:
Originally Posted by yancek
If you have one of the Ubuntu derivatives, mkusb is a good tool. Not sure it is available in other distross.
Next I tried mkusb. DL'ed a live Unbuntu iso, wrote it to a thumb drive, and booted. Installed mkusb and it wrote KaOS and a second partition to a second thumb drive. I was able to read the additional files I copied to the second partition while booted from the same thumb drive. Success all around.
Quote:
Originally Posted by colorpurple21859
Create a new dos partition table.
Create two partitions. The first partition large enough to hold the iso, formated fat32 and the boot flag set. The second partition the storage partition, formatted however you like.
Mount the first partition
Extract the contents of the live iso to the partition.
As root in a terminal run
Code:
mount /dev/sdb1 /mnt
grub-install --target=i386-pc --boot-directory=/mnt/boot --recheck /dev/sdb
This created a bootable thumb drive that came to a grub shell prompt, and not much else. I tried both extracting and dd copying, no joy. dd copy ended with a grub rescue prompt. Maybe there's another step after installing grub.
Heard some good things about Regolith Linux. https://regolith-linux.org/ Built with Ubuntu, GNOME, and i3. Gnome without the ugly Desktop. Nice. Installed it on a spare drive (loved it) and also installed mkusb. Win/Win.
Thanks all for your input.
8bit
Last edited by eight.bit.al; 12-27-2020 at 01:24 PM.
Reason: minor grammer fix
This is one of the things I tried. Neither gparted nor KDE Partition Manager could edit the read only ISO9660 partition.
I thought I had done this previously so tried it again and had the same results you did, not able to access or mount from the booted iso. Trying to mount shows already mounted but but not where. I had no luck with gparted but was able to create an additional partition with fdisk and format it with mkfs but it was only accessible when booted from another Linux install. If there is a way to do this after using dd to copy the iso, I have never seen it.
I have rarely used dd as I usually have several 'live' systems on a usb so I simply install grub and then copy the iso files to the same or another partition and manually create the grub.cfg file and the menuentries. Almost any major Linux OS can boot from an iso with Grub2 and it's usually not difficult to find an example with just an online search.
Quote:
Maybe there's another step after installing grub.
I would guess it is creating the grub.cfg file and creating the menuentries although I haven't tried this.
Ventoy worked, sort of. It would not boot KaOS, but did boot the several other distros I tried it with. Just happened it was KaOS I wanted to use for this project. NO distro, when booted from the Ventoy thumb drive, could read the additional files I put on the thumb drive. The files were available from the Ventoy thumb drive when plugged into any running system, just not when booted from the Ventoy thumb drive. So, mostly fail.
Strange. I can access anything on the ventoy drive, whether anything is booted from it or not. I've never had any need for Kali, so I have no idea what's going on with that.
Strange. I can access anything on the ventoy drive, whether anything is booted from it or not. I've never had any need for Kali, so I have no idea what's going on with that.
This isn't ideal but it seems to work. I think the problem is the iso looks for a disk label name that is too long for use on a fat32 partition.
Use rufus in windows to install iso to usb, use the maximum allowed for the size of the persistence partition. After rufus is done open disk management.
delete the persistence partition and create a new volume at least 2.5G in size formated ntfs labeled the same name as the iso, you can get the iso label name from the rufus log. It will be something like this: KAOS_20201116
copy the kdeos folder from the other usb parition to the the ntfs partition.
The usb will now be bootable in both legacy and uefi with space left on the usb for other partitions. I tried to do it manually with linux, but as usual I always seem to have trouble with getting the syslinux boot-loader to work.
edit: From linux
create first partition 200mb fat32 boot flag set
create second partition 2.6G ntfs labeled same as iso ie: KAOS_20201116
extract efi loader isolinux directories to first partition
create a kdeos directory on first partition and extact boot and isomounts from iso kdeos directory to the kdeos directory
create a syslinux.cfg on first partition with this in it:
This created a bootable thumb drive that came to a grub shell prompt, and not much else. I tried both extracting and dd copying
I used the method described in post 4 above and the usb booted both EFI and Legacy. I initially forgot to set the vfat partition as active and also got the error about i386-pc. Set sdb1 (vfat partition active) and copied the i386-pc directory and contents from /usr/lib/grub to the vfat partition on the usb in /boot/grub and then it worked. I had also created 2 ext4 partitions with one being labelled casper-rw for persistence, put the word persistent at the end of the linux line of grub.cfg menuentry on the usb. Was able to copy folders/files to the 2nd ext4 partition. The casper-rw allows persistence for most Ubuntu derivatives (Lubuntu in this case) to write to the system and save some settings such as wireless and to install software. If you are trying to use something other than an Ubuntu, the casper-rw part won't help save settings or install software on it but you can use it to store data as on any other partition.
Another method using a gpt usb drive is to first create a 1-2MB unformatted partition labelled bios_grub. I then created a 200MB vfat partition as the EFI directory and 2 ext4 partitions. I mounted both the vfat (sdb2) and the first ext4 (sdb3) partitions. On the first ext4 partition, I copied all the folders/files from the iso I had (bodhi) and then ran the 2 commands below to install Grub for EFI and Legacy. Since the files for the bodhi iso were on an ext4 partition, it was not necessary to mark any partitions active. For the Legacy install to work, you need the i386-pc directory and its contents in the /boot/grub directory of the system you are installing or creating the usb from. When I booted bodhi and opened pcmanfm filemanager, the partition for data was shown in the left panel and I could copy (as root/sudo) to that partition. Didn't do persistence on this.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.