Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
Distribution: PClinuxOS KDE 64Bit & Android Kit Kat 4.4.2
Posts: 3
Rep:
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.
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
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.
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Rep:
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.
Distribution: PClinuxOS KDE 64Bit & Android Kit Kat 4.4.2
Posts: 3
Rep:
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.
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Rep:
Quote:
Originally Posted by DaMobileGuy
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.