LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to create bootable USB with multiple partitions? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-bootable-usb-with-multiple-partitions-4175602849/)

Wolfpeach42 03-30-2017 12:47 PM

How to create bootable USB with multiple partitions?
 
I'm trying to create a bootable live linux USB stick with a separate data partition, as it seems a waste to have several gig of unused space after the iso.

I've tried using gparted to partition an 8Gig stick into two FAT32 partitions, first one 7Gig (for data), second one 1Gig (for an iso), marking the 2nd partition as "bootable".

Then I opened a terminal in the folder containing the iso, and used:

sudo dd if=[iso name] of=/dev/sdc1 bs=4M

I'm sure that /dev/sdc1 was the correct partition.

I've tried with a Linux Lite iso, and also a Puppy Linux iso.

The iso write seems to work fine, but then when I try to boot from the stick, it does not recognise it. When I use a standard USB with a single partition, containing an iso of one of the same distros created in windows with Win32DiskImager, it works fine.

BW-userx 03-30-2017 01:10 PM

Two partition bootable USB

if this allows two then the same mythology should let you create more then two. I have not read it.

yancek 03-30-2017 02:24 PM

Using dd to the device /dev/sdb rather than a partition should work and give you a bootable usb. I'm not aware of any way to create another partition on the device written this way with dd.

Using various other software, you can create a bootable usb with persistence and if you have a persistent usb which can be done with some Linux distributions, you may not have to create the mount point or mount it each time. Not really sure about the mounting, an entry in fstab. I've tried that a few times with persistent usb drives and never got it to work.

You can install Grub to the MBR of the usb drive pointing to the boot directory that you have created previously and manually create a grub.cfg file to boot an iso on that partition or another partition. Booting an iso directly is possible with Grub2 but will not boot all version of Linux. This again is a read-only filesystem so you will need to create a mount point and manually mount each boot.

A likely reason for your not being able to boot the usb you created with dd is writing to the partition rather than the device.

Shadow_7 03-30-2017 02:43 PM

I've had limited success with partitioning the storage device and rsync-ing the / of the image.

# mount -o loop -t iso9660 image.iso /mnt/loop
# cd /mnt/loop
# ls

A lot of the newer bootable images put the actual / in a squashfs file in a sub-tree. And other /boot/ and such sub imaging. So getting to an rsync-able / that is bootable isn't always easy.

# mount /dev/sdX# /mnt/partition
# rsync -aRXHv ./* /mnt/partition/

Although I tend to make a minimal debootstrap install on another partition to "rescue" and contain a bootloader like grub. Which is how I manage booting the various partitions.

-----

But to be honest, use something like easy2boot. You'll have better odds of maintaining your sanity.

Rickkkk 03-30-2017 03:18 PM

Quote:

Originally Posted by Wolfpeach42 (Post 5690365)
I'm trying to create a bootable live linux USB stick with a separate data partition, as it seems a waste to have several gig of unused space after the iso....

I don't think you really need another partition on the USB drive to do this. After formatting it as a bootable distro, just use the rest of the space on the same partition ... Create a "Data" directory if you like, to distinguish it more readily.

Cheers,

jefro 03-30-2017 05:12 PM

There may be a few ways to make dual booted usb. As above notes, dd to a partition is not correct when using an iso. Even if it were a hybrid iso.

Another way might be to get a large enough usb and install each linux on it as if it were a real mechanical hard drive. Then you'd have loader(grub2 usually) and two linux distros. If you get too many distro's you may have to work on issue about primary partitions and such.


You could use tools like YUMI (I think) that create multiboot usb's.

Could use grub4dos and boot directly to some iso images.

yancek 03-30-2017 06:11 PM

Quote:

I don't think you really need another partition on the USB drive to do this. After formatting it as a bootable distro, just use the rest of the space on the same partition ... Create a "Data" directory if you like, to distinguish it more readily.
That won't work as the OP wants a Live CD which will be read-only whether using dd, unetbootin or similar software. The easiest thing to do is to do an actual install which could easily be done with Puppy. The Linux Lite iso is only 800+ MB so that could probably be installed on an 8GB flash with room to spare on the same partition or another partition.

Wolfpeach42 03-30-2017 06:56 PM

Quote:

Originally Posted by yancek (Post 5690425)
Use the dd command on the device (/dev/sdc) rather than the partition. Boot another Linux system with GParted or GParted from a CD. Resize (shrink) the part you have the iso on to slightly larger than the iso.

i reformated the USB, and used dd on the device (sdc) rather than the partition (sdc1) - this gives me a bootable USB stick. So far so good... However, it has no partitions on it. GParted comes up with the error "Invalid partition table - recursive partition on /dev/sdc", and does not recognise anything on the USB to shrink. It lets me create a partition... but this wipes the iso and I am back to square 1.

It seems burning the iso on the device gives a bootable stick, but no partitions, so I cant use the same stick to store anything. Creating partitions, and burning the iso to one of the partitions, produces a stick that is not bootable.

Wolfpeach42 03-30-2017 07:27 PM

Tried something else - rather than reformat the whole disk, and knowing that the iso was at the start, and just under 1gig in size, I created a partition after the iso (sdb1, leaving the first gig unallocated. This worked, and the usb was still bootable (I'm using it now...) but I have not been able to mount or access sdb1. fdisk shows me that the partition exists, but I cant access it (tried, see below)

Disk /dev/sdb: 7.2 GiB, 7747397632 bytes, 15131636 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: 0x613089a1

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2539520 15128575 12589056 6G b W95 FAT32

linux@linux:~$ mkdir /tmp/x/
linux@linux:~$ sudo mount /dev/sdb1 /tmp/x/
mount: /dev/sdb1 is already mounted or /tmp/x busy

Rickkkk 03-30-2017 07:57 PM

Quote:

Originally Posted by yancek (Post 5690537)
That won't work as the OP wants a Live CD which will be read-only whether using dd, unetbootin or similar software. The easiest thing to do is to do an actual install which could easily be done with Puppy. The Linux Lite iso is only 800+ MB so that could probably be installed on an 8GB flash with room to spare on the same partition or another partition.

Hmmmm. I do this all the time. The difference perhaps is that I use YUMI to format the USB drive to allow me to have several ready to boot distros and tools. If there is any space left in the single partition on the drive, it is accessible read/write (formatted FAT32) for any usage whatsoever.

I apologize - I should have been clearer about that particularity.

Cheers !

yancek 03-30-2017 10:42 PM

Quote:

The difference perhaps is that I use YUMI to format the USB drive to allow me to have several ready to boot distros and tools.
There's more to YUMI than simply doing a dd of an iso which the OP indicated he was using. What happens with dd is explained in post 8 above, the 'invalid partition table' message.

Quote:

I created a partition after the iso (sdb1, leaving the first gig unallocated. This worked, and the usb was still bootable
Your post immediately prior to the above explains that, you have no partition table. I recall using dd to write an iso to a flash drive and getting the same message when accessing it in GParted. I don't know how one could access and use different partitions without a partition table?

You might try YUMI suggested above which works well. The best software I have found to create a bootable usb with a separate data partition is mkusb. It creates a boot partition, installs the iso on a separate partition, creates an ext4 persistent partition any size you want as well as an ntfs partition for data. Very simple, fast and reliable. The drawback is that from what I have read, it is only Ubuntu and derivatives so you would need an Ubuntu to run it from but it would work with Linux Lite.

Wolfpeach42 03-31-2017 02:16 AM

Thanks All! Futzing with bootable partitions and MBRs seems to escalate rapidly way past my capability, so I will try YUMI and mkusb as recommended above (Someone also recommended easy2boot).

[Edit: YUMI seemed to work initially, and booted at first thru the YUMI loader, then the Linux lite initial "feather" screen, but stopped at a screen asking for a Ubuntu username & password... which I had never set, as this was a fresh boot from a live iso... odd. Lucid Puppy Linux worked first time, though!]

yancek 03-31-2017 08:14 AM

What you describe in your last post is not expected behavior. When I booted Linux Lite from the iso, it booted directly to the Desktop. Either something went wrong with the creation during YUMI or you might have had a bad download of the iso. Glad you got the Puppy working.

Wolfpeach42 03-31-2017 08:54 AM

Quote:

Originally Posted by yancek (Post 5690780)
What you describe in your last post is not expected behavior.

Inorite!? I will try again with a fresh Linux Lite iso download and install. But, in any case, YUMI seems to have done the job. Really elegant, easy to use way to create live linux USB sticks (that will also store data). The ability to boot multiple distros is cherry on the cake.

trumpforprez 03-31-2017 09:42 AM

Quote:

Originally Posted by Wolfpeach42 (Post 5690795)
Inorite!? I will try again with a fresh Linux Lite iso download and install. But, in any case, YUMI seems to have done the job. Really elegant, easy to use way to create live linux USB sticks (that will also store data). The ability to boot multiple distros is cherry on the cake.

Glad to hear the good news.
I have a full debian OS burnt onto a 16gb usb. The OS uses up the whole usb.
I booted from a separate OS (on my HDD), opened gparted and attempted to shrink the OS on the usb. However, gparted wouldn't let me. I'm wondering if that was your situation.

I did lsblk to see if the usb was mounted automatically when I booted from my OS on my HDD:
Code:

lsblk -o name,mountpoint,label,size,uuid
Turns out the usb was mounted and that's why gparted wouldn't let me make changes to the usb.
I unmounted the usb, opened gparted and it let me shrink the OS and add a data partition.


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