Posts Tagged 'XubuntUSB'

Ubuntu from your flash drive – easier than ever before

As you have probably noticed, new versions have arrived of Ubuntu, Xubuntu and other derivatives. One of the most exciting new features has received far less publicity than it deserves – the ability to “install” it onto your USB flash drive with just a few clicks.

The advantages are obvious: just plug your flash drive into a computer and run your favourite operating system. What’s more, everything you do — installing applications, saving documents, editing preferences — will be saved to your flash drive and will be available to you every time you run it!

The best news is that it’s astoundingly easy: all it takes is a few clicks.

Of course, there are a few requirements. First, you can only run it on computers that support booting from a USB flash drive – this is the case for most computers nowadays. Secondly, you must have a CD or a CD image. The latter can be downloaded free of charge – I, obviously, downloaded Xubuntu. Third, you’ll need to install usb-creator, the new application that is readily available in version 8.10 but which you can also download and install on version 8.04 (with Windows and Qt versions planned). And, last but not least, you’ll obviously need to have a USB flash drive.

Once installed, you can find it in your menu as Create a USB startup disk (on Xubuntu it is located under Applications->System, in Ubuntu this would be System->Administration, IIRC).



The first thing you’ll need to do is to insert the flash drive you’re planning to use. Usb-creator will then detect the drive – if multiple flash drives are inserted, you can pick from a list which one you want to use, and if the drive isn’t formatted yet usb-creator will give you the option to do so (note that this will destroy all files on it!).

The next step is inserting the appropriate CD into your CD drive, or loading the CD image you downloaded before by clicking Other….



Finally, you’ll need to configure whether you want all your documents, settings and applications to be discarded on shutdown (i.e. act as a regular LiveCD) or if you want to save them to your flash drive (this is called persistency, or persistent mode). If you pick the latter, you’ll also be able to select how much space you want to reserve for this.

Do note that usb-creator will not overwrite existing files on the drive – thus, if you want to use your entire drive, you’ll first have to delete all existing files.

Now, with everything configured, click Make Startup Disk, and sit back and relax while usb-creator prepares your flash drive.



You can do something entirely different now, like reading the rest of this blog, viewing all my screenshots of usb-creator, whatever you like. Once usb-creator is finished, it will notify you that it’s done. All that’s left now is to boot your computer from your flash drive and have fun 🙂



Troubleshooting

If persistency does not work, you might need to edit the file text.cfg in the syslinux folder on your flash drive. Just replace the line default livewith the following lines, adding a new Start Xubuntu option to the boot screen the next time you boot. Note that you might want to replace occurences of “Xubuntu” with the name of the distro you’re using. This has been tested with Xubuntu 8.10;

default persistent
label persistent
menu label ^Start Xubuntu
kernel /casper/vmlinuz
append file=/cdrom/preseed/xubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash persistent
--

Xubuntu Feisty – now from USB drive!

IMPORTANT NOTE: Unless for some specific reason you want to run Xubuntu version 7.04 specifically from your USB Drive, this tutorial is deprecated. I’ve written an updated and much easier tutorial on how to run the latest version of Xubuntu from your USB flash drive.

In my previous post I showed you how you can run Ubuntu Feisty Fawn from your USB drive, and have it preserve any changes you make. In this post, I’ll show you how to do it with Xubuntu. And of course, as usual, you can also view the screenshots as a slideshow.

Using Xubuntu has a few advantages. The first one is that it is more appropriate for this blog (hence the name Xubuntu blog 😉 ), and that I like it better. The second one is that it is faster than Ubuntu, which is quite handy seeing that running it from a USB drive (or flashdrive, pendrive, memory stick, or whatever you’d like to call it) does bring about a speed decrease. The third advantage is that it takes up considerably less space on your USB drive. About 70 MB matters quite a lot, especially if you’re using a 1GB drive (which is the minimum).

But I hear you thinking: didn’t Ubuntu 6.06 “Dapper Drake” already introduce the possibility of such a “persistent liveUSB session”? Why do we need a specific tutorial for Feisty?
OK, perhaps you didn’t think that. But you would be correct if you were: it is already possible since Dapper. However, some packages in Feisty introduced this bug which prevented this feature from working. To work around this bug, we will use some packages from the previous version, 6.10 “Edgy Eft”, which do not suffer from this bug and which most likely won’t cause you additional problems.

Before we start, I’d first like to thank everyone who has worked and is still working on fixing this bug (more details on the bug page and the forum thread) and especially Mike (mjpca) for providing this teporary workaround. His writeup of the steps he took allowed me to do the same for Xubuntu, also using this great guide from “bibe’s” site. And last but not least, this guide would not have been possible without the detailed How-to from Debuntu on how to install Ubuntu on a USB pendrive.

First off, be sure to realize that this will wipe all existing data on your USB drive. Furthermore, these instructions are geared towards Xubuntu, but they’ll also work on other Linux distributions if you change the instructions a bit (e.g. perhaps you use another program for partitioning). It might also work on Windows (I know “syslinux” is available for Windows) but then the instructions will probably differ a lot so it’s your own responsibility.
You need a USB drive of at least 1GB but as that only leaves about 240MB for any additional programs you’d want to install or documents you want to save, I recommend you to use a USB drive of 2GB or more.

The process of putting Xubuntu on your USB drive is not that difficult. Basically we need to divide your USB drive in several regions (partitioning), one of which will hold the modified Xubuntu and one which will hold all your documents and settings. However, because this will take a while, I suggest you already start downloading the modified Xubuntu image generously hosted by pepeio (I have also created a XubuntUSB torrent, hosted on LinuxTracker. If you know how to, please use that torrent.).

As your partitions need to stay unmounted, I recommend you to turn of “Volume Management” (you can turn it on again after you have finished this tutorial). To do so, open Thunar, click Edit->Preferences, then switch to the “Advanced” tab and make sure “Enable Volume Management” is unchecked.

Then, fire up Gparted (Applications->System->GNOME Partition Editor) and, from the drop-down menu in the top right corner, select your USB drive. Be sure to select the correct one, because if you select your hard drive we will remove all data on that and I suppose you won’t like that. Note down the drive (e.g. mine was /dev/sda) because you will need it later. Delete all partitions on your USB drive if there are any, then click the checkmark to apply. After that, the screen should look like this, without any partitions:
Setting up XubuntUSB - no partitions on my USB drive

Right click the “unallocated” space and select “New” to create a new partition, the one that will hold the modified Xubuntu. Set it to be 760 MB (Gparted calls it MiB) and set the filesystem to “FAT16”.
Setting up XubuntUSB - setting the first partition

Then create the second partition, which can take up all the remaining space. Set the filesystem of this one to “ext2”.

Setting up XubuntUSB - setting the second partition

Now, click the checkmark or select Edit->Apply to apply your changes.

Then, open a terminal window (Applications->Accessories->Terminal). In the following command, replace the “/dev/sdx” with your drive (ine was “/dev/sda”, so that would become “/dev/sda1”). If you want, you can change “xubuntusb”, which will be the label for this partition. Enter this command and press enter:
sudo mkfs.vfat -F 16 -n xubuntusb /dev/sdx1
Again, in the following command, change “/dev/sdx” with your drive. This time, however, you may not change the label “casper-rw”, as it will be used to determine where to save changes to. Enter this command and press enter:
sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdx2

Setting up XubuntUSB - creating the filesystem of the second partition

Now, make sure you have unmounted both partitions (in Thunar, right click them and select “unmount”), then unplug your USB drive. You can then plug it back in and you should see that it will appear with the new labels in Thunar. If the modified Xubuntu has finished downloading, extract it and copy all the files to the “Xubuntusb” drive. You might get complaints about symbolic links that could not be created, but that is no problem, just select “Yes to all”:
Setting up XubuntUSB - sfailed to create symbolic links, no problem

Copying of the files should take a while (especially the file “filesystem.squashfs”), but when it’s done, there is just one final step you have to do: make sure your computer can boot from the device. In order to do this, you need “syslinux” and “mtools”, so fire up Synaptic (Applications->System->Synaptic Package Manager), mark those for installation and click apply. When they are installed, first unmount both your partitions, then open a terminal window (Applications->Accessories->Terminal) and execute
sudo syslinux -f /dev/sdx1

Setting up XubuntUSB - now allow it to be booted, and we're done!

If everything went allright, you should now be able to run XubuntUSB, congratulations! If it didn’t work for you, see “Troubleshooting” below, if it did, please leave a notice in the comments. Thanks!

Note: If you want to create a new user, be sure to grant administrator rights, otherwise it may cause errors.

Another note: For those who don’t like the amount of files on their USB drive, Fisslefink posted a great how-to which guides you to using GRUB instead of Syslinux, so that only two folders will be used. It didn’t work for me, but since he also includes instructions on how to revert back to Syslinux, there is no harm in trying.

Troubleshooting

If you experience any troubles, please first check if your problem is in the following list, and if not, please ask for help in the forum thread.

  • If, upon boot, you get the message no partition active, you have to set it active for boot. Open up a Terminal (Applications->Accessories->Terminal) and type sudo fdisk /dev/sdx (you know, replace sdx with your drive). Press “a” and then “1”. Press “w” to save and then it should work!
  • You might think it is weird that your casper-rw drive shows up on your desktop, and actually, it shouldn’t, but everything still worked as it should with me, so it should not be a problem. Note that you cannot browse it, though.
  • Toad mentions that he could not boot from his USB drive with this tutorial for Ubuntu, but he fixed it:

    I finally got the computer to boot from the USB stick. I had to set the fat16 partition to bootable. ‘cfdisk /dev/sdx’ should do the trick, just press enter on the set bootable option.

  • If this worked, but after a while it doesn’t anymore, you can remove any edits you did to restore it to the point where it worked (all your settings will be lost though):
    sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdx2
    (Thank zenobiaflex for this one)
  • If your drive won’t boot correctly, your Master Boot Record may be corrupted. You can repair it with Lilo (so open up Synaptic from Applications->System->Synaptic Package Manager and install the package lilo) using the following command from the terminal:
    sudo lilo -M /dev/sdx
    (From PiterP)
  • If, during shutdown, the screen switches from the shutdown screen with the Xubuntu logo with the progress bar to a black screen, possibly with error messages, then you computer is probably just shutting down the normal way without notifying you of its status. At a certain moment (not too long after the screen turned black) it will have reached the point where it would have normally said something like “remove the disk, close the tray (if any) and press enter”. So when the screen turns black, you just have to try to press enter a little while after it has turned black.

a