Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
#######
#
# E-scripts on pen drives.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/pendrive.e>
#           or at <http://angg.twu.net/e/pendrive.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######





# «.partitioning»	(to "partitioning")
# «.repartition-1»	(to "repartition-1")
# «.bootable»		(to "bootable")
# «.live-usb-old»	(to "live-usb-old")
# «.yumi»		(to "yumi")
# «.live-usb-2013»	(to "live-usb-2013")



# (find-es "debian" "debian-via-pen-drive")


# From:
# https://www.debian.org/CD/faq/#write-usb

Several of the Debian and Debian Live images, notably all i386, amd64
and arm64 images, are created using the isohybrid technology, which
means that they may be used in two different ways:

  * They may be written to CD/DVD/BD and used as normal for CD/DVD/BD
    booting.

  * They may be written to USB flash drives, bootable directly from
    the BIOS / EFI firmware of most PCs.

On a Linux machine, simply use the cp command, to copy an image to a
USB flash drive:

  cp <file> <device>

Alternatively you can also use dd:

  dd if=<file> of=<device> bs=4M; sync






#####
#
# Partitioning a pen drive
# 2010mar14
#
#####

# «partitioning»  (to ".partitioning")
# (find-es "e2fs" "e2fs-attributes")
# (find-status   "dosfstools")
# (find-vldifile "dosfstools.list")
# (find-udfile   "dosfstools/")
# (find-sh "dmesg | tail")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo umount /tmp/pen/
R
fdisk /dev/sdb
p

d
1
d
2
d
3
d

p

n
p
1
1
+8192M
7810

n
p
2
7811
15620

t
1
L
c

p

m
w

mkdosfs /dev/sdb1
fsck    /dev/sdb1
mke2fs  /dev/sdb2
fsck    /dev/sdb2

# (find-sh "dmesg")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo umount /tmp/pen
mkdir /tmp/pen/
sudo mount -o uid=$UID -t vfat /dev/sdb1 /tmp/pen/
sudo mount -o uid=$UID -t vfat /dev/sdb  /tmp/pen/
sudo mount -o uid=$UID         /dev/sdb1 /tmp/pen/
sudo mount -o uid=$UID         /dev/sdb  /tmp/pen/
mount
# (find-fline "/tmp/pen/")



#####
#
# Repartition a pen drive to make a single FAT32 partition on it
# 2013nov24
#
#####

# «repartition-1» (to ".repartition-1")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# In desperate cases ONLY, do this (destroy the partition table):
sudo dd if=/dev/zero of=/dev/sdb bs=4M count=1; sync

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# For normal cases:
sudo umount /tmp/pen/
sudo fdisk /dev/sdb
p
d
1
d
2
p
n
p
1

l
t
1
c
p
w

sudo mkdosfs /dev/sdb1




#####
#
# Bootable pen drives
# 2012jul24
#
#####

# «bootable»  (to ".bootable")
# http://www.google.com/search?q=how+to+boot+from+an+iso+on+a+usb
# http://superuser.com/questions/308635/how-to-boot-from-a-usb-device-using-an-iso-image
# http://www.isotousb.com/
# http://en.wikipedia.org/wiki/ISO_9660
# http://en.wikipedia.org/wiki/El_Torito_(CD-ROM_standard)
# http://en.wikipedia.org/wiki/Live_CD
# http://en.wikipedia.org/wiki/Live_USB




#####
#
# A live Debian on a pen drive
# 2012oct11
#
#####

# «live-usb-old» (to ".live-usb-old")
# (find-es "debian" "debian-via-pen-drive")
# http://live.debian.net/devel/live-installer/
# http://wiki.debian.org/InstallToUsbMemoryStick
# http://live.debian.net/cdimage/release/current/i386/iso-hybrid/
# http://live.debian.net/cdimage/release/current/i386/iso-hybrid/debian-live-6.0.5-i386-gnome-desktop.iso
# http://wiki.debian.org/DebianInstaller/NetInstWithThirdPartyNetworkDriver
# ftp://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/boot.img.gz

# (find-es "qemu" "virtualbox")
# (find-fline "~/LOGS/2012oct11.eev")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo dd if=$S/http/live.debian.net/cdimage/release/current/i386/iso-hybrid/debian-live-6.0.5-i386-gnome-desktop.iso of=/dev/sdb bs=4M; sync




# (find-pen-links)


sudo rm -Rv          /home/pendrive-backup/
sudo mkdir           /home/pendrive-backup/
sudo chown edrx:edrx /home/pendrive-backup/

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/pen/")
cd /tmp/pen/
for i in [2-C]* Fo* [M-v]*; do cp -Rv $i /home/pendrive-backup/; done


# (find-fline "/home/pendrive-backup/")

# (find-esgrep "grep -nH -e fdisk *.e")
# (find-sh "sudo fdisk -l /dev/sdb")
# (find-man "8 fdisk" "  -l" "List  the  partition tables")
# (find-man "8 mkdosfs" "-c" "Check the device for bad blocks")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo umount /tmp/pen/
R
mkdosfs -v -c /dev/sdb1 



/dev/sdb1



#####
#
# Yumi
# 2012oct17
#
#####

# «yumi» (to ".yumi")
# http://www.pendrivelinux.com/yumi-multiboot-usb-creator/






#####
#
# Live USB (2013)
# 2013oct25
#
#####

# «live-usb-2013» (to ".live-usb-2013")
# (find-es "live")
# http://www.linux.com/community/blogs/133-general-linux/420179-creating-a-debian-live-usb-flash-drive-with-persistence-for-non-techies
# http://live.debian.net/manual/1.x/html/persistence.html
# http://ubuntupop.blogspot.com.br/2013/05/tutorial-how-to-create-debian-live-usb.html

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)

sudo rm -Rf ~/live/chroot/
sudo rm -Rf ~/live/binary/

mkdir ~/live/
   cd ~/live/
lb config
R
lb build  |& tee olb

# file:///usr/share/doc/live-manual/html/live-manual.en.html
# (find-fline "~/live/")

# (find-status   "live-build")
# (find-vldifile "live-build.list")
# (find-udfile   "live-build/")
# (find-fline "/usr/lib/live/build/")
# (find-fline "/usr/lib/live/build/binary_syslinux")
# (find-fline "/usr/lib/live/build/binary_iso")
# (find-fline "/usr/lib/live/build/binary_package-lists")












# http://debian.profijt.info/?page_id=54 Build a persistent Debian USB drive | Debian Howto's
#
# apt-get install -t stable live-build debootstrap
# The following extra packages will be installed:
#   gnu-fdisk live-boot-doc live-config-doc live-manual-html
# Suggested packages:
#   debian-keyring xorriso loadlin memtest86+ memtest86 mtools parted
#   squashfs-tools mtd-tools syslinux grub uuid-runtime win32-loader

# (find-man "1 lb")
# (find-man "7 live-build")
# (find-man "1 lb_config")

# http://debian.profijt.info/?page_id=54 Build a persistent Debian USB drive | Debian Howto's
# (find-man "8 apt-get" "-t, --target-release")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
apt-get install -t stable live-build debootstrap
apt-get install dosfstools genisoimage mtools parted syslinux uuid-runtime squashfs-tools genext2fs mtd-tools

# (find-fline "~/live/")
# (find-fline "~/live/olb")
rm -Rfv ~/live/

  cd /tmp/
  cd ~/
mkdir live
cd    live
lb config --architecture i386
lb config -b usb-hdd
lb config --bootappend-live "persistent"
lb config --distribution stable
lb config --archive-areas "main contrib non-free"
lb config --mirror-bootstrap       http://ftp.nl.debian.org/debian/
lb config --mirror-chroot-security http://ftp.nl.debian.org/debian-security/
lb config --mirror-binary          http://ftp.nl.debian.org/debian/
lb config --mirror-binary-security http://ftp.nl.debian.org/debian-security/

# (find-fline "~/live/")
# (find-fline "~/live/olb")
# (find-fline "~/live/chroot/")
# (find-sh "cd ~/live/ && sudo find .* * | sort")
# (find-fline "~/live/binary/live/")

# (find-status   "syslinux")
# (find-vldifile "syslinux.list")
# (find-udfile   "syslinux/")
# (find-man "1 syslinux")

lb config --help

# (find-man "1 xorriso")
# (find-man "1 xorriso" "-as personality")

lb config --packages "xserver-xorg-core xorg xfce4 iceweasel gparted partimage"
lb config --packages "xserver-xorg-core xorg xfce4 iceweasel gparted partimage emacs fvwm zsh"
# http://live.debian.net/manual/en/txt/live-manual.txt
R
lb build  |& tee olb
lb build  |& tee olb2

# "loop: can't delete device /dev/loop2: Device or resource busy"
rm binary/dists/squeeze/squeeze
# and run the build again, it should run fine the second time.

# To copy the image to your USB drive:
dd if=binary.img of=/dev/your-usb-device
fdisk /dev/your-usb-device
# Press "p" to list the partition table, look for the end cylinder of
# the first partition.
# Then press "n" to create a new partition, select a primary partition
# and enter the first free cylinder as the starting cylinder. Now you
# have to enter the size of the new partition.
# Press "w" to write the changes to the disk.

# Now all you have to do is create a filesystem in your new partition,
# use the label "live-rw":
mkfs.ext3 -L live-rw /dev/your-new-partition


# (find-sh "locate testroot")
# (find-man "1 lb_testroot")
# (find-man "1 lb_chroot")
# (find-sh "mount")


# (find-status   "live-build")
# (find-vldifile "live-build.list")
# (find-udfile   "live-build/")
# (find-fline "/usr/lib/live/build/")
# (find-fline "/usr/lib/live/build/binary_syslinux")
# (find-fline "/usr/lib/live/build/binary_iso")
# (find-fline "/usr/lib/live/build/binary_package-lists")

# (find-status   "debootstrap")
# (find-vldifile "debootstrap.list")
# (find-udfile   "debootstrap/")

# (find-status   "live-boot-doc")
# (find-vldifile "live-boot-doc.list")
# (find-udfile   "live-boot-doc/")
# (find-man "7 live-boot")
# (find-man "7 live-build")
# (find-man "7 live-tools")
# (find-man "7 live-config")
# (find-man "5 persistence.conf")

# (find-status   "live-config-doc")
# (find-vldifile "live-config-doc.list")
# (find-udfile   "live-config-doc/")
# (find-udfile "live-config/examples/live-config-foobar/")

# (find-status   "live-manual-html")
# (find-vldifile "live-manual-html.list")
# (find-udfile   "live-manual-html/")
# (find-udfile "live-manual/html/")
# file:///usr/share/doc/live-manual/html/live-manual.en.html

# (find-status   "genisoimage")
# (find-vldifile "genisoimage.list")
# (find-udfile   "genisoimage/")

# (find-man "5 genisoimagerc")
# (find-man "1 mkzftree")
# (find-man "1 genisoimage")
# (find-man "1 dirsplit")
# (find-man "1 isoinfo")
# (find-man "1 geteltorito")
# (find-man "1 devdump")
# (find-man "1 isodump")
# (find-man "1 isovfy")




# (find-anggfile "LOGS/2012nov06.emacs")
# (find-anggfile "LOGS/2012nov06.emacs" "debian-live")









#  Local Variables:
#  coding:               raw-text-unix
#  ee-delimiter-hash:    "\n#*\n"
#  ee-delimiter-percent: "\n%*\n"
#  ee-anchor-format:     "«%s»"
#  End: