I've just received two messages with the same question related to my previous article Create your first ISO image: "Is there a way to create an USB stick with it ?". Short answer is: "Yes, there's script to do it" but if you're still reading you may want more information. Here's what you might do if you want to create a bootable USB stick from your virtual slax build machine.
I'm still referring to my previous article: "Create a custom distro: Create your first ISO image", path and directories are still the same
Take a look at the source !
The creation of a bootable USB stick is not a mess, it's quite simple, if you take a closer look to "bootinst.sh" script located into the /boot directory you might understand what you can do with it but if you're lazy or you want to have more automation you may use the script listed below, I've created it for personal purposes but it's basically a wrapper of bootinst.sh.
Let's keep the same virtual machine, same paths and locations, just place a script in the same dir where you've placed the script for creating the ISO image for CDs (/root/target/).
#!/bin/bash # This script builds an ISO file from the image created BASEPATH=/mnt/sda1/target TARGET=/dev/sdb1 MOUNTPOINT=/mnt/sdb echo "Mounting and formatting the USB Stick" mkdir -p $MOUNTPOINT umount $TARGET 2>/dev/null mkfs.ext2 $TARGET -m 0 # Device not found or not mounted if [[ $? -ne 0 ]]; then echo -e "TARGET USB DEVICE NOT FOUND, INSTALLATION FAILED !!" exit fi mount $TARGET $MOUNTPOINT echo -e "Generating `du -kLs image` size" echo "Copying contents into the USB Stick..." cp -Rd $BASEPATH/image/* $MOUNTPOINT/ $MOUNTPOINT/boot/liloinst.sh echo -e "Target disk size" df $TARGET umount $TARGET echo -e "Installation Completed"
This script is very simple but just to be clear here's what it does:
- Create the mount point for your usb stick
- Format the usb stick (ext2 is sufficient but you may use something else)
- Mount your usb drive
- Copy the contents with your new image in it
- Add lilo to make it bootable
In my virtual environment /dev/sda is my primary virtual hard disk, take a look at previous article for path usage, /dev/sdb is what VMWare uses when I connect an USB stick to the virtual machine. Before running this script make some checks in your current system, as you can see it's a batch script to format and wipe sdb internal contents, so you've been warned !
If you're inside my virtual environment you don't need to worry about it
liloinst.sh script is smart enough to understand where it resides and it applies lilo in the MBR of the mounted drive.
There's a lot of space for improvements so if you modify it or automate the script a little bit more just drop me few notes or send me your version and I'll modify and republish it for the community
As usual feel free to contribute with your comments