This question is different from the one marked as duplicate as I know how to install Ubuntu on an USB Key but I want to have an additional partition on this USB Key
I have an USB 3.0 Stick with 64GB and I want to use it to save some backup data in an encrypted Partition but also have one partition with a bootable ubuntu.
Making a bootable ubuntu stick is easy:
# sudo dd if=ubuntu-16.04.2-desktop-amd64.iso of=/dev/sdX bs=1k count=2048 conv=fdatasync
(changed sdd to sdX to prevent users from copying it and harm their system)
But then I get a strange partition table:
# fdisk -l /dev/sdd
Medium /dev/sdd: 58,4 GiB, 62746787840 Bytes, 122552320 Sektoren
Einheiten: sectors von 1 * 512 = 512 Bytes
Sektorengröße (logisch/physisch): 512 Bytes / 512 Bytes
I/O Größe (minimal/optimal): 512 Bytes / 512 Bytes
Typ der Medienbezeichnung: dos
Medienkennung: 0x15e2543d
Gerät Boot Start Ende Sektoren Größe Id Typ
/dev/sdd1 * 0 3035519 3035520 1,5G 0 Leer
/dev/sdd2 14432 19295 4864 2,4M ef EFI (FAT-12/16/32)
This seems to be correct as my stick is booting fine. But I really don't understand it.
When I partion the usb device before and have one FAT32 and one LUKS parttion then I still can dd
the iso to the first partition /dev/sdd1
but it is not bootable anymore.
I set the bootable flag on the first partition of course an my laptop tries to boot it but only shows a blinking underscore.
There are so many misleading informations in the web about this scenario. I am lost. I am familiar with partitioning, and MBR and GRUB but only in using it. It seems I never really understood what is going on and many things have changed since I last did it (EFI, loop devices..)
It seems to be very difficult to use an USB stick as a bootable ubuntu AND as a backup partition. But I still think this should be a matter of
- Formatting and partitioning USB stick
- Copying ISO to partition
- Make some magic like MBR, bootable flag, Grub2
Can somebody help with a small step-by-step command line example to get things running on a modern ubuntu 16.04?
The second partition doesn't need to be mounted on Windows by the way.
I'll answer you question in an effort to clear your confusion.
You can make a bootable USB. Just install Ubuntu the USB stick. Once you have this bootable disk, you can repartition, resize, and make the same changes to the USB drive the same way you do on your regular system's hard drive.
This bootable drive that you have created can be cloned to an ISO, just as your regular internal hard drive can be cloned to an ISO. You use the
dd
command in your question to make copies of this ISO into other drives. After you make copies you can also edit and modify the partitions as you indicated for your criterion.The thing you can't do is make an ISO of a CDROM installer, or use a LiveUSB ISO installer (which is built using the same basic algorithm of a DVD, but on an USB stick instead) as your cloned drive. As you see from the details your experience included in your question, the drive would be corrupted (as far as being able to boot) if you make partition changes.
While this isn't what you are looking for, a deliberate and specific design has gone into making an installer version (called a persistent usb) to overcome the limited design and intent of the OS installer.
An ubuntu installer with the ability to modify the partitions of the media doesn't exist at this time. If it did exist, someone would post the source as an answer, or point you to the solution.
You could, alternatively, while it may take a lot of work, make your own installer and add it to your own Ubuntu pendrive. It's discussed here: Install from existing Linux
This is an alternate method of making your own LiveUSB for your Pendrive:
Installation/FromLinux
I haven't attempted to create this environment. So I can't comment on whether the task would be easy. I'm just trying to provide you with what would be involved if you are trying to have a Pendrive that can be used as an installer and also have partitions that are editable.
You can create a persistent live drive with mkusb. Directly after that, while still booted from the other system, you can edit the partition table and shrink some partition and create your own partitions. But I think the partition structure of the persistent live drive by mkusb is good enough for your purpose. There is an
ext
partition for persistence and anNTFS
partition for communication with Windows computers. You can store files in both of those partitions.There is a total of 5 partitions. It can look like the following listed output in a USB 3 pendrive with 128 GB. During the installation you can decide the percentage of the available drive space for persistence (the
casper-rw
partition with theext2
file system, and the rest of the drive space will be used for theusbdata
partition with theNTFS
file system). In this case I used the default, 50%.See details at the following links,
help.ubuntu.com/community/mkusb
help.ubuntu.com/community/mkusb/persistent
mkUSB-quick-start-manual-12.pdf