Mk-boot-usb: Easily Creating a [Self-Cloning] Bootable USB Key
By HUNG Chao-Kuei on Monday, February 18 2008, 22:19 - Permalink
Mk-boot-usb is a perl script to create multiple-bootable usb keys. It wipes out an entire usb key, partitions it, creates file systems on it, installs grub, and installs a minimal linux on it. Mk-boot-usb is meant to speed up and lower the barrier of entry for creating bootable usb keys. The usb key will immediately become bootable (using the minimal linux), and more useful distributions can then be installed into other partitions manually simply by (1) copying any Live CD into each partition (2) modifying grub's configuration file. Starting from version 08g, it supports cloning: use mk-boot-usb to create a first bootable usb key and install mk-boot-usb into it, and then with a simple command you can use it to clone many more bootable usb keys that have cloning capabilities themselves!
Think about your next linux install-fest. Now you don't need to ask people to bring their desktop computer. Instead just ask them to bring a usb key. And a notebook if they really wish to see it work immediately.
It doesn't even have to be a geek event like linux install-fest. You can demonstrate this in 10 minutes to your non-technical audience. For example, next time when you give a FLOSS speech (even to non computer science students), please ask the event correspondent to ask the audience to bring their own usb keys. If you are lucky enough to have an assistant who is not too afraid of command line, s/he can help create a bootable key for every person while you give the talk. Then ask the audience to test this usb key on new computers they plan to buy. This will have at least two effects: (1) Make sure that the hardware supports linux well, including booting from usb. (2) Show the computer sales what is possible with linux. By the way please also distribute portable apps on the first partition.
That's what I will do anyway :-) That was the major motivation behind this work. Happy advocating.
Comments
How can i use this to boot parted magic from usb? The default boot from usb of parted magic does't work for me.
Thanks!
I found GPL Gujin bootloader better for that (Loads of options if you want to autoboot without any menu or even load an ISO9660 image inside a partition of your USB drive), download:
http://downloads.sourceforge.net/gu...
Then type (if USB drive is in /dev/sdg):
umount /dev/sdg*
dd if=/dev/zero of=/dev/sdg bs=512 count=63 # triple check the output device of= parameter!!!
./instboot boot.bin /dev/sdg -d=BIOS:0x80,auto --mbr-device=/dev/sdg
indifference: I downloaded http://exo.enarel.eu/mirror/partedmagic/pmagic-usb-2.0.zip and unzipped it to the primary partition of a bootable usb key created by mk-boot-usb. Then I added this entry (a direct translation of its default boot entry from the syslinux syntax) to boot/grub/menu.lst :
I was able to boot it from qemu and saw the bluish graphic screen. Did you make sure to copy the pmagic file into the _primary partiton_ of your usb stick? The document says it has to be in a FAT16 or FAT32 partition.
However it hangs later, saying,
This is beyond me and I suggest that you google for an answer and then possibly ask PartedMagic author for help.
Etienne: gujin looks more like an alternative to grub/syslinux to me, right? All three are real projects with lots of hard work. The mk-boot-usb script, on the other hand, is just a convenient wrapper that hide a few commands from the ordinary users and make some sensible (but inflexible) choices for them so that they don't have to be bothered with details like partitioning and creating file systems. Thanks for posting the info and I will see if gujin can replace not only grub but also some of mk-boot-usb's functions from below when I have time.
this seams like the perfect thing to do usb sticks with, but where do I get it?
Hi,
a while ago I was using ubuntu and it created a perfectly bootable usb stick. Now I switched to Suse11 and it seems to work but the stick is not bootable at all.
You may want to look into that.
Regards, Scar
Thank you, Scar. I'll look into that. So far I have only tested it in Ubuntu and have successful report from Debian users. There are now unsuccessful reports from Fedora and Suse.
The above refers to the environment where you issue the mk-boot-usb command. [Let's call it the working env.] I have tried, or people have reported that Ubuntu, Slax, Fedora, DSL, and a few others have been successfully created as the environment that the usb boots into [Let's call it the target env.]
mk-boot-usb is a greate tool to create bootable usb. But I am unable to make the usb persistent( I have checked all the options described in making it persistent). will here any help be available . if so please reply to this. and I will explain what i did.
Local Electronic shop had cheap 8GB DataTravelers sticks on sale.
Ubuntu 8.10 usb install doesn't work - can't find linux image
Unetbootin doesn't work. - can't find linux image
mk-boot-usb - worked perfectly.
Thanks,
Hi to everybody :-)
I think that this is a wonderfull script, sure, but, I don't know why, it can't work on my Usb Pendrive;
first some generic information, than the text file (launched by srcipt shell.txt during my installation);
-I've an Philps pendrive 8Gb FAt32 (.?08FD02B/00)
I Want to put on this key 4 Linux distro (DSL 4.4.6; Slax 6.0, Knoppix 5.1, Puppy,3.1), and I decided to divide my pen drive in this way:
6000 (Fat32) 130 (Dsl ) 130 (puppy) 900 (knoppix) 472 (Slax)
- I've tryed several time to run your script and I've otteined some different error message obteinig different result: some time in the partition Sda4 (when the script have fineshed to work) I've found the folder boot+ lost&found and other time only the folder lost&found; some time in the foldere boot/grub there was the spalsh image and the menu.list, other time only the file "device map" and the binary file of the stage, some times it seems that Grub was installed (when i found the file device map and bynary file) and other time (tis is the case of the shell script that i'll put in this post) No;
Well i'm tired to try (i'ts one week that i try), I thik that I make some mistake when I try to do this work, (I'm a "little rookie" in th eLinux world) but I want understand my mistake :-) and I've also the suspect that my Key is not good to do What I Want:
So her folow the shel.txt registred during my last test
I'm sure that someone can't find the real problem :-)
Script started on Thu Jan 29 12:30:52 2009
root@slax:~# tar xzf mk-boot-usb-08h.tgz
root@slax:~# ls
Desktop mk-boot-usb-08h.tgz shell.txt usr
root@slax:~# cd usr
root@slax:~/usr# cd 7sbin
bash: cd: 7sbin: No such file or directory
root@slax:~/usr# m
Display all 115 possibilities? (y or n)
root@slax:~/usr# m./m ./mk ls
sbin share
root@slax:~/usr# cd sbin
root@slax:~/usr/sbin# mk
mk_cmds mkfileswap mkfs.cramfs mkfs.reiserfs mkmanifest mkslaxsave
mkdir mkfontdir mkfs.ext2 mkfs.xfs mknod mksquashfs
mkdosfs mkfontscale mkfs.ext3 mkhybrid mkpasswd mkswap
mke2fs mkfs mkfs.jfs mkisofs mkreiserfs mktemp
mkfifo mkfs.bfs mkfs.minix mklost+found mkrescue mkzftree
root@slax:~/usr/sbin# mk / ./mk-boot-usb
ls: cannot access /dev/sd?: No such file or directory
=+=+= Insert the usb stick, wait a few seconds (often the usb stick
=+=+= will flash a bit), and press enter to continue. If file manager(s)
=+=+= pops up, please press control-C to abort and read the web pages
=+=+= about disabling automatic mounting.
=+=+= Your usb stick has these partitions: /dev/sdc /dev/sdc1 /dev/sdc2 /dev/sdc4 /dev/sdc5 /dev/sdc6 /dev/sdc7
=+=+= The most recently modified few files in each partition are:
mount: No such file or directory
=+=+= [ /dev/sdc ]
total 0
umount: /tmp/mk-boot-usb/mnt/sdc: not mounted
=+=+= [ /dev/sdc1 ]
total 0
mount: No such file or directory
=+=+= [ /dev/sdc2 ]
total 0
umount: /tmp/mk-boot-usb/mnt/sdc2: not mounted
=+=+= [ /dev/sdc4 ]
total 12
drwx------ 2 root root 12288 Jan 29 12:22 lost+found
=+=+= [ /dev/sdc5 ]
total 12
drwx------ 2 root root 12288 Jan 29 12:22 lost+found
=+=+= [ /dev/sdc6 ]
total 12
drwx------ 2 root root 12288 Jan 29 09:33 lost+found
=+=+= [ /dev/sdc7 ]
total 12
drwx------ 2 root root 12288 Jan 29 12:22 lost+found
=+=+= size of destination stick /dev/sdc: 7648 MB
=+=+= partition 4 using 16 MB; 7632 MB available for other partitions
=+=+= Type in a list of numbers separated by spaces representing
=+=+= the sizes of each partition in MB. For example:
=+=+= 7332 60 240
=+=+= means 1 fat and 2 ext2 partitions, each of size 7332, 60, 240 MB.
=+=+= Sizes: 6000 260 900 472
=+=+= THESE FILES and ALL OTHER FILES on /dev/sdc will be destroyed!
=+=+= Press 'yes' to continue. Are you absolutely sure?yes
16065+0 records in
16065+0 records out
8225280 bytes (8.2 MB) copied, 24.6803 s, 333 kB/s
sh: line 1: /usr/share/mk-boot-usb//lilo.mbr: No such file or directory
Disk /dev/sdc: 974 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdc: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdc1 0+ 763 764- 6136798+ c W95 FAT32 (LBA)
/dev/sdc2 764 971 208 1670760 5 Extended
/dev/sdc3 0 - 0 0 0 Empty
/dev/sdc4 * 972 973 2 16065 83 Linux
/dev/sdc5 764+ 796 33- 265041 83 Linux
/dev/sdc6 797+ 911 115- 923706 83 Linux
/dev/sdc7 912+ 971 60- 481918+ 83 Linux
Successfully wrote the new partition table
Re-reading the partition table ...
=+=+= formatting /dev/sdc1 ...
mkdosfs 2.11 (12 Mar 2005)
=+=+= formatting /dev/sdc4 ...
=+=+= formatting /dev/sdc5 ...
=+=+= formatting /dev/sdc6 ...
=+=+= formatting /dev/sdc7 ...
=+=+= copying ttylinux and customized grub config files to /dev/sdc4 ...
cp: cannot stat `/usr/share/mk-boot-usb//boot/': No such file or directory
=+=+= installing grub to /dev/sdc4 ...
sh: grub: command not found
grep: /tmp/mk-boot-usb//device.map: No such file or directory
Died at ./mk-boot-usb line 404, <STDIN> line 3.
ro
note: the error message "sfdisk: ERROR sector 0 have not an msdos siganture in this case it's no true 'cause the pendrive was formatted wiht HP-USB-DISK STORAGE- FORMATT TOOL enabling the option "create an Ms-Dos boot disk" whit the help of Windows enabler 1.1 (i've foloww this tutorial :http://www.aetherwide.com/vignettes...)
All this test was made on Slax 6.0 in Virtual Box 1.5.0, knoppix live and Knoppix in VirtualBox 1.5
> sh: line 1: /usr/share/mk-boot-usb//lilo.mbr: No such file or directory
This line tells the story. You should "cd /" before "tar xzf mk-boot-usb-08h.tgz" Well, I have to admit that the output of my script is really untidy. Now, there are several other programs that create a bootable linux pendrive for you using more friendly GUI, such as unetbootin and portable linux. I haven't tried them yet, but I would recommend that you try these if mk-boot-usb still doesn't work for you. Good luck and have fun!
Hi HUNG Chao-Kuei,
first thank: you write in your post my probably mistake so i can try to use your script in the correct way; probably, a long time ago, everyone was a rookie :-) ;
second: I think that you made a wonderfull script to put linux in one time in several pen drive, and tis is fantastic for the linux-diffusion in general but.........
It seems that you are a little touchy: I've told in my last post that "I think that i've made some mistake" or probably my pendrive in not godd for your script, BUT I DON'T TELL YOU THAT YOUR SCRIPT IT'S WRONG OR IT'S A BAD SCRIPT!!!!!!
It's possible that your script it's no good for THE TYPE OF PENDRIVE IN QUESTION (PHILPS 8Gb): Before tryng your script I tried UNIBOOTINI with the same result (the pen drive was not bootable but pheraps i can change something in my BIOS 'cause i'm starting to think that a pend drive of 2Gb and one of 8Gb is not the same things for my AMIBIOS);
Well, I'll try also portable linux but I hope to have succes with your script 'cause IT'S THE ONLY ONE THAT CAN PREPARE YOUR PEN DRIVE FOR SEVERAL DISTRO IN ONE TIME AND FEW CLIK! :-)
Good luck too,
see you
PEACE AND LOVE
This post's comments feed