HowTo: Put a Live Image to a USB stick.

Share your own howto's etc. Not for support questions!

HowTo: Put a Live Image to a USB stick.

Postby Bro.Tiag » 2008-10-25 02:32

This how to is a spin-off of MeanDean's HowTo: create, customize, and install a debian live image and will cover how I create a debian live image for booting from a usb stick, add software, customize, and hopefully save & maintain stuff on said usb stick.

Some of the sources I used.
DebianLive/FirstStepsUSB
DebianLive/Howto/USB
DebianLive Examples

REQUIRED SOFTWARE
live-helper - in debian main repo
squashfs-tools* - in debian main repo
genisoimage* - in debian main repo
squashfs-modules* - in debian main repo
* - I do not believe that these are needed, but I already have them installed so I'm not sure.


Sort out your own root permission.

0 - GET STARTED
#open a terminal
#create a directory to hold all your work
mkdir usblive
#change to our work directory
cd usblive

1 - CREATE A BASE CONFIGURATION
#From within usblive use lh_helper to create a basic configuration for a minimal Sid system.
lh_config -d sid -b usb-hdd
#Now start the actual build process. It might take a while...
lh_build

2 - Put the image to the USB device
#You should already know where your usb stick is mounted, but just in case do the following to sort it out.
ls -a /dev/disk/by-id/usb*
#Note: you need the dev file for the whole stick (i.e. "/dev/sdb"), not only for one partition on it.
#Unmount your usb stick and then put the image to your usb stick.
umount /dev/sdb
dd if=binary.img of=/dev/sdb bs=1M


3 - Now have at it
#There are several ways to test out your image before rebooting and dean covers at least one of them as does the DebianLive/Howto/USB. I just reboot with the usb stick in place. If all goes to plan you should get the nice Debian Live Bootsplash.
Image
Cheers
Last edited by Bro.Tiag on 2008-10-25 18:51, edited 1 time in total.
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

Additional Options.

Postby Bro.Tiag » 2008-10-25 02:33

In the OP, I set up a Live Image for just a minimal Sid install. One is not limited to just that.

0 - etch, lenny, Sid, oh my
#To make live Images of different distributions (default is etch) use the -d flag with lh_config:
lh_config -d lenny
#or
lh_config -d sid

1 - Oh what desktop environment to use
#To use a kde desktop image:
lh_config -p kde-desktop

#To make a gnome desktop image:
lh_config -p gnome-desktop

#To make an Xfce desktop image:
lh_config -p xfce-desktop

#Then build your Image.
lh_build

2 - Some Examples
#So for example, if you want etch with Xfce you would use;
lh_config -p xfce-desktop -b usb-hdd && lh_build

#Or for lenny & gnome use;
lh_config -d lenny -p gnome-desktop

Cheers
Last edited by Bro.Tiag on 2008-10-25 02:58, edited 2 times in total.
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

Adding Software at build time.

Postby Bro.Tiag » 2008-10-25 02:33

So you want to add some specific applications from the get go. Well you can, and there are several ways to do so. This is the easiest way.

Since I've only done a minimal Sid install that is what I'll use for my example.

#Include screen, mc, moc, alsa and elinks.
lh_config -d sid -b usb-hdd --packages screen mc moc alsa-base elinks && lh_build

That's it.

Then dd the binary image to your usb stick same as above.
Last edited by Bro.Tiag on 2008-10-27 23:41, edited 3 times in total.
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

This post for a custom setup.

Postby Bro.Tiag » 2008-10-25 02:33

Right, so you have done your stock install with a few must have applications and wrote it to a usb stick and all goes to plan. Now you have decided that well the background is not to your liking as well as a few other configurations not to mention you forgot that one killer app that you just mush have. What to do. Well you could start all over again, or you could just do some custom work & rebuild the binary image.

0 - Hacking your chroot file system
This assumes your bootstrap stage is still intact from previous calls to lh_bootstrap (or lh_build)

#From with in your working directory clean up the old binary build.
lh_clean --binary
#Change what you need in the chroot directory or chroot into chroot and do the hacks there.
chroot chroot
#Once you are finished, exit and then build a new binary.
lh_binary

Then dd the binary image to your usb stick same as above.

Cheers
Last edited by Bro.Tiag on 2008-10-28 00:03, edited 3 times in total.
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

How to save & maintain stuff on your USB stick.

Postby Bro.Tiag » 2008-10-25 02:34

Well I haven't gotten exactly what I wanted to do accomplished, but it's a start. Using DebianLive HOWTO Custom Install as a place to start. I've managed to set up my DebianLive usb stick so that it will retain my user settings and such.

This is what I did, you may need to edit to suite.

0 - BOOT DEBIANLIVE IMAGE & ADD PARTITIONS
#After writing the image to my usb stick I reboot to the usb stick.
#Next I partition the remaining space on the usb stick. First I need to add gparted.
apt-get update
apt-get install gparted

#Now with gparted I added two new partitions.
# 1 as ext3 and
# 1 as fat32
# I also added a Label, home-rw for the ext3 partition which is to be used as my ~/user partition. Besure to add the label, it is what persistent uses to mount the partition.

1 - SET UP THE ~/HOME PARTITION
#I used the linux partition as my ~/home directory. So I needed to copy everything from it to the new partition.
#mount the linux partition
mount /dev/sdb2 /mnt
#copy ~/home to the new partition
cp -a /home/* /mnt/

2 - ADD THE DATA PARTITION
#The data partition has to be mounted after the Live system is up & running.
#So I used a bash script to mount the data partition and added the script to my window managers autostart function.
#I run e17, so you'll have to sort out how to auto start apps on your own.
Code: Select all
#!/bin/bash
# shared-disc.sh
# partition /home
PART=`mount | grep /home | awk '{print $1}' | sed 's/2/3/'`
[ -z "$PART" ] && exit 1
[ -d "$HOME/Documents" ] || mkdir $HOME/Documents
sudo mount $PART $HOME/Documents \
-o rw,noexec,nosuid,nodev,noatime,uid=999,utf8,shortname=lower


3 - USE PERSISTENT TO BOOT DEBIANLIVE
#persistent needs to be added to the boot perimeter. This can be done at boot time by hand, or you can edit the syslinux/menu.cfg file and make it permanent. I've been trying this for the last couple of days so I forget exactly how I did such. Regardless, it can be done from windows or linux w/ a text editor. Just add persistent to the end of the kernel line & save.
Code: Select all
LABEL live
   MENU LABEL Start Debian Live 686
   kernel /live/vmlinuz2
   append initrd=/live/initrd2.img boot=live union=aufs vga=791 persistent


4 - FOR THE FUTURE
#it says in DebianLive HOWTO Custom Install that one should also be able to mount the whole "/", using casper-rw (live-rw for lenny & sid) in place of home-rw, and then be able to add software and have other configurations saved as well. I was unable to get this to work, yet. It may have to do with how I set up my partitions or it might have something to do with the uses of "-b usb-hdd " in the original DebianLive build. I've yet to test those theories.

[Edit]Right, I did some experimenting and have determined that it is in fact an issue with the use of "-b usb-hdd " in the original DebianLive build. I followed the instructions @ DebianLive HOWTO Custom Install this time using a stock Debian Live Sid cd and all went to plan. I added a few apps, did some simple configurations, rebooted and everything was just as I left it. So as not to clutter this forum with yet another custom debian live how to, here's a link to where I did, Instructions for setting up a DebianLive Operating System on a USB stick.[/Edit]

Cheers
Last edited by Bro.Tiag on 2008-11-04 02:43, edited 4 times in total.
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

Postby Bro.Tiag » 2008-10-25 02:35

This post left intentionally blank.
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

Postby helmsdeeper » 2008-10-25 05:55

Thanks Bro. Tiag, I've yet to try booting a live usb image.
I might play around with a 8gb stick sometime this weekend and try Lenny/kde.
helmsdeeper
 
Posts: 22
Joined: 2008-07-13 06:08

Postby n6yga » 2008-10-25 15:48

Bro.Tiag wrote:This post left intentionally blank.


...awesome.


Mark.
n6yga
 
Posts: 80
Joined: 2008-04-29 18:05
Location: El Monte, CA

Postby Bro.Tiag » 2008-10-25 18:04

n6yga wrote:
Bro.Tiag wrote:This post left intentionally blank.


...awesome.


Mark.

Well it's just in case I think of something else, but as you can see I ran out of gas last night.

Cheers
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

Postby n6yga » 2008-10-26 02:43

Don't be afraid to take credit for a great sense of humor, my friend! We need more of that, as I think, perhaps, we take ourselves too seriously!

Have a great weekend!

Mark.
n6yga
 
Posts: 80
Joined: 2008-04-29 18:05
Location: El Monte, CA

Postby MeanDean » 2008-10-26 03:15

reserved posts are annoying....but I find them very useful....

nice howto teague, will be expecting more soon....
User avatar
MeanDean
 
Posts: 3953
Joined: 2007-09-01 01:14

Debian live lenny on USB

Postby g0nad » 2009-02-17 05:39

I'm looking for a way to have my system run from a USB stick but for the changes made to be persistent.

So that on the machine that runs from the USB stick, if I change configurations in /etc or add/remove/update packages the changes aren't lost on reboot.

I've just made a Debian Live Lenny USB thumb drive and tested it out, and that's nearly what I want. I'd just like it not to be forgetful.
g0nad
 
Posts: 9
Joined: 2009-02-17 05:34

Re: Debian live lenny on USB

Postby Bro.Tiag » 2009-02-17 13:29

g0nad wrote:I'm looking for a way to have my system run from a USB stick but for the changes made to be persistent.

So that on the machine that runs from the USB stick, if I change configurations in /etc or add/remove/update packages the changes aren't lost on reboot.

I've just made a Debian Live Lenny USB thumb drive and tested it out, and that's nearly what I want. I'd just like it not to be forgetful.


I put together a wee how to at, Instructions for setting up a DebianLive Operating System on a USB stick.. Give it a try and let me know how it works for ya.

Cheers
User avatar
Bro.Tiag
 
Posts: 1937
Joined: 2007-06-02 19:14

Thanks

Postby g0nad » 2009-02-19 05:46

Thanks for the howto! It appears to have worked. It seems to me that the only things really needed was the 'live persistent' boot option and the partition labelled 'live-rw'. Is that correct?

What happens when Debian release and update for the kernel?
g0nad
 
Posts: 9
Joined: 2009-02-17 05:34

timezone / interfaces

Postby g0nad » 2009-02-19 06:39

Two things I've noticed so far: I can't change the timezone, and if I make changes to the interfaces file it gets clobbered on reboot.

I've tried to make the timezone changes with 'dpkg-reconfigure tzdata'

and for /etc/network/interfaces I wanted to make the computer's IP static rather than dhcp so that I could remove the package dhcp3-client

I've built my USB image from debian-live-500-i386-standard.iso as the machine that will be running the USB image with it as it's system is going to be a samba server.
g0nad
 
Posts: 9
Joined: 2009-02-17 05:34

Next

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable