You are not logged in.

#1 2025-02-20 00:33:17

Kardell
Member
From: London a new Babylon
Registered: 2007-02-20
Posts: 276

What is the best way to install OS on a USB stick (multi-partition)?

Hi All,
I hope you are well.
I have a 32GB USB stick and I want the OS on it but the catch is I want at least 2 more partitions on that stick.
I could just dd the iso to the /dev/sdX and then try and resize the partition, create new ones but this is not a clean solution.
I don't know if Unetbootin tool can do that but again I would prefer to do it by hand so I can script it.

I think I don't want to go the MBR legacy way but UEFI.

wipefs --all /dev/sdg
dd if=/dev/zero of=/dev/sdg bs=1M count=10

parted /dev/sdg mklabel gpt
parted /dev/sdg mkpart primary fat32 1MiB 512MiB
mkfs.vfat -F32 /dev/sdg1
parted /dev/sdg set 1 esp on
parted /dev/sdg mkpart primary ext4 512MiB 5.5GiB
mkfs.ext4 /dev/sdg2
... the other partitions will follow

mount /dev/sdg2 /mnt/usb
mkdir -p /mnt/usb/boot/efi
mount /dev/sdg1 /mnt/usb/boot/efi

grub-install --target=x86_64-efi --efi-directory=/mnt/usb/boot/efi --boot-directory=/mnt/usb/boot /dev/sdg
grub-mkconfig -o /mnt/usb/boot/grub/grub.cfg

at some point I have to copy the OS to sdg1 partition but I don't know what source should I use? the ISO or the running OS?
I think me dd the ISO to sdg2 will mess the partition table.

I could go with Arch based SystemRescueCD but I think this time I want the GUI but something lightweight like LXDE not Gnome (Meow 3.0)
What would you recommend?


"Those who don't know history are doomed to repeat it." Edmund Burke

Offline

#2 2025-02-20 00:35:42

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,694

Re: What is the best way to install OS on a USB stick (multi-partition)?

Kardell wrote:

at some point I have to copy the OS to sdg1 partition but I don't know what source should I use? the ISO or the running OS?

Neither, this is what pacstrap is for. Just follow the Installation Guide, with a few minor changes: https://wiki.archlinux.org/title/Instal … ble_medium

Offline

Board footer

Powered by FluxBB