How to install Debian onto a flashdrive

21,974

Solution 1

You can use a tool called Linux Live USB Creator (this is to create the USB from Windows). It will create a live USB and will let you specify a space for permanent data that will be kept from run to run. This is called the Persistence File.

Or you can create a the whole system in your USB. The way I did that was installing Debian on a machine (I think you can't install directly to a USB if you can then that is the way to go, otherwise keep reading).

Crate the needed partitions on your USB Stick (for / and swap or whatever you need). Start your machine from a live usb/CD and rsync -arv your Debian HD install in your USB.

Once you have done that, start the machine from your HD, mount your USB and mount --bind /dev, /dev/pts, /proc and /sys to those in your usb, then chroot to your USB and grub-install to your USB's /dev/sdX device (being X the letter a, b, c, etc... which is the one where your USB is).

You're almost done now, just run blkid to identify your USB's root/swap/whatever partition ids you created and modify /etc/fstab so that your root/swap/whaever partitions point to the ids in your USB. After that, you only need to change your /boot/grub/grub.conf so that the id also points to the one in your USB, but be aware that this will be modified if you update your system so either find what you need to change in your /etc/defaults/grub or wherever that configuration is and modify it to make it permanent.

Now you're ready, take the USB wherever you want, start the system from the USB and your Debian system will start.

Solution 2

I have installed debian 8 (jessie) onto a usb drive. Here's the trick: use the installation media (cd, dvd, thumbdrive, whatever) to start your 'debian install.' Go through it like normal until you get to the 'partition disks' screen.

THEN, insert your thumb drive (that you want debian installed to) in the machine, choose 'go back' a step in the installer, then 'partition disks' again. Inserting the thumbdrive late in the installation process like this will make the thumbdrive available to the installer.

Debian installer will again scan for disks at this point and recognize the thumbdrive as unmounted, which is what we want. Make partition(s), tell the installer to install the OS on the one of the partitions you made on the thumbdrive, in my case it was /dev/sdb2.

Note: while this setup may sound good in theory, the read/write speed of a flash drive is slow compared to a normal hard drive, and as such the speed of the debian system will be sometimes crippled, but otherwise completely usable.

Untested advice: I made a swap partition as well a / filesystem partition on my thumbrive, and have even more performance issues (speed) I attribute to this. I think I should have went without a swap file, the laptop already has a Gig of ram and that ought to be enough by itself.

The good news is, just as planned, I can move this thumbdrive between computers and boot up my maintained operating system. It's "portable."

Share:
21,974

Related videos on Youtube

Amateur Programer
Author by

Amateur Programer

Updated on September 18, 2022

Comments

  • Amateur Programer
    Amateur Programer over 1 year

    I actually want my 4GB flash-drive to be the OS and for it to be transfer in-between any machine.

    1. I have tried to follow Debian's website, and I couldn't figure it out.
    2. I had my friend make my flash-drive into an actual installer, and now it won't install on any other computer. For some reason it was just one time use.

    So if any one knows how to make my flash-drive into an OS, that would be very useful to me.

    • eyoung100
      eyoung100 over 9 years
      If you want a live USB Disk, you need to follow YoMismo's Answer. If you want your USB to behave like a Hard Disk, follow kashminder's answer.
  • Amateur Programer
    Amateur Programer over 9 years
    The flash drive does not have the files needed to become the OS