You can easily put the writable filesystem (in the casper-rw file)
for a live media onto a hard disk. The limitation is that the
casper-rw file must go on a FAT partition. Newer machines (UEFI)
all have a FAT EFI partition, but that's typically too small to hold
a 1G-4G casper-rw file. On another big enough FAT partition, you can
make directories, each holding a casper-rw file for possibly different live medias.
Suppose sda11 is 10G and has a 10G FAT filesystem, mounted at /mnt/sda11,on which there are directories /A , /B , /C , /D , and /E. Assume we will use /A for our persistent media, putting a casper-rw there.
cd /mnt/sda11/A
dd if=/dev/zero of=casper-rw bs=1M count=4096
mkfs.ext4 -F -O^has_journal -L casper-rw casper-rw
Take your live media created with persistence, and edit the /boot/grub/grub.cfg file and the /syslinux/txt.cfg file, adding after the word "persistent"
"persistent-path=/A"
/boot/grub/grub.cfg
...
menuentry "Try Ubuntu without installing" {
set gfxpayload=keep
linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --- cdrom-detect/try-usb=true noprompt persistent persistent-path=/A
initrd /casper/initrd.lz
}
/syslinux/txt.cfg
default live
label live
menu label ^Try Ubuntu without installing
kernel /casper/vmlinuz.efi
append noprompt cdrom-detect/try-usb=true persistent persistent-path=/A file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash ---
label live-install
...
That's it. You don't even need to rename/remove the casper-rw file on the USB media.
If there's room on the USB media, you can even copy the hard disk's casper-rw back to the USB, and take your changes with you.
The persistent-path does not allow any explicit disk reference, so should be unique across all FAT partitions. Tested with 1 or 2 FAT partitions (one being the EFI partition). Will not work on an ext2 or ntfs filesystem instead of FAT. If you also add the "toram" word on the same line as "persistent", your compressed filesystem on the slow USB will be copied into ram and give much better performance, however,
there seems to be a shutdown issue, with the FAT partition not being cleanly unmounted (which does not seem to cause any problems but...)
Ok, I understand you in two different ways. First one is that you simply need Ubuntu on a USB stick, so that you can install it to some system using that same USB stick. In other words, the USB stick replaces the installation DVD. This would be done like this:
- download the desired ISO-image of Ubuntu. This could be
ubuntu-17.10-desktop-amd64.iso
.
- Insert the USB stick into your computer and type
sudo fdisk -l
to find the device name your USB stick has in your system. If I put a USB stick in my system, the name will be /dev/sdc
.
- Copy the ISO-image to your USB stick using
sudo dd if=/path/to/your/iso/ubuntu-17.10-desktop-amd64.iso of=/dev/sdc
. You'll have to adapt the path and the drive to your system. Oh, and pay attention to the drive. If it fdisk
shows you something like /dev/sdc1
and /dev/sdc2
, then you still use only /dev/sdc
without the number behind, because you want to overwrite all the partitions on the stick.
- Reboot your system and boot from your USB stick.
The other way your question could be interpreted, is that you want to use your USB stick as main or secondary drive. This should be fairly simple. Use gparted
to partition your USB stick. For instance a 2 GB SWAP, a 50 GB ext4, and the rest with a third partition with ntfs. You'll use the SWAP and the ext4 partition for Ubuntu and the ntfs partition for file exchange between Windows and Linux.
Best Answer
In Ubuntu, Debian and many but not all 're-spins' [operating systems] based on them, you can install mkusb and create a persistent live drive according to the following links,
help.ubuntu.com/community/mkusb
help.ubuntu.com/community/mkusb/persistent
In Windows, you can install and use
Rufus, an extracting tool, which is easy to use.
Win32 Disk Imager, a cloning tool, and clone an image file with [a persistent live operating system and] mkusb. See the following links,
wiki.ubuntu.com/Win32DiskImager/compressed-image_2_USB-or-SD
Compressed image file with a persistent live system
In most operating systems (including MacOS), you can also try with Unetbootin according to the following link,
unetbootin.github.io/