LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-18-2015, 10:12 PM   #1
p3aul
Member
 
Registered: Jul 2011
Distribution: Ubuntu 10.04
Posts: 116

Rep: Reputation: Disabled
Smile Installing Linux on a USB drive


I'd like to install linux on a 32GB USB drive and use the space left over to install apps. Can this be done?
 
Old 01-18-2015, 10:40 PM   #2
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Rep: Reputation: 156Reputation: 156
Firstly you will need an ISO of your chosen distro.

If you are comfortable with the command line then try something like this to

Quote:
sudo dd if=/dev/sdb of=/home/user/image.iso bs=4M
where /dev/sdb is your USB drive and image.iso is the ISO file you downloaded

Fedora provides their live USB creator:

https://fedorahosted.org/liveusb-creator/

I think this can run from anywhere. Not sure whether you are limited to Fedora and/or live distros.

Before being able to boot you will have to ensure that booting from USB is enabled in the BIOS.

I am sure there are other mechanisms that people will suggest

cheers
 
Old 01-18-2015, 10:57 PM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by timl View Post
Firstly you will need an ISO of your chosen distro.

If you are comfortable with the command line then try something like this to

sudo dd if=/dev/sdb of=/home/user/image.iso bs=4M

where /dev/sdb is your USB drive and image.iso is the ISO file you downloaded
The shown command code has error. The command should be instead:

Code:
sudo dd if=/home/user/image.iso of=/dev/sdb
 
Old 01-18-2015, 11:10 PM   #4
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by p3aul View Post
I'd like to install linux on a 32GB USB drive and use the space left over to install apps. Can this be done?
Yes, you can do it. It doesn't matter where you want to install the system - to internal HDD or to USB drive. Split the available drive space as you need and install system in usual way. After that, to get your system bootable you need to add few modules to kernel or to initrd. These modules need to access the drives which attached to USB ports.

If you want to boot it at random hardware, you may need to build some kind of "bloated" kernel to support as much different hardware as it possible.

The second partition at your drive you can use in any way you want.

Last edited by Teufel; 01-18-2015 at 11:14 PM.
 
Old 01-19-2015, 12:24 AM   #5
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
Originally Posted by veerain View Post
The shown command code has error. The command should be instead:

Code:
sudo dd if=/home/user/image.iso of=/dev/sdb
You are right timl gave wrong command niether the output file or the input file are correct.

Last edited by EDDY1; 01-19-2015 at 01:37 AM.
 
Old 01-19-2015, 12:42 AM   #6
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Rep: Reputation: 156Reputation: 156
I just reread my post. What a shocker. Apologies all round. I'll give myself an uppercut.
 
Old 01-19-2015, 11:56 AM   #7
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,140

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
Some Linuxes are actually designed for this. They load onto RAM when they boot, so they're much faster than just running an normal Linux from the USB stick. Knoppix, Puppy, and Slax are all good: look at the reviews on this site and linked to from Distrowatch, and take your pick. Puppy is probably the simplest to use.
 
Old 01-19-2015, 03:15 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Almost any modern distro can be installed to a usb drive. To them, the usb is just a regular internal hard drive.

I remove internal hard drive and then install to the usb if I don't have a virtual machine. (just to prevent borking my internal drive)
 
Old 01-19-2015, 03:32 PM   #9
DaMobileGuy
LQ Newbie
 
Registered: Jan 2015
Distribution: PClinuxOS KDE 64Bit & Android Kit Kat 4.4.2
Posts: 3

Rep: Reputation: Disabled
There is one caveat to the dd method above. Your 32GB will be seen as the size of the iso image file. So, if the iso file is about 3GB and you use the dd method, your 32GB usb drive will be seen as a 3GB drive.

This can be easily fixed by using gparted. I once used gparted to resize the root partition of my 8GB sdcard after dding a raspbian image file.

Last edited by DaMobileGuy; 01-19-2015 at 03:42 PM.
 
Old 01-19-2015, 03:43 PM   #10
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I asked related questions in my recent thread:
http://www.linuxquestions.org/questi...ux-4175530090/

I don't think I really got answers to some parts of that I would have expected to be answered in this forum. But despite that, I think some of what was said there would help p3aul in this thread.

Quote:
Originally Posted by p3aul View Post
use the space left over to install apps.
That aspect is much much simpler if you treat the USB as if it were a hard drive and do an ordinary install of Linux onto it.

You can use the left over space to install apps, even if you install a bootable .ISO file onto the USB (treat the USB as if it were a liveCD, rather than a hard drive). But that way adds extra layers of distribution specific complexity onto the task of using the extra space to install apps. Using the USB as if it were a hard drive means installing apps happens the ordinary way (just slower).

I still don't know what part of the performance deficit I saw in setting up a USB as a hard drive rather than liveCD was inherent in that approach vs. due to other details. But when booted in a better computer, even the USB as hard drive version wasn't all that bad performance. In theory file caching should make almost everything fast the second time you use it after booting. In practice, second use of each program was far faster than first use, but still not as fast as you would expect given enough ram that nothing ever needed to be dropped from cache once loaded.

For the best performing USB based system, I think you would want to install everything on a hard drive first, including installing and updating apps and whatever else needs to be customized, then convert it all to a squashfs and turn that into a bootable USB. I know the basics, but have not gone through the exercise to nail down the details and see the final performance. (The whole idea is based on CPU cost for decompressing being much faster than USB access speeds, so it will depend on your specific hardware).

When I installed Centos 7 from a bootable USB copy of the install DVD onto a second USB stick (treated as a hard drive), the installer was confused (as you would expect) about the drive number/name that the new install would have when finally booted. It really should have used UUID rather than device name in /boot/grub2/grub.cfg. It usually does and I don't really know why it didn't for me. But if you understand such issues, it is easy to check /etc/fstab and /boot/grub2/grub.cfg while the stick is still mounted in another Linux and make sure everything uses UUID. The next kernel update will overwrite /boot/grub2/grub.cfg, but in Centos 7 that used UUID anyway. /boot/grub2/grub.cfg only needed to be manually fxed once.

In /etc/fdisk make sure /tmp is a tmpfs, not an ordinary directory in the USB file system. Some of the installs I did got this right automatically. Others did not. When you are booted on a slow USB stick (pretending to be a hard drive) and web browsing, you really really don't want /tmp on the USB.

If you decide against removing the hard drive (for safety) during the install, pay close attention to any choice in the installer on where to put the first part of grub. When I did Centos 7, I never spotted that choice but somehow it did the right thing (maybe there is no choice or maybe the default is right). When I earlier did a similar install with Centos 6, the choice would have been easy to get past without noticing and the default was horribly wrong (would have connected the mbr of the hard drive to the directory on the usb, so neither could be used without the other). If there is a choice, make sure the first part of grub goes on the usb, not in the mbr of the hard drive.

Last edited by johnsfine; 01-19-2015 at 04:00 PM.
 
Old 01-19-2015, 03:58 PM   #11
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 50
If you have a Windows OS, there are a couple of usb-creator programs which will do this for you. Unetbootin is popular - but it may see your USB as a hard disk and thus not work properly.
If you already have a linux distro, then you can use a usb-creator program or the 'dd' command as others have said. Naturally, the dd command is quicker and easier.

You shouldn't really install just any linux distro onto your USB. Like DavidMcCann says, there are special 'live' distros for USB (and cd).
The 'live' distros only write the OS to your USB. After that, the OS on the USB will save everything in RAM. So when you re-boot - nothing is saved.
The 'live' OS versions do this to prevent write-cycles to your USB because each write cycle slowly wears away the USB.

Even so, you can still install a 'live' OS which has persistence - this saves stuff onto your USB. To do this you'll need a usb-creator program which offers the persistence option. Since you have a 32gb USB the wear from the write-cycles should still give you a few years of use.
Of course, if you have a USB without persistence then it'll last forever. Except that not being able to save stuff isn't very useful.

I think some people may have installed a normal linux distro onto a USB. In which case, you could do the same - just don't save and delete stuff all the time.
I have debian on my USB but it doesn't have persistence. I used it to then install linux distros onto my hard disk.
 
Old 01-19-2015, 04:28 PM   #12
DaMobileGuy
LQ Newbie
 
Registered: Jan 2015
Distribution: PClinuxOS KDE 64Bit & Android Kit Kat 4.4.2
Posts: 3

Rep: Reputation: Disabled
I, on several occasions tried to run a live linux systeem from a usb drive, But it was slow. Perhaps a minimalist distro might be a better option or a faster Usb 3.0 drive. I did get a marginal increase in performance when I installed linux onto a class 10 sdcard. But, it still lack the speed of a hard drive.

Today, I use a small SSD drive for the linux OS, while using a hard drive for the home partition. I still use linux on usb's mainly for troubleshooting or testing distros on real hardware.

Last edited by DaMobileGuy; 01-19-2015 at 04:33 PM.
 
Old 01-19-2015, 04:47 PM   #13
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 50
Quote:
Originally Posted by DaMobileGuy View Post
I, on several occasions tried to run a live linux systeem from a usb drive, But it was slow. Perhaps a minimalist distro might be a better option or a faster Usb 3.0 drive. I did get a marginal increase in performance when I installed linux onto a class 10 sdcard. But, it still lack the speed of a hard drive.
I have a USB 3.0 but it won't work from the USB3.0 port. So I just use the USB 2.0 port.
Even so, I never see any speed problems. I think I downloaded a couple of iso files and it was about the same speed as the OS on a hard disk.

What version of OS do you have on your USB?
Code:
uname -a
 
Old 01-19-2015, 05:23 PM   #14
DaMobileGuy
LQ Newbie
 
Registered: Jan 2015
Distribution: PClinuxOS KDE 64Bit & Android Kit Kat 4.4.2
Posts: 3

Rep: Reputation: Disabled
Quote:
Originally Posted by Higgsboson View Post
What version of OS do you have on your USB?
Code:
uname -a
Linux localhost.localdomain 3.4.64-pclos1 #1 SMP PREEMPT Thu Oct 3 22:02:09 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux

I have pclinuxos on both my system and on usb.
 
Old 01-19-2015, 05:40 PM   #15
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 50
Quote:
Originally Posted by DaMobileGuy View Post
Linux localhost.localdomain 3.4.64-pclos1 #1 SMP PREEMPT Thu Oct 3 22:02:09 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux

I have pclinuxos on both my system and on usb.
Is it the 'PCLinuxOS-liveusb' version or the full version?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Installing Linux on a USB drive LXer Syndicated Linux News 0 08-02-2011 11:01 PM
Installing linux without a CD or USB drive Kygha Linux - Newbie 9 07-20-2010 05:14 AM
Installing Debian on USB Hard Drive/USB Jump Drive kushalkoolwal Debian 10 02-26-2009 01:46 PM
Installing Linux from a usb flash drive? jck Linux - General 0 08-03-2003 04:35 PM
Installing Linux on a USB flash drive!? delphinus Linux - General 4 03-15-2003 06:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration