Can I copy my Ubuntu OS off my hard drive to a USB stick and boot from that stick with all my programs?

18,425

Solution 1

I've been doing this for years. I'm writing now from a PC which does not even contain an internal hard drive. I don't even carry a laptop, just this high performance USB flash media.

I will now outline the two components you need to buy if you want decent performance. Most flash drives are too slow for most people, and they can also become unstable due to overuse of the type they get running operating systems and particularly swapspace.

I use this USB3 to mSATA SSD flash media adapter, priced here at US$19.

And inside it, I use an mSATA SSD drive originally made for today's tablet and netbook computers. Though I manage to get by on just 64 GB myself, you may choose to buy something with greater capacity. Last I checked, the capacity of these drives was up to around 1 TB. I remember when the largest available was just 32 GB.

If you would like something still more rugged, I can recommend this similar USB3-mSATA adapter which is made from a solid section of extruded aluminum. It is almost exactly the same price. Whereas the model I previously recommended is only 2/3 the thickness, it would probably cave if stepped on. This one might tolerate a car driving over it.

To the best of my knowledge, nobody has made a waterproof model yet, but it's only a matter of time. The strange thing is that as obvious as these appear as portable operating system environments, apparently all references to these regard their use entirely for portable data.

One last detail. It is my practice to keep a 128 GB common slow flash drive in one of the more regularly used computers and have the portable drive automatically back up critical data to it when it is used there. The automatic backup software I'm using is that which is included with Ubuntu and it encrypts its backups. This way whether I lose the boot drive, or my home is robbed, the odds of actually losing all my current personal data are incredibly low.

Solution 2

This should be possible; your flash drive just needs to have enough memory for the OS and whatever files you'll be using. The limitations are based on the flash drive and/or the computer you run it (but most likely the read/write speed of the flash drive will have a larger impact on speed).

The stick is used as memory similar to any other harddrive in a laptop or desktop computer. You could probably boot from one flash drive with Ubuntu flashed onto it and select your other flash drive as the destination hard disk drive for the OS.

I'm no expert in this, but it should be do-able, just slow.

Solution 3

Yes, this is completely possible. First and foremost, you will need at least 2 USB ports available, or 1 USB port and 1 CD-Drive.

You start by booting into a Live-CD version of Ubuntu with your hard-drive where it is and the target device plugged into USB. Mount your internal drive and target USB to any paths you like.

Open up a terminal and enter the following commands:

tar cp --xattrs /path/to/internal | tar x /path/to/target/usb

You can also look into doing this through a live installation and a utility called CloneZilla, but I am unsure of exactly how to use CloneZilla. The above method is what I used to copy my 128GB hard-drive's installation of Ubuntu to a 64GB flash drive.

Solution 4

I'm adding ANOTHER ANSWER to answer your OTHER QUESTION, which you added to your first question after I offered my original answer, chosen above:

you wrote:

Update: Thanks so much for the thoughtful responses! At this point, I'm wondering how I should go about keeping my system backed up to a bootable external drive.

What you are asking can be answered different ways depending on what you are trying to do. I can think of four possible ways, I will explain in outline format below:

1) Synchronize data-only across two bootable drives:

This seems to be what you want to do, but I believe you will run into a problem which will impede data security. I will explain.

It seems to me that you seek to SYNCHRONIZE data files between two (or more) bootable operating systems. Though I've never actually done this, I know that it is only a google-search away, and very likely explained on this site. However for that to work, you'd almost have to turn encryption off, or rather, never turn encryption on. In my opinion, if you are going to have portable bootable external drive, they should always have data encryption turned on, so unless you discover a drive synchronize that can also accept password data, or unless you decide to travel without data encryption, this is not a viable solution.

2) Clone again the internal or external drive in its entirety to another drive:

Use the "Clonezilla" utility, mentioned in the very last paragraph of my original answer, to clone the original internal drive to another external drive to make two such external bootable drives to keep track of.

3) Use the backup utility included with Ubuntu with your external bootable drive:

This is what I do. I boot (nearly) ALL MY COMPUTERS to a single external drive which travels with me, and when I am home, the 128gb slow usb flash drive, which remains plugged in my home computer, makes incremental backups of changed files on the traveling boot drive.

In your case, I would recommend that in the interest of data security, that you physically remove your internal hard drive and leave it at home. It will frustrate the heck out of anyone who steals your laptop, in fact if they get to try it before they steal it, they might even decide it is broken and leave it alone. If the thought of having only one bootable external drive frightens you, bring two and mark the spare clearly as such so it is never used unless the first one is lost or destroyed. As long as you create the backup drive on the first external drive before cloning it to make a second external drive the incremental backup drive will continue to work with the spare bootable drive.

4) Use the backup utility included with Ubuntu in the traditional method:

Use the backup utility to backup just the data from the internal drive to an ENCRYPTED data-only external drive. You can configure it to make "incremental" backups of any changed files on your internal hard drive to the external, non bootable, SSD.

Solution 5

Yes you can copy a full Ubuntu OS (with Programs, customizations and all ) from your Desktop or Laptop Hard drive to an external USB Flash Drive or external Hard drive. I just did it for Ubuntu 14.04 LTS to an external Hard drive (but equally applicable to USB Flash drive as well) Required software / hardware:

1 Destination External Hard Drive / Destination USB Flash Drive to have the cloned OS

1 Source OS (Ubuntu or any other OS that needs to be cloned)

1 USB Drive (with at least with as much capacity (256 MB - 1 GB) as a clonezilla live USB requires)

1 computer / laptop having Windows which can run Live Linux USB creator

Steps:

  1. Download Clonezilla from http://clonezilla.org/downloads/download.php?branch=stable (download the ISO)

  2. Download Live Linux USB Creator (Lili) from http://www.linuxliveusb.com/en/download

  3. Create a bootable Clonezilla (Live Clonezilla) on USB by running Live Linux USB Creator.

  4. Configure your Source desktop / laptop to boot from a USB drive

  5. Insert both, the destination external hard drive or destination USB Flash drive in 1 USB Slot and the Clonezilla Live USB drive in other slot and boot.

  6. Clonezilla will take some time to read partition info When the Clonezilla UI appears, select default menu entries.

  7. [With Caution] select Source Partition info and Destination partition info It may be noted that Clonezilla would require space on destination USB Flash drive or external hard disk which is equivalent of the source Hard disk and it will erase all data from the destination USB Flash drive / external hard drive.

  8. Once all is selected, Clonezilla will create a live OS on the destination drive / flash drive

  9. Test the cloned OS by removing Clonezilla Live USB drive and booting from the Live OS which has been cloned onto the destination External drive / USB Flash drive.

Enjoy !

Share:
18,425

Related videos on Youtube

Josh
Author by

Josh

Learned how to code when I tried to start an online business after college. The business failed basically instantaneously, but I found a love for code that's lasted and come to impact the way I think about entrepreneurship and many other things in life. More about me here: general bio I was in the 2014 summer batch at Hacker School, now The Recurse Center, which was incredible! I had never met any other developers before, I didn't know how to pronounce gif (I still don't)... not to mention, it's an incredible community for developers. These days I work mostly with scientists, NASA, the National Science Foundation, etc, by designing and facilitating 5-day innovative research conferences. Tons of fun : ) Check out Knowinnovation for more. Looking forward to Q&A'ing with everyone here.

Updated on September 18, 2022

Comments

  • Josh
    Josh over 1 year

    I'll be travelling and I hope to back up my laptop in case it gets stolen. I wonder if I can make my backup a bootable USB flash drive, that way I could just have my system as-is on stick and use it on any computer.

    Is this possible? What are the limitations? (only 64-bit systems? No way to keep it up to date?, etc...)

    Update: Thanks so much for the thoughtful responses! At this point, I'm wondering how I should go about keeping my system backed up to a bootable external drive.

    • deviantfan
      deviantfan over 9 years
      Because no answer addresses this: Beside size and speed, there are no hard limitations. 32/64bit work both, and keeping it up to date is no problem. Make some partitions, transfer the files with rsync and restore grub, that´s all. Only possible problem: Flash drives wear out after some time. A cheap one could get unusable within the expected lifetime if you use it much.
    • Iluvathar
      Iluvathar over 9 years
      @deviantfan that one must be extremely cheap. USB 2.0 is way too slow to make the flash wear out in any interesting time.
    • deviantfan
      deviantfan over 9 years
      @Ruslan I agree, but production "errors" happen... at least knowing about the possibilty won´t hurt.
    • Xen2050
      Xen2050 over 9 years
      +1 deviantfan. I tried installing Mint to a usb drive (not a super-cheap no-name one either, a Lexar) and it just couldn't do it, crashed a few times, corrupted filesystem, very very slow, terrible. Not sure if it was some combination of usb ports & devices, it didn't wear out the drive (no errors afterwareds) but when using the usb drive normally it was & still is flawless. I would recommend using a usb drive to run live iso's from, along with a copy of your $HOME and a few .deb programs you need, that's practically your whole system ready to run "live" but effectively read-only
  • Admin
    Admin over 9 years
    This isn't really an answer here. Yes, it answers the base question of "is it possible", but it does not offer any solution as to HOW it is possible.
  • Xen2050
    Xen2050 over 9 years
    OP didn't ask how... maybe he already knows. Question answered +1
  • Xen2050
    Xen2050 over 9 years
    You know, you can use the toram boot option when booting live, then you don't need to keep the iso cd/dvd/usb connected (if you have enough ram, >1.5GB or so
  • Peter Cordes
    Peter Cordes over 9 years
    Huh, /dev/sda is actually where you have your internal drive mounted, right? Not the device file. Ditto for /dev/sdc. You don't need to boot from USB to do this. You could just do it while your Ubuntu desktop is up and running from the hard drive you're going to use as the source for the copy. I'd use rsync -aHAXx to do the copy, as that preserves hardlinks. I forget if tar does or not. rsync -x limits to one filesystem, so you don't copy /proc, /sys, and all that crap from your running system. Booting from a live cd/usb is a workaround for --one-file-system.
  • Peter Cordes
    Peter Cordes over 9 years
    IDK if modern Ubuntu has anything in any of the directories that are shadowed when udev is mounted on /dev, for example. Probably not, since initrd and pivot_root is completely standard now, so a populated /dev existing for the boot scripts isn't needed.
  • Peter Cordes
    Peter Cordes over 9 years
    You'd probably want to have syslinux on the flash drive, but maybe have it load GRUB, instead of a kernel directly? Once you have a setup that loads a kernel + initrd, with root=LABEL, and that the kernel can find the root FS with that label, GNU/Linux should Just Work.
  • Xen2050
    Xen2050 over 9 years
    Right @PeterCordes , I didn't look too close earlier, but pipeing tar to tar, with raw devices, no even a partition, just to copy... somethin' wrong there
  • Peter Cordes
    Peter Cordes over 9 years
    The first tar command will run as typed, but it will output a tar file that just has one block-device special file. (not the contents, just the device-file.) In extract mode, tar's arguments are the list of files to extract from the archive.
  • gyropyge
    gyropyge over 9 years
    PS: Perhaps I should have mentioned that my operating system cloner of choice is actually clonezilla run either from flash media or a cdrom. I am very familiar with dd and for a very long time I used it just because it meant less stuff to carry, but it has risks. In the end I find clonezilla less stressful.
  • gyropyge
    gyropyge over 9 years
    Re-reading your post now. Yes, if your clone is 64 bit then that will limit your travel options. My portable is 32 bit for this reason. I like flexibility. Also post pae (?) versions are less limited by the 32 bit condition so I'm not missing out on as much. when using a host of different computers, you have no control over how much ram they have, and as 32 but ubuntu is more ram efficient, that works better for me.
  • gyropyge
    gyropyge over 9 years
    Oh, and for some reason you asked, "No way to keep it up to date?" I have no idea why you would assume or ask that. Updating an external drive is exactly like updating an internal drive. If you have internet connectivity, you just update. You just treat it as though it is your own drive... because it is.
  • Admin
    Admin over 9 years
    You guys were right, the "/dev/sda" was not the best way to go around this. Been a couple of years since I did this. I fixed my answer to explain that you should first mount and then use the mounted paths instead of device files.
  • gyropyge
    gyropyge over 9 years
    I see now that my original answer has lost its chosen status in favor of this one, even though this is not the answer to the original question. I would proposed that the second question should have been posted as a separate question with a pointer to this question, and I could have posted my second answer to the new question.
  • Josh
    Josh over 9 years
    That probably makes the most sense.
  • Josh
    Josh over 9 years
    You are incredibly thorough, sir. Thanks so much!
  • gyropyge
    gyropyge over 9 years
    I've been building and repairing PCs since the late 1980s. I've built several pcs which entirely depended on external scsi hard drives, external parallel port hard drives, and in recent years, entirely on USB external SSD drives such as I've described in these answers. At first these SSD booted computers contained hard drives which in some cases contained windows, but I began to physically disable those drives out of fear for boot sector viruses. In recent years I've been building driveless desktops at cost (no profit) for my valued friends, and may I add, they are "selling" like hotcakes.
  • Josh
    Josh over 9 years
    That's really awesome! It sounds like a great idea. These are essentially terminals. Imagine if it were common for people to carry their OS around in their pocket...
  • gyropyge
    gyropyge over 9 years
    @Costa, it is becoming common, at least among my friends. I've made over 40 clones of a particularly well equipped "mubuntstick" intended for small scale distribution personal friends. You can read a little more about it on my bio page. There is not yet a web page about the project, but you might be able to persuade me to send you a pdf file of the user manual complete with hotlinked index. There is a separate document on each stick which explains how to boot it. A printed is included. When you consider that bootable pen drives are hardly new, and nearly all of my friends have one...
  • Josh
    Josh over 9 years
    Sounds like a worthy project, sir. I wish you the best! Will post back here if I implement this.