Status of this page

  • As of 2008.12.18, this is a work-in-progress. The page is being built as quickly as possible. If you're reading this, it will still have significant missing information. This will soon have that remedied.
  • 2008.12.20: We're almost finished here!

Why do this?

It's about portability. Kubuntu-on-a-Flash-Drive (KFD) offers you your favorite operating system (which can be updated - manually, not via Adept), running out of a RAM disk. If you wish to set it up with the optional "persistence" feature, you can save your system settings, install programs, and save data files. This OS can access hard drives on the machine on which it's running, and also can access other USB flash drives and USB hard drives. You really can "take it with you", with this KFD!

Introduction

A Live Kubuntu flash drive ("FD") is bootable (if your computer's boot sequence checks USB devices before it checks hard drives). The Kubuntu it contains will run in your PC's main memory (RAM, in ramdisk) and will not change anything on your hard drive unless you specifically direct it to.

Such a flash drive is essentially the same as a Kubuntu Live CD, except...

  • It's easier to carry.
  • It uses only GRUB as boot loader (with the manually created version).
  • If you elect to use the "persistence" option, you can install programs on the FD, and save files of all sorts. You will also be able to save your program and system settings - something not possible with a mere "Live CD". When you return to the OS you will find it as you left it.

In addition, as with Kubuntu Live CD, you can "see" and access - in the Dolphin filesystem browser - other persistent memory devices attached to the computer you're using - other FD's, and hard drives, including USB hard drives (of course). "Access" here means USE the files on these devices - read and write them, using programs that are part of the Kubuntu Live operating system.

What you will need

  • A 1 GB flash drive - something bigger is better, especially if you plan on saving any of your work. Don't worry about what's on the drive when you obtain it. You're going to wipe it clean anyway.
  • Ten to twenty minutes - more if you create the drive manually and don't get it right the first time (easy to do) or are fundamentally new to much of this process. But it's worth it!

  • A computer the boot sequence of which is set, or may be set, to check USB devices before it checks any internal hard drives. Without this, you cannot test or use your FD.

Two ways to do it: [1] use software, or [2] do it manually

Manual creation of the Kubuntu FD is a detailed process, but not especially difficult, and you'll likely to learn a few useful things. Letting software do it for you is a significantly less flexible option, but highly likely to work the first time. One way to resolve this choice problem might be to use the software option first, then if you want more you can return to use the manual procedure. You risk little, either way.

Comparison of the two options

Here are some of the differences between the results of the two methods:

USB creator

manual creation

is fast and sure

takes more time (about 15 min. +/-), and relatively easy to mess up

Uses syslinux to boot

uses grub to boot

Uses vfat formatting

can use ext3 formatting

Persistent area of drive not visible in Dolphin*

User account and full persistent area visible in Dolphin*

Root access to filesystem requires password (which at the time of this writing is unknown!)

Root access to filesystem requires no password.

BOTH: Can make a "persistent" OS

BOTH: Can access (r/w) other devices in hardware configuration

*When your FD is viewed by the Dolphin filesystem browser launched from a normal Kubuntu OS.

First Steps

These steps must be accomplished regardless of which creation option you elect.

[1] Boot into your usual Kubuntu installation, where you will do this work.

[2] Download the Kubuntu Live CD: kubuntu-8.10-desktop-i386.iso is what this page is designed around, and will be used here. Make sure it is good: Burn the Live CD using K3b. Check the md5sum; run the CD, select “Check CD for defects,” then test run the Live CD. (An alternative: SEE "APPENDIX - Access your iso files without burning the CD", near the bottom of this page.)

[3] Acquire the partition-management program GParted - which should be in your favorite repository. This may be needed if you use USB-creator, and WILL be needed if you create your FD manually.

Option ONE: Use USB-creator

Install the usb-creator program. This works to create a Live, persistent or non-persistent Ubuntu (and variants) USB flash drive. The usb-creator program is available in the 8.10 repository, and is available for Kubuntu 8.04, too - visit https://launchpad.net/~evand/+archive

If you know you have an empty, never-used FD (not simply one that's empty), you can begin. Other wise, you must pay particular attention to preparation of your FD - it's absolutely critical. Review "Troubleshooting" below, before going any further.

Running usb-creator

Source disk image You can provide a burned CD, or specify an iso file. To do the latter, click Other and navigate to the file - for example, "kubuntu-8.10-desktop-i386.iso". Highlight the iso file you wish to use, and click the Open button at lower right.

USB disk to use

Plug a flash drive into your PC and see if it is detected by usb-creator. If not, leave the flash drive plugged in, Quit usb-creator, launch usb-creator again, and see if the flash drive is detected (it should be this time).

If there is not enough space on the flash drive, you will be informed. If the flash disk needs to be formatted, you will be given that option.

Persistence

If you want persistence, click the Stored circle. Then specify how much space by using the slider (in MB).

(Example: On my 2 GB flash drive, I gave it 750 MB. You might study how the program works and be able to increase that size to as much as (approximately) 1.25 GB (= 2 GB minus 750 MB for Kubuntu OS).)

Finally, click “Make Startup Disk” button at lower right.

It will take a while, perhaps 10 minutes on a 2 GB flash drive, and you will be informed of its progress, down to “Creating persistence file,” and “Making persistence filesystem.” Finally, you will be given a message “Installation is Complete. You may re-boot your PC to boot using the USB thumb drive.”

Testing persistence

You will see a message about the Syslinux booting. You will see a Kubuntu progress screen, and a KDE panel of icons loading. Then the screen MAY go blank for a long time (perhaps 2 minutes, plus or minus). Then Kubuntu Desktop shows up. You may find that after your initial trial of the FD, it boots significantly more quickly - as if some settings are getting saved.

You can test persistence by opening the text editor Kate and saving a test file. When you reboot, you should be able to open Kate again, click the "File >Open recent" menu item, and reload the file.

Troubleshooting

Your flash drive must not have a bootloader installed to the MBR! If you use a FD which is already bootable, it will have a bootloader installed in an area of the drive which is not accessible to a disk formatting program - the MBR, and this can cause complete failure of the drive creation process.

Syslinux (if you use USB-creator) or Grub (if you create the FD manually) will boot from the first sector of the first partition of the flash drive (= the boot sector of partition 1 = the first 512 bytes of partition 1). Your flash drive must not have another bootloader in its MBR (= sector 1 = the first 512 bytes of the flash drive preceding the first partition).

If it does have a bootloader in the MBR (or if you don't know), you have two options:

* Launch GParted, delete the partition(s) on the drive, create a new partition, then format the drive as FAT32. If you're going to create the drive manually, ext3 is fine. Creating the new partition after deleting all partition(s) seems to erase the MBR quite satisfactorily. * Zero out the MBR: sudo dd if=/dev/zero of=/dev/sdc bs=512 count=1, then create the FD by either method. (this is likely the quickest option)

Option TWO: Manual creation

Step 1: Find out what your flash drive is named

  • Plug in your flash drive to a USB port on your PC.
  • Open K > Applications > System > Terminal (Konsole)

  • Type these commands:
    • sudo fdisk -lu
    • sudo grub
    • grub> geometry (hd<Press the Tab key now>

  • Then you can do:
    • grub>geometry (hd0)

    • grub>geometry (hd1)

    • Etc. Study this output. In what follows, the flash drive is sdc = hd2. You may well be something else.

Step 2: Prepare the flash drive

Summary: Partition the drive, format it, set a boot flag, and set some labels.

The end result should be this:

  • Partition 1, for Kubuntu: sdc1, ext3, 750 MB, set boot flag, set label: Kubuntu810
  • Partition 2, for the “persistence partition,” sdc2, ext3, 1 GB, set label: casper-rw

Procedure - do this:

  • Launch GParted.
  • Access the dropdown menu on the toolbar to select the right device - your FD.
  • Highlight whatever partitions are already there, and delete them. (Why? See APPENDIX, near bottom of page.)
  • Create partition one: Use the "new" option on the mouse's right-click menu. Set:
    • free space preceding: 0
    • new size: 750
    • free space following: let program determine.
    • create as: Primary partition
    • filesystem: ext3
    • label: Kubuntu810 (assumes you will be putting the Kubuntu 8.10 OS on the drive)
  • Click ADD.
  • Create the next partition the same way, but with these values:
    • free space preceding: 0
    • new size: your choice, but usually you'll just accept what the program determines is the space remaining on the drive.
    • free space following: let program determine.
    • create as: Primary partition
    • filesystem: ext3
    • label: casper-rw
  • Click ADD.
  • Click APPLY on the toolbar, and let the program set up the partitions.
  • Exit GParted.

Note: the casper-rw label on partition 2 is critical. It's the label you need so your Live Kubuntu recognises the persistent partition as the one to use to save your data/settings/configurations. When you save data to your /home, it is saved in the casper-rw partition.

Step 3: Install GRUB files to kubuntu810 partition, and build the boot menu

CAUTION - This narrative uses sdc = hd2 for the flash drive here. Yours may be different!

(1) Build /boot/grub on partition 1 (= kubuntu810) of the flash drive

[a] open a file manager as root: Konsole, then type: kdesudo konqueror OR kdesudo dolphin.

[b] Create /boot in kubuntu810: In the file manager you opened as root, open the partition kubuntu810, create a new folder called boot (right-click in an open area, slect Create New Folder, and give it the name boot).

[c] Copy grub to your FD: In your file manager (still open as root), navigate to your regular Kubuntu OS /boot directory, open boot, right-click on the folder called grub, select Copy [to] (CAUTION: Use Copy; do NOT use Move!!!). Then browse to and select the partition kubuntu810 of the flash drive, then to the directory /boot (that you just created), and say OK (or at the lower right, Open or whatever it takes to make it happen). So, now you have set up /boot/grub on partition 1 (= kubuntu810) of the flash drive. (You may keep your file manager open.)

Note: We only need the grub directory and its files, so you can get it from anywhere (/grub contains stage_1, stage_1.5, and stage_2 files).

(2) Install (setup) GRUB to the MBR of the flash drive

Open Konsole, type sudo grub. At the GRUB prompt type these commands:

  • grub> root (hd2,0) # CAUTION: Use YOUR device name instead of hd2!!!

  • grub> setup (hd2) # CAUTION: Use YOUR device name instead of hd2!!!

  • grub> quit

The "setup" command should produce output that looks something like:

 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd2)"...  16 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd2) (hd2)1+16 p (hd2,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

This sets up GRUB in the MBR of the flash drive using the GRUB files in partition 1 of the flash drive.

(3) Build the boot menu, /boot/grub/menu.lst

With your file manager open as root, open /boot/grub/menu.lst. Delete everything in menu.lst; type or copy exactly the following into your menu.lst:

# Kubuntu 8.10 Live Flash Drive GRUB boot menu.
# Includes Persistent option, and other Live options, including Install.
#
timeout = 5    # you can make it any number of seconds
default = 0     # Makes the Persistent option the default OS to boot

title  Kubuntu 8.10 LIVE Persistent
root (hd0,0)
kernel /casper/vmlinuz  boot=casper  ramdisk_size=1048576  root=/dev/ram  rw quiet splash persistent
initrd /casper/initrd.gz

title    Kubuntu 8.10 LIVE -- Start or Install
root (hd0,0)
kernel /casper/vmlinuz  boot=casper  ramdisk_size=1048576 root=/dev/ram  rw quiet splash
initrd /casper/initrd.gz

title Safe Graphics mode -- xforcevesa
root (hd0,0)
kernel /casper/vmlinuz  boot=casper  xforcevesa ramdisk_size=1048576 root=/dev/ram  rw
initrd /casper/initrd.gz

title   Install with driver update CD -- driver updates
root (hd0,0)
kernel /casper/vmlinuz boot=casper ramdisk_size=1048576 root=/dev/ram  rw  debian-installer/driver-update=true quiet splash --
initrd  /casper/initrd.gz

title   OEM install (for manufacturers)
root (hd0,0)
kernel /casper/vmlinuz boot=casper ramdisk_size=1048576 root=/dev/ram  rw  oem-config/enable=true quiet splash --
initrd  /casper/initrd.gz

title   Check CD for defects
root (hd0,0)
kernel /casper/vmlinuz boot=casper integrity-check quiet splash --
initrd  /casper/initrd.gz

title   Memtest
root (hd0,0)
kernel /install/mt86plus

title   Re-boot the PC
reboot

Finish with File > Save, File > Quit. You may keep your file manager open.

BOOT OPTIONS - As you can see from the menu.lst listing, when using this flash drive you have the option of running it without the persistent capability. That is, you can run it as a straight Live Kubuntu 8.10 OS and it will not save anything to casper-rw. You can use it that way to install Kubuntu 8.10 to an internal/external hard drive or to another USB flash drive, or ....

Cloning your flash drive: Another option is simply to clone your flash drive--see the brief how-to in Appendix at bottom of this page.

Step 4: Copy the Live Kubuntu files from the CD to the first partition (kubuntu810) of the flash drive

IMPORTANT: You can do this step with either your GUI filesystem browser or with the CLI. If you use GUI, make sure you see and copy the HIDDEN FILES! In your file browser, select: View > Show Hidden Files on the main menu.

Filesystem browser instructions: To copy the CD files to partition 1 (= kubuntu810) of the flash drive: Insert your Kubuntu Live CD into the PC, wait for it to be recognised. With your file manager open as root, navigate to the CD, open it to see the folders and files on the CD, click View > Show hidden files, Edit > Select All, Edit > Copy [to], browse and navigate to the flash drive partition kubuntu810, highlight the partition kubuntu810, and accept that choice (by pressing at the lower right OK or Open or whatever it takes to make it happen).

CLI instructions: See how-to in Appendix at the end of this page on extracting files from an .iso. Attend to the first part of the procedure - just to get access to the ISO files.

Step 5: You're done!

[unfinished]

Testing persistence

[unfinished]

What to expect

[unfinished]

Troubleshooting Tips

The following tips come from the experience of a limited number of people. Your experience may be different, but these tips may give you some ideas about how to work your way out of problems you run into. If all else fails, bring your problem to the Kubuntu Forum, Intrepid Ibix "Installation and Boot" subsection, where much of the material here originated.

[unfinished]

APPENDIX

Access your iso files without burning the CD

This time-saving option is relevant only if you chose the manual creation option. USB-creator can use either the iso file you download, or the disk you create by burning the file to a CD.

Download the iso file to the Desktop. (If it's a tar.gz file or similar, you get the iso by right-click, Extract Here, or by using ARK ( find it in K menu > Applications > Utilities > Archiving Tool (ARK)). Let's say the file name is kubuntu-8.10-desktop-i386.iso and it's on your Desktop, and your user account is "mike": /home/mike/Desktop/ kubuntu-8.10-desktop-i386.iso.

  • GET ACCESS TO THE ISO
    • Make a directory /mnt/test for your mount point: sudo mkdir /mnt/test
    • Mount the iso: sudo mount -t iso9660 -o loop /home/mike/Desktop/kubuntu-8.10-desktop-i386.iso /mnt/test
    • You can also change directories (cd /mnt/test) and list (ls) the files to see what's there. (In a GUI filebrowser, just refresh the file listing - press F5, usually - to see the files. If you're going to copy the files to your FD at this point, be sure to select the View Hidden Files option in your GUI file browser first!!!)
  • COPYING THE GRUB FILES
    • Next, copy the GRUB files /boot/grub to a folder that will be created and called new_grub, say under /tmp: cp -R /mnt/test/boot/grub/ /tmp/new_grub
    • Now change the ownership so mike can have these files and then unmount it: hown -R mike:mike /tmp/new_grub
    • Unmount /test: sudo umount /mnt/test
    • If you have to invoke root, use sudo (as I have above, when it was necessary).
    • Open your file manager and go to /tmp/new_grub, where you can see /new_grub and its files.
    • Experts may want to copy /grub directly into /media/kubuntu810.

Cloning your bootable flash drive

This procedure allows you to cloning a (bootable) Kubuntu 8.10 Live persistent USB flash drive. Caution - Use YOUR own device names; sdc & sdd are used for example only.

Source drive: sdc - 2 GB flash drive, ext3, (GRUB-bootable) Live Persistent Kubuntu 8.10. Two ext3 partitions: sdc1 = kubuntu810, sdc2 = casper-rw (the persistent partition)

Target drive: sdd - 2 GB flash drive, FAT32, empty.

Do this:

dd if=/dev/sdc of=/dev/sdd bs=4096 conv=notrunc,noerror

Expect output something like this:

492671+1 records in
492671+1 records out
2017984000 bytes (2.0 GB) copied, 425.104 seconds, 4.7 MB/s

The dd copies everything--including GRUB bootloader, MBR, the two source partitions, and the ext3 formatted filesystems. Your clone is ready to boot.

(For more on this, see the Reference below: dd Command)

Updating your Kubuntu Flash Drive (KFD)

This procedure is for use with the manually created, GRUB-only version of the KFD, and assumes you'll be using an iso file. To use a Live CD, just mount it and skip to the file copy step.

  • MOUNT THE ISO: As detailed in the "Access your iso files..." section above in this appendix, you need to mount your iso download disk image.
  • MOUNT YOUR FD; GET ACCESS TO BOTH FILESYSTEMS: Insert your Kubuntu FD also. Launch an administrator account file browser (e.g., sudo dolphin). Split the display, so you can see your /mnt/test directory, holding the iso image, on the left, and your kubuntu810 FD partition on the right.

  • You can either save a copy of the menu.lst file in the "ubuntu/boot/grub" dir, or recreate it, as detailed in the manual process above. You can save your copy into the root of kubuntu810 easily enough.
  • After that, delete all files in kubuntu810's root, and all directories and their contents. Then copy the iso to the FD, as you did before.
  • Finally, restore the /boot/grub/menu.lst file, either from the copy in root or y the process detailed above.
  • Repeat the Manual option, Step 3 (2) above - "Install (setup) GRUB to the MBR of the flash drive"
  • Test your work - you should be able to boot this FD up and get to your saved files.
  • Problems: you may need to delete your user account settings to get the FD to work.

[unfinished]

References and Sources

Kubuntu on a Flash Drive

This wiki page is a reduction-to-essentials of the following sources. Two of them are forum threads, and as such meander a bit. But, the contributors to those threads are the real authors of this page. They have done a fine service!

HowTo: Install Feisty on a bootable USB Flash drive - this is the fundamental source.

http://kubuntuforums.net/forums/index.php?topic=3089474.msg161112#msg161112 - this is Reply #54 to Build a LIVE Kubuntu Flash Drive, How-To. The basic procedure is derived from the "Install Feisty..." thread referenced above, with essential modifications. The result is easier, most certainly, and adapted to current releases. Please note that this is the core reference used here, and is quoted whenever possible (but without attribution other than here). Note especially replies #7, #17, #18 to this "Build a LIVE Kubuntu..." thread.

How To Make GRUB Thumb Drive

How To GRUB Methods - Toolkit

dd Command (see Reply #1 for cloning & other applications)

Tuxfiles (permissions, ownership, commands, file and folders, Linux file system, mounting, and more)

Commands at Konsole: Beginners (permissions/ownership for flash drives: see Reply #1)

GParted

GParted

GParted how-to

Other stuff

PuttingKubuntuOnAFlashDrive (last edited 2008-12-21 04:35:40 by c-24-17-182-26)