LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 12-26-2020, 12:17 PM   #1
eight.bit.al
Member
 
Registered: Jul 2015
Location: Prison
Distribution: a new distro every day
Posts: 124

Rep: Reputation: Disabled
Question 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.
 
Old 12-26-2020, 01:08 PM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
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.
 
Old 12-26-2020, 01:26 PM   #3
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
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.
 
Old 12-26-2020, 07:51 PM   #4
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
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.
 
Old 12-27-2020, 01:02 PM   #5
eight.bit.al
Member
 
Registered: Jul 2015
Location: Prison
Distribution: a new distro every day
Posts: 124

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
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 View Post
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 View Post
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 View Post
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
 
Old 12-27-2020, 03:33 PM   #6
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Quote:
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.
 
Old 12-28-2020, 11:40 AM   #7
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Quote:
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.
 
Old 12-28-2020, 03:33 PM   #8
eight.bit.al
Member
 
Registered: Jul 2015
Location: Prison
Distribution: a new distro every day
Posts: 124

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sgosnell View Post
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.
Kali? Did you mean KaOS? https://kaosx.us/

8bit
 
Old 12-28-2020, 10:51 PM   #9
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
I know little about either.
 
Old 12-28-2020, 10:59 PM   #10
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
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:
Code:
DEFAULT loadconfig

LABEL loadconfig
  CONFIG /isolinux/isolinux.cfg
  APPEND /isolinux/
extract kdeos directory to second partition
install syslinux to usb

Last edited by colorpurple21859; 12-29-2020 at 07:37 PM.
 
Old 12-29-2020, 05:01 PM   #11
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Quote:
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.


Code:
grub-install --target=x86_64-efi --recheck --removable --efi-directory=/mnt/efi --boot-directory=/mnt/seagate/boot
Code:
grub-install --target=i386-pc --recheck --boot-directory=/mnt/seagate/boot /dev/sdb
You will have to change the mount points to what you actually used from those above.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying ISO to thumb drive using 'dd' causes thumb drive to be read-only? ahc_fan Linux - General 8 01-15-2019 08:10 AM
dd to copy a thumb drive which I am live booted on to another thumb drive DrinkinHomeBrew Linux - Newbie 3 01-26-2015 04:52 PM
[SOLVED] If I dd copy a bootable usb drive to an iso will the iso be bootable? mgallatin Linux - Software 5 03-23-2011 04:46 PM
Diagnostics on bootable CD to bootable thumb drive IsItFridayYet Linux - Newbie 15 10-12-2007 06:24 AM
how to make usb thumb drive bootable with Redhat enterprise linux 3 niranjan_mr Linux - Hardware 2 11-05-2006 04:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration