Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on making live USBs (mainly with live-build).
#
# 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/live.e>
#           or at <http://angg.twu.net/e/live.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/>.
#
#######






# «.manpages»			(to "manpages")
# «.crunchbang»			(to "crunchbang")
# «.persistence-inspect»	(to "persistence-inspect")
# «.unetbootin»			(to "unetbootin")
# «.unetbootin-deb-src»		(to "unetbootin-deb-src")
# «.debian-live-old»		(to "debian-live-old")
# «.debian-live»		(to "debian-live")
# «.live-manual»		(to "live-manual")
# «.live-build-Contents-bug»	(to "live-build-Contents-bug")
# «.live-build-versions»	(to "live-build-versions")
# «.live-build-distro»		(to "live-build-distro")
# «.live-build-my.list.chroot»	(to "live-build-my.list.chroot")
# «.live-build-chrome»		(to "live-build-chrome")
# «.live-build-add-partition»	(to "live-build-add-partition")
# «.live-build-partition-3»	(to "live-build-partition-3")
# «.live-build-read-partitions»	(to "live-build-read-partitions")
# «.live-build-read-short»	(to "live-build-read-short")
# «.live-build-gpt»		(to "live-build-gpt")
# «.live-build-gparted-by-hand»	(to "live-build-gparted-by-hand")
# «.live-build-test-qemu»	(to "live-build-test-qemu")
# «.live-build-hdd»		(to "live-build-hdd")
# «.live-build-xorriso»		(to "live-build-xorriso")
# «.live-build»			(to "live-build")
# «.debian-live-chrome»		(to "debian-live-chrome")
# «.debian-live-stretch»	(to "debian-live-stretch")
# «.debian-live-make-ISO»	(to "debian-live-make-ISO")
# «.debian-live-irc»		(to "debian-live-irc")
# «.irc-channel»		(to "irc-channel")
# «.debian-live-mailing-list»	(to "debian-live-mailing-list")
# «.mailing-list»		(to "mailing-list")




# (find-es "pendrive")



# (find-fline "~/live/")
# (find-fline "~/live/olb")
# (find-fline "~/live/olb"     "lb chroot_cache restore")
# (find-fline "/usr/lib/live/build/chroot_cache")

# (find-fline "/usr/bin/lb")
# (find-fline "/usr/lib/live/build.sh")
# (find-fline "/usr/share/live/build/functions/")




# (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")




#####
#
# manpages
# 2013oct26
#
#####

# «manpages» (to ".manpages")





#####
#
# crunchbang
# 2013nov24
#
#####

# «crunchbang» (to ".crunchbang")
# http://crunchbang.org/
# http://en.wikipedia.org/wiki/CrunchBang_Linux
# http://crunchbang.org/forums/viewtopic.php?id=19658 Waldorf LiveUSB
# http://crunchbang.org/forums/viewtopic.php?id=23267 How To prepare an ISO to USB - Linux & Windows Instructions ***
# http://crunchbang.org/forums/viewtopic.php?id=25489 The Correct Way for Persistence on a LiveUSB for WALDORF ***
# http://crunchbang.org/forums/viewtopic.php?id=22031 Waldorf and persistence
# http://crunchbang.org/torrents/crunchbang-11-20130506-i686.iso.torrent
# (find-fline "/sda5/torrents/" "crunchbang-11-20130506-i686.iso")

# (find-sh0 "sudo ls -l /dev/disk/by-id/*usb*")

** First test (without persistence):
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
ISO=/sda5/torrents/crunchbang-11-20130506-i686.iso
laf $ISO
sudo dd if=$ISO of=/dev/sdb bs=4M; sync


** To create a pen drive with persistence we follow the instructions here:
**   http://crunchbang.org/forums/viewtopic.php?id=25489
** 1) Format the pen drive with a single FAT32 partition
**   (find-es "pendrive" "repartition-1")
** 2) Install the ISO into that partition with:
**   (to "unetbootin")
** 3) Shrink that partition with gparted, label it "DEBIAN_LIVE",
**    and create a 2nd partition (ext2), label it "persistence"
** 4) Make the changes below:

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-tkdiff "~/LIVE/syslinux.cfg.orig" "~/LIVE/syslinux.cfg")

mkdir /tmp/pen/
sudo mount /dev/sdb1 /tmp/pen/
cd /tmp/pen/
sudo cp -iv /tmp/pen/syslinux.cfg /tmp/pen/syslinux.cfg.orig
sudo cp -v    ~/LIVE/syslinux.cfg /tmp/pen/syslinux.cfg
# (find-tkdiff "/tmp/pen/syslinux.cfg.orig" "/tmp/pen/syslinux.cfg")
sudo umount          /tmp/pen/

mkdir                /tmp/persistence/
sudo mount /dev/sdb2 /tmp/persistence/
sudo cp -v    ~/LIVE/live-persistence.conf /tmp/persistence/
sudo umount          /tmp/persistence/



# Old notes:
# (kill-new " persistence")
# (find-asrootfile "/tmp/pen/")
# (find-asrootfile "/tmp/pen/syslinux.cfg")
# (find-fline        "~/LIVE/syslinux.cfg")
# (find-fline "~/LIVE/live-persistence.conf")
# (kill-new "")
# (find-asroot "/tmp/persistence/")
# (find-asroot "/tmp/persistence/live-persistence.conf")





#####
#
# Inspecting how persistence is implemented
# 2013nov25
#
#####

# «persistence-inspect» (to ".persistence-inspect")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
mkdir /tmp/debian-live/
mkdir /tmp/persistence/
sudo mount -o ro /dev/sdb1 /tmp/debian-live/
sudo mount -o ro /dev/sdb2 /tmp/persistence/

# (find-fline "/tmp/debian-live/")
# (find-fline "/tmp/debian-live/syslinux.cfg" "persistence")
# (find-fline "/tmp/persistence/")
# (find-fline "/tmp/persistence/home/crunchbang/")
# (find-fline "/tmp/persistence/usr/bin/")

sudo umount /tmp/debian-live/
sudo umount /tmp/persistence/

# (find-man "mount")
# (find-sh "locate union")



#####
#
# unetbootin
# 2013nov24
#
#####

# «unetbootin» (to ".unetbootin")
# (find-status   "unetbootin")
# (find-vldifile "unetbootin.list")
# (find-udfile   "unetbootin/")
# (find-man "1 unetbootin")
# (find-fline "/usr/share/menu/unetbootin")
# (find-fline "/usr/share/menu/unetbootin" "Applications/System/Administration")
# http://unetbootin.sourceforge.net/
# http://sourceforge.net/apps/trac/unetbootin/wiki
# http://sourceforge.net/apps/trac/unetbootin/wiki/guide
# http://unetbootin.sourceforge.net/diskimg/readme.txt
# http://sourceforge.net/apps/trac/unetbootin/wiki/installmodes
# http://sourceforge.net/apps/trac/unetbootin/wiki/commands ***
# http://sourceforge.net/apps/trac/unetbootin/wiki/commands?format=txt
# (find-wget "http://sourceforge.net/apps/trac/unetbootin/wiki/commands?format=txt")






#####
#
# unetbootin (from the debian sources)
# 2013nov28
#
#####

# «unetbootin-deb-src» (to ".unetbootin-deb-src")
# http://ftp.de.debian.org/debian/pool/main/u/unetbootin/
# http://ftp.de.debian.org/debian/pool/main/u/unetbootin/unetbootin_585-2.dsc
# http://ftp.de.debian.org/debian/pool/main/u/unetbootin/unetbootin_585-2.debian.tar.gz
# http://ftp.de.debian.org/debian/pool/main/u/unetbootin/unetbootin_585.orig.tar.gz
#*
rm -Rv ~/usrc/unetbootin/
mkdir  ~/usrc/unetbootin/
cd $S/http/ftp.de.debian.org/debian/pool/main/u/unetbootin/
cp -v unetbootin_585* ~/usrc/unetbootin/
cd     ~/usrc/unetbootin/
dpkg-source -sn -x unetbootin_585-2.dsc
cd     ~/usrc/unetbootin/unetbootin-585/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (find-fline "~/usrc/unetbootin/")
* (eepitch-shell)
cd ~/usrc/unetbootin/
sudo dpkg -i *.deb

#*
# (code-c-d "unetbootin" "~/usrc/unetbootin/unetbootin-585/")
# (find-unetbootinfile "")




#####
#
# Debian Live (old)
# 2014jul06
#
#####

# «debian-live-old» (to ".debian-live-old")
# «debian-live» (to ".debian-live")
# http://live.debian.net/manual/1.x/html/persistence.html
# (find-fline "/sda4/isos/")
# (find-es "live" "crunchbang")

** First test (without persistence):
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
ISO=/sda4/isos/debian-live-7.5.0-i386-xfce-desktop.iso
laf $ISO
sudo dd if=$ISO of=/dev/sdb bs=4M; sync





#####
#
# live-manual
# 2018mai18
#
#####

# «live-manual» (to ".live-manual")
# http://packages.debian.org/live-manual
# https://packages.debian.org/search?keywords=live-manual
# https://packages.debian.org/sid/live-manual-html
# http://http.debian.net/debian/pool/main/l/live-manual/live-manual_20151217.1_all.deb
# http://http.debian.net/debian/pool/main/l/live-manual/live-manual-html_20151217.1_all.deb
# http://debian-live.alioth.debian.org/live-manual/stable/manual/html/live-manual.en.html
# http://debian-live.alioth.debian.org/ (should transition to:)
# https://salsa.debian.org/public

cd /tmp/
wget http://http.debian.net/debian/pool/main/l/live-manual/live-manual_20151217.1_all.deb
wget http://http.debian.net/debian/pool/main/l/live-manual/live-manual-html_20151217.1_all.deb
  sudo dpkg -i live-manual-html_20151217.1_all.deb
# sudo dpkg -i live-manual_20151217.1_all.deb

# (find-status   "live-manual-html")
# (find-vldifile "live-manual-html.list")
# (find-udfile   "live-manual-html/")
# (find-fline "/usr/share/doc/live-manual/html/live-manual/")
# file:///usr/share/doc/live-manual/html/live-manual/about-manual.en.html#7
# file:///usr/share/doc/live-manual/html/live-manual/examples.en.html
# file:///usr/share/doc/live-manual/html/live-manual/installation.en.html#installing-live-build





#####
#
# Why we need the version of live-build from Sid (the Contents-xxx.gz bug)
# 2018mai29
#
#####

# «live-build-Contents-bug» (to ".live-build-Contents-bug")
# Description of the bug:
# https://superuser.com/questions/923411/why-are-there-no-contents-arch-gz-file-for-debian-jessie
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637442
#
# Check:
# http://ftp.debian.org/debian/dists/wheezy/main/  Contents-amd64.gz
# http://ftp.debian.org/debian/dists/stretch/main/ Contents-amd64.gz




#####
#
# live-build: installing a newer version (from sid)
# 2018mai18
#
#####

# «live-build-versions» (to ".live-build-versions")
# http://packages.debian.org/live-build
# https://packages.debian.org/search?keywords=live-build
# http://http.debian.net/debian/pool/main/l/live-build/
# http://http.debian.net/debian/pool/main/l/live-build/live-build_20180411.dsc
# http://http.debian.net/debian/pool/main/l/live-build/live-build_20180411.tar.xz
# http://http.debian.net/debian/pool/main/l/live-boot-doc/
# http://http.debian.net/debian/pool/main/l/live-manual/

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
wget http://cdn-fastly.deb.debian.org/debian/pool/main/l/live-build/live-build_20180411_all.deb
wget http://cdn-fastly.deb.debian.org/debian/pool/main/l/live-build/live-build_20170213_all.deb
sudo dpkg -i live-build_20180411_all.deb
apti -f

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




#####
#
# live-build: changing the distribution
# 2018mai19
#
#####

# «live-build-distro» (to ".live-build-distro")
# (find-man "1 lb_config")
# (find-man "1 lb_config" "   --debian-installer-distribution")
# (find-fline "/usr/lib/live/build/lb_config")

       --debian-installer-distribution        stretch
       --distribution                         stretch
       --parent-distribution                  stretch
       --parent-debian-installer-distribution stretch




#####
#
# live-build: adding packages using the my.list.chroot file
# 2018mai18
#
#####

# «live-build-my.list.chroot» (to ".live-build-my.list.chroot")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo rm -Rfv /home/live/
mkdire /home/live/
cd     /home/live/

cat > /tmp/my.list.chroot <<'%%%'
emacs24 emacs24-el zsh lua5.1 git make lua-lpeg expect xpdf recode figlet
xinit fvwm
%%%

cd /home/live/
sudo lb config \
  --debian-installer-distribution        stretch \
  --distribution                         stretch \
  --parent-distribution                  stretch \
  --parent-debian-installer-distribution stretch

sudo cp -v /tmp/my.list.chroot \
  /home/live/config/package-lists/my.list.chroot

sudo lb build   |& tee build1.log




#####
#
# live-build: adding some standard debian packages plus google-chrome
# 2018mai19
#
#####

# «live-build-chrome» (to ".live-build-chrome")
# (find-THfile "live-build.blogme" "live-build-chrome")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# sudo rm -Rfv /home/live/
mkdire /home/live/
cd     /home/live/

# sudo lb clean --binary
sudo lb clean
sudo lb config \
  --debian-installer-distribution        stretch \
  --distribution                         stretch \
  --parent-distribution                  stretch \
  --parent-debian-installer-distribution stretch

cat > /tmp/my.list.chroot <<'%%%'
emacs24 emacs24-el zsh lua5.1 git make lua-lpeg expect xpdf recode figlet
xinit fvwm
lua5.1-doc install-info bash-doc zsh-doc
%%%
sudo cp -v /tmp/my.list.chroot \
  /home/live/config/package-lists/my.list.chroot

cd /tmp/
wget -nc https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
wget -nc http://http.debian.net/debian/pool/non-free/e/emacs24-non-dfsg/emacs24-common-non-dfsg_24.5+1-2_all.deb
# (find-fline "/tmp/")
sudo cp -v google-chrome*.deb           /home/live/config/packages.chroot/
sudo cp -v emacs24-common-non-dfsg*.deb /home/live/config/packages.chroot/

cd     /home/live/
sudo lb build   |& tee build1.log

# (find-fline "/home/live/")
# (find-fline "/home/live/build1.log")
# (find-fline "/home/live/" "live-image-amd64.hybrid.iso")
# (find-fline "/home/live-images/")

laf -h /home/live/
laf -h /home/live-images/
laf -h /home/live/live-image-amd64.hybrid.iso
cp -v  /home/live/live-image-amd64.hybrid.iso \
       /home/live-images/emacs-fvwm-chrome.hybrid.iso



# Make an image adding xfce4 and lxde
#
cat > /tmp/my.list.chroot <<'%%%'
emacs24 emacs24-el zsh lua5.1 git make lua-lpeg expect xpdf recode figlet
xinit fvwm
lua5.1-doc install-info bash-doc zsh-doc
xfce4 lxde
%%%
sudo cp -v /tmp/my.list.chroot \
   /home/live/config/package-lists/my.list.chroot

cd /home/live/
sudo lb clean
sudo lb build   |& tee build2.log

# (find-fline "/home/live/")
# (find-fline "/home/live/" "live-image-amd64.hybrid.iso")
# (find-fline "/home/live-images/")

laf -h /home/live/
laf -h /home/live-images/
laf -h /home/live/live-image-amd64.hybrid.iso
cp -v  /home/live/live-image-amd64.hybrid.iso \
       /home/live-images/emacs-fvwm-xfce4-lxdm-chrome.hybrid.iso
laf -h /home/live-images/

# Copy the image into the pen drive
# (find-fline "/dev/disk/by-id/")
#
sudo time \
  dd if=/home/live-images/emacs-fvwm-xfce4-lxdm-chrome.hybrid.iso of=/dev/sdb
sync






# 4.5.2 Copying an ISO hybrid image to a USB stick:
# file:///usr/share/doc/live-manual/html/live-manual/the-basics.en.html#195
#   cp live-image-i386.hybrid.iso ${USBSTICK}

cd /home/live/
sudo time \
  dd if=live-image-amd64.hybrid.iso of=/dev/sdb
sync





#####
#
# Adding a partition to a pen drive made with live-build
# 2018mai29
#
#####

# «live-build-add-partition» (to ".live-build-add-partition")
# (to "live-usb-partition-3")
# (find-man "8 fdisk" "  -l")
# (find-sh "sudo fdisk -l /dev/sdb")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo fdisk  /dev/sdb
p
n
p
3

+200M
p
m
w
sync

# Errors and warnings:
#   WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util
#   fdisk doesn't support GPT. Use GNU Parted.

# (find-sh "sudo fdisk -l /dev/sdb")
#    Device Boot      Start         End      Blocks   Id  System
# /dev/sdb1   *          64     1429503      714720    0  Empty
# /dev/sdb2             708        2115         704   ef  EFI (FAT-12/16/32)
# /dev/sdb3            2116      411715      204800   83  Linux

sudo mke2fs /dev/sdb3
# The kernel still uses the old table. The new table will be used at
# the next reboot or after you run partprobe(8) or kpartx(8)
sync

# (find-man "8 partprobe")
# (find-man "8 kpartx")
sudo partprobe
sudo kpartx
sudo kpartx /dev/sdb

mkdir /tmp/pen1
mkdir /tmp/pen2
mkdir /tmp/pen3
sudo mount -o ro /dev/sdb1 /tmp/pen1
sudo mount -o ro /dev/sdb2 /tmp/pen2
sudo mount       /dev/sdb3 /tmp/pen3

sudo umount /tmp/pen1
sudo umount /tmp/pen2
sudo umount /tmp/pen3




#####
#
# Putting some files (edrx.tgz plus scripts) in the 3rd partition of a Live USB
# 2018mai29
#
#####

# «live-build-partition-3» (to ".live-build-partition-3")
# (to  "live-build-add-partition")
# (find-fline "/home/live-images/")
# (find-fline "/home/live-images/edrx/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "~/live-build/")

rm -Rv ~/live-build/edrx.tgz
rm -Rv ~/live-build/edrx2.tgz

cd
rm -v ~/TH/L/edrx.tgz
rm -v      ~/edrx.tgz
makeLedrxtgz
laf ~/edrx.tgz ~/TH/L/edrx.tgz
sudo cp -v ~/TH/L/edrx.tgz ~/live-build/

# (find-fline "~/books/__comp/")
cd
FILES=(
  TODO
  ORG/index.org
  books/__comp/__comp.el
  books/__comp/ierusalimschy__programming_in_lua_2nd_ed.pdf
  books/__comp/ierusalimschy__programming_in_lua_3rd_ed.pdf
)
sudo tar -cvzf ~/live-build/edrx2.tgz $FILES

# (find-fline "~/live-build/")




* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
mkdir /tmp/pen3/
sudo mount /dev/sdb1 /tmp/pen3/
# (find-fline "/tmp/pen3/")
# (find-angg "live-build/")

mount

sudo cp -v ~/live-build/edrx*.tgz /tmp/pen3/
sudo cp -v ~/live-build/install?  /tmp/pen3/

sudo umount /tmp/pen3/
sync


# PROBLEM: the pen drive with this added partition doesn't even boot!
# Here is a screenshot (low-tech):
# http://angg.twu.net/tmp/live-build-partition-3-bug-2018may29.jpg




#####
#
# Mounting a liveUSB image on a loop device and reading its partitions
# 2018mai29
#
#####

# «live-build-read-partitions» (to ".live-build-read-partitions")
# (find-fline "/home/live-images/" "emacs-fvwm-xfce4-lxdm-chrome.hybrid.iso")
# (find-es "loop" "partx")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -v /home/live-images/emacs-fvwm-xfce4-lxdm-chrome.hybrid.iso /tmp/myliveusb.img

partx --show -            /tmp/myliveusb.img
# NR START     END SECTORS SIZE NAME UUID
#  1    64 1429503 1429440 698M      
#  2   708    2115    1408 704K      

sudo losetup   /dev/loop4 /tmp/myliveusb.img
sudo partx --show -       /dev/loop4
sudo partx --add          /dev/loop4
# partx: /dev/loop4: error adding partition 2

sudo fdisk -l /dev/loop4
# WARNING: GPT (GUID Partition Table) detected on '/dev/loop4'! The
# util fdisk doesn't support GPT. Use GNU Parted.
#
# Disk /dev/loop4: 731 MB, 731906048 bytes
# 255 heads, 63 sectors/track, 88 cylinders, total 1429504 sectors
# Units = sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disk identifier: 0x772e4d3a
# 
#       Device Boot      Start         End      Blocks   Id  System
# /dev/loop4p1   *          64     1429503      714720    0  Empty
# /dev/loop4p2             708        2115         704   ef  EFI (FAT-12/16/32)

# sudo parted /dev/loop4 print

laf /dev/loop*
laf /dev/loop4*

mkdir /tmp/live1/
mkdir /tmp/live2/
sudo mount -o ro /dev/loop4p1 /tmp/live1/
# (find-fline "/tmp/live1/")
# (find-fline "/tmp/live1/boot/grub/" "efi.img")

# It seems that there is an image of the second partition in
# boot/grub/efi.img, so let's cheat...
sudo mount -o ro,loop /tmp/live1/boot/grub/efi.img /tmp/live2/
# (find-fline "/tmp/live2/")

sudo umount /tmp/live2
sudo umount /tmp/live1
sudo partx --delete   /dev/loop4
sudo losetup          /dev/loop4
sudo losetup --detach /dev/loop4
sudo losetup          /dev/loop4






#####
#
# Mounting a liveUSB image on a loop device and reading it (short version)
# 2018mai30
#
#####

# «live-build-read-short» (to ".live-build-read-short")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# This is the short version of the script in the block above.
# (find-fline "/home/live-images/" "emacs-fvwm-xfce4-lxdm-chrome.hybrid.iso")

cp -v /home/live-images/emacs-fvwm-xfce4-lxdm-chrome.hybrid.iso /tmp/myliveusb.img
sudo losetup     /dev/loop4 /tmp/myliveusb.img
sudo partx --add /dev/loop4
# partx: /dev/loop4: error adding partition 2
mkdir /tmp/live1/
mkdir /tmp/live2/
sudo mount -o ro /dev/loop4p1 /tmp/live1/
sudo mount -o ro,loop /tmp/live1/boot/grub/efi.img /tmp/live2/

# (find-fline "/tmp/live1/")
# (find-fline "/tmp/live2/")

sudo umount /tmp/live2/
sudo umount /tmp/live1/
sudo partx   --delete /dev/loop4
sudo losetup --detach /dev/loop4




#####
#
# Errors about the gpt table in a live-build pen drive
# 2018mai30
#
#####

# «live-build-gpt» (to ".live-build-gpt")

# (find-sh "sudo parted    /dev/sdb print")
# (find-sh "sudo parted -m /dev/sdb print")
# Warning: /dev/sdb contains GPT signatures, indicating that it has a GPT table.
# However, it does not have a valid fake msdos partition table, as it should.
# Perhaps it was corrupted -- possibly by a program that doesn't understand GPT
# partition tables.  Or perhaps you deleted the GPT table, and are now using an
# msdos partition table.  Is this a GPT partition table?





#####
#
# Partitioning a LiveUSB pen drive with gparted and copying files to it by hand
# 2018mai29
#
#####

# «live-build-gparted-by-hand» (to ".live-build-gparted-by-hand")
# (find-man "8 parted")
# (find-man "8 mkfs")
# (find-man "8 mkfs.ext2")
# (find-man "8 mkfs.ext3")
# (find-man "8 mkfs.ext4")
# (find-man "8 mkfs.ext4dev")
# (find-man "8 mkfs.fat")
# (find-man "8 mkfs.msdos")
# (find-man "8 mkfs.ntfs")
# (find-man "8 mkfs.vfat")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo dd if=/dev/zero of=/dev/sdb bs=1M count=10
sudo gparted /dev/sdb
# GPT partition table;
#   1: 750MB ntfs
#   2:  16MB fat16
#   3: 200MB ext2

sudo mkfs.ntfs --help
sudo mkfs.ntfs -Q /dev/sdb1
sudo mkfs.fat
sudo mkfs.fat  /dev/sdb2
sudo mkfs.ext2
sudo mkfs.ext2 /dev/sdb3

# Use this to mount /tmp/live1/ and /tmp/live2/:
# (to "live-build-read-short")

mkdir /tmp/pen1/
mkdir /tmp/pen2/
mkdir /tmp/pen3/
sudo mount /dev/sdb1 /tmp/pen1/
sudo mount /dev/sdb2 /tmp/pen2/
sudo mount /dev/sdb3 /tmp/pen3/
# (find-sh "mount")

# (find-fline "/tmp/pen1/")
# (find-fline "/tmp/pen2/")
# (find-fline "/tmp/pen3/")
sudo rm -Rfv /tmp/pen1/.*
sudo rm -Rfv /tmp/pen1/*
sudo rm -Rfv /tmp/pen2/*

# (find-fline "/tmp/live1/")
# (find-fline "/tmp/live2/")

cd /tmp/live1/ && sudo cp -av .* * /tmp/pen1/
cd /tmp/live2/ && sudo cp -av    * /tmp/pen2/
cd

sudo umount /tmp/pen1/
sudo umount /tmp/pen2/
sudo umount /tmp/pen3/
sync

# Use this to umount /tmp/live1/ and /tmp/live2/:
# (to "live-build-read-short")





#####
#
# Testing an image with QEMU
# 2018mai29
#
#####

# «live-build-test-qemu» (to ".live-build-test-qemu")
# (find-es "qemu" "pen-drive")
# Status: sort of works using "-cdrom"; pretending that the image is a
# pen drive doesn't work (yet).

# 4.6.1 Testing an ISO image with QEMU:
# file:///usr/share/doc/live-manual/html/live-manual/the-basics.en.html#218
# (find-es "qemu" "qemu-kvm")
cd /home/live/
qemu-system-x86_64 -cdrom live-image-amd64.hybrid.iso






#####
#
# Building an "hdd" image instead of the default iso-hybrid
# 2018mai19
#
#####

# «live-build-hdd» (to ".live-build-hdd")
# 4.7 Building and using an HDD image:
# file:///usr/share/doc/live-manual/html/live-manual/the-basics.en.html#233

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# sudo rm -Rfv /home/live/
# mkdire /home/live/
cd     /home/live/

# sudo lb clean --binary
sudo lb clean
sudo lb config -b hdd \
  --debian-installer-distribution        stretch \
  --distribution                         stretch \
  --parent-distribution                  stretch \
  --parent-debian-installer-distribution stretch

cd /tmp/
wget -nc https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo cp -v google-chrome*.deb /home/live/config/packages.chroot/

cd     /home/live/
sudo lb build   |& tee build2.log

# (find-fline "/home/live/build2.log")
# (find-fline "/home/live/")

# [2018-05-19 03:57:04] lb binary_disk 
# P: Begin installing disk information...
# [2018-05-19 03:57:05] lb binary_loadlin 
# [2018-05-19 03:57:05] lb binary_win32-loader 
# [2018-05-19 03:57:05] lb binary_includes 
# P: Begin copying binary includes...
# [2018-05-19 03:57:05] lb binary_hooks 
# P: Begin executing hooks...
# [2018-05-19 03:57:05] lb binary_grub-efi 
# P: Begin preparing Grub based EFI support...
# Reading package lists...
# Building dependency tree...
# Reading state information...
# E: Unable to locate package shim-signed
# E: Unable to locate package grub-efi-amd64-signed
# W: UEFI Secure Boot disabled due to missing signed Grub/Shim.
# W: Bootloader in this image type not yet supported by live-build.
# W: This would produce a not bootable image, aborting (FIXME).
# P: Begin unmounting filesystems...
# P: Saving caches...
# Reading package lists...
# Building dependency tree...
# Reading state information...

# (find-fline "/usr/lib/live/build/binary_grub-efi")
# (find-fline "/usr/lib/live/build/binary_grub-efi" "shim-signed")
# (find-fline "/usr/lib/live/build/binary_grub-efi" "a not bootable image, aborting (FIXME)")




#####
#
# How live-build invokes xorriso
# 2018mai19
#
#####

# «live-build-xorriso» (to ".live-build-xorriso")
# (find-es "cdrom" "xorriso")
# (find-livebuildgrep "grep -niH -e xorriso *")
# (find-fline "/home/live/config/binary" "LB_BOOTLOADERS")
# (find-livebuildfile "binary_iso" "IMAGE=\"${LIVE_IMAGE_NAME}-")
# (find-livebuildfile "binary_iso" "-e binary/boot/grub/efi.img")
# (find-livebuildfile "binary_iso" "xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary")

# (find-fline "/home/live/binary/")
# (find-sh "cd /home/live/binary/ && find .* * | sort")
# (find-sh "cd /home/live/binary/ && du -ch")
# (find-fline "/home/live/chroot/")
# (find-sh "cd /home/live/chroot/ && sudo find * | sort")

# (find-sh "cd /home/live/ && find .* * | sort")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
mkdir /tmp/hybridiso/
sudo mount -o loop,ro /home/live/live-image-amd64.hybrid.iso /tmp/hybridiso/
# (find-fline "/tmp/hybridiso/")
# (find-fline "/tmp/hybridiso/.disk/mkisofs")
# (find-fline "/tmp/hybridiso/.disk/mkisofs" "xorriso -as mkisofs")
# (find-sh "cd /tmp/hybridiso/ &&  find .* * | sort")
# (find-fline "/tmp/hybridiso/live/" "filesystem.squashfs")
# (find-fline "/tmp/hybridiso/isolinux/")
# (find-fline "/tmp/hybridiso/isolinux/splash.png")
cp -v /tmp/hybridiso/.disk/mkisofs /tmp/
sudo umount /tmp/hybridiso/





#####
#
# live-build
# 2018mai15
#
#####

# «live-build» (to ".live-build")
# (find-es "isolinux")

# (find-status   "live-build")
# (find-vldifile "live-build.list")
# (find-udfile   "live-build/")
# (find-man "1 lb")
# (find-man "1 lb_binary")
# (find-man "1 lb_bootstrap")
# (find-man "1 lb_build")
# (find-man "1 lb_chroot")
# (find-man "1 lb_clean")
# (find-man "1 lb_config")
# (find-man "1 lb_source")
# (find-man "1 lb_testroot")
# (find-man "7 live-build")

# (find-fline "/usr/bin/lb")
# (find-fline "/usr/bin/live-build")
# (find-fline "/usr/lib/live/build/")
# (find-fline "/usr/lib/live/build/binary_iso")



# (find-status   "live-image-lxde-desktop")
# (find-vldifile "live-image-lxde-desktop.list")
# (find-udfile   "live-image-lxde-desktop/")
# (find-status   "live-image-rescue")
# (find-vldifile "live-image-rescue.list")
# (find-udfile   "live-image-rescue/")
# (find-status   "live-image-standard")
# (find-vldifile "live-image-standard.list")
# (find-udfile   "live-image-standard/")
# (find-status   "live-image-xfce-desktop")
# (find-vldifile "live-image-xfce-desktop.list")
# (find-udfile   "live-image-xfce-desktop/")

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

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

# (find-status   "live-debconfig-doc")
# (find-vldifile "live-debconfig-doc.list")
# (find-udfile   "live-debconfig-doc/")
# (find-man "7 live-debconfig")
# (find-man "5 live-debconfig_hostname")
# (find-man "1 live-debconfig-set-selections")
# (find-man "1 live-debconfig-get-selections")

# (find-status   "live-image-lxde-desktop")
# (find-vldifile "live-image-lxde-desktop.list")
# (find-udfile   "live-image-lxde-desktop/")
# (find-fline "/usr/share/live/images/lxde-desktop/config/bootloaders/")
# (find-fline "/usr/share/live/images/lxde-desktop/config/package-lists/")

# (find-status   "live-manual-html")
# (find-vldifile "live-manual-html.list")
# (find-udfile   "live-manual-html/")
# (find-fline "/usr/share/doc/live-manual/html/live-manual/")
# file:///usr/share/doc/live-manual/html/live-manual/about-manual.en.html#7
# file:///usr/share/doc/live-manual/html/live-manual/examples.en.html
# file:///usr/share/doc/live-manual/html/live-manual/installation.en.html#installing-live-build

# (find-fline "/usr/share/live/images/")
# (find-fline "/usr/share/live/images/lxde-desktop/")
https://www.debian.org/devel/debian-live/
https://wiki.debian.org/DebianLive

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
mkdir /tmp/tutorial1/
cd    /tmp/tutorial1/
lb config

# (find-fline "/etc/live/build.conf")

sudo lb build   |& tee build.log

# (find-fline "/tmp/tutorial1/")
# (find-fline "/tmp/tutorial1/build.log")
# (find-fline "/tmp/tutorial1/chroot/var/cache/apt/archives/")
# (find-fline "/tmp/tutorial1/chroot/var/lib/apt/lists/")
# (find-fline "/tmp/tutorial1/binary/live/")

# (find-fline "/tmp/tutorial1/config/binary" "DISTRIBUTION")

# (find-es "u" "every-boot")
# emacs zsh lua5.1 git make lua-lpeg expect xpdf recode figlet
# (find-fline "/tmp/tutorial1/config/package-lists/my.list.chroot")

mkdir /tmp/tutorial1/
cd    /tmp/tutorial1/
sudo lb clean   |& tee clean.log
sudo lb build   |& tee build2.log
# (find-fline "/tmp/tutorial1/build2.log")
# (find-fline "/tmp/tutorial1/cache/packages.binary/" "emacs")

# (find-es "u" "every-boot")
# google-chrome-stable
# (find-fline "/tmp/tutorial1/config/package-lists/my.list.chroot")

mkdir /tmp/tutorial1/
cd    /tmp/tutorial1/
sudo lb clean   |& tee clean.log
sudo lb build   |& tee build3.log
# (find-fline "/tmp/tutorial1/build3.log")
# (find-fline "/tmp/tutorial1/build3.log" "Unable to locate package google-chrome-stable")
# (find-fline "/tmp/tutorial1/cache/packages.binary/" "")

# file:///usr/share/doc/live-manual/html/live-manual/customizing-package-installation.en.html#430
# (find-fline "/tmp/tutorial1/config/packages.chroot/")
# (find-es "u" "every-boot")
# (find-es "u" "every-boot" "chrome")

cd /tmp/
wget -nc https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
cp -v google-chrome*.deb /tmp/tutorial1/config/packages.chroot/


sudo umount /tmp/tutorial1/chroot/dev/pts
sudo umount /tmp/tutorial1/chroot/proc
sudo umount /tmp/tutorial1/chroot/sys

sudo rm -Rf /tmp/tutorial1/
mkdir /tmp/tutorial1/
cd    /tmp/tutorial1/
# lb config --distribution buster
lb config --distribution stretch
# (find-fline "/tmp/tutorial1/config/")
# (find-fline "/tmp/tutorial1/config/binary" "DISTRIBUTION")
sudo lb clean   |& tee clean.log
sudo lb build   |& tee build5.log


mkdir /tmp/tutorial1/
cd    /tmp/tutorial1/
sudo lb clean   |& tee clean.log
sudo lb build   |& tee build4.log
# (find-fline "/tmp/tutorial1/build4.log")


lb config




#####
#
# Installing Google Chrome in debian-live
# 2018mai15
#
#####

# «debian-live-chrome» (to ".debian-live-chrome")
# (find-es "debrepository" "debootstrap-2018")
# https://askubuntu.com/questions/824818/how-can-i-install-chromium-browser-in-live-mode
# file:///usr/share/doc/live-manual/html/live-manual/customizing-package-installation.en.html#430
# file:///usr/share/doc/live-manual/html/live-manual/customizing-package-installation.en.html#437

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo rm -Rfv /home/live/
mkdire /home/live/
cd     /home/live/

sudo lb config
sudo lb clean   |& tee clean.log
sudo lb build   |& tee build1.log


# 4.5.2 Copying an ISO hybrid image to a USB stick:
# file:///usr/share/doc/live-manual/html/live-manual/the-basics.en.html#186

cd /home/live/
sudo time \
  dd if=binary.hybrid.iso of=/dev/sdb
sync

# 4.6.1 Testing an ISO image with QEMU:
# file:///usr/share/doc/live-manual/html/live-manual/the-basics.en.html#208
# (find-es "qemu" "qemu-kvm")
cd /home/live/
qemu-system-x86_64 -cdrom binary.hybrid.iso

sudo fdisk  /dev/sdb
sudo mke2fs /dev/sdb2

# (find-fline "/usr/lib/live/build/lb_binary_iso")


sudo gparted /dev/sdb


lb config --distribution buster
sudo lb clean   |& tee clean.log
sudo lb build   |& tee build1.log
# E: Failed getting release file http://ftp.debian.org/debian/dists/belenos/Release
# http://ftp.debian.org/debian/dists/
# http://ftp.debian.org/debian/dists/buster/

# (find-fline "/home/live/build2.log")
# (find-fline "/home/live/cache/packages.binary/" "emacs")

lb config





#####
#
# debian-live-stretch
# 2018mai18
#
#####

# «debian-live-stretch» (to ".debian-live-stretch")

# (find-es "u" "every-boot")
# emacs24 emacs24-el zsh lua5.1 git make lua-lpeg expect xpdf recode figlet
# xinit fvwm
# (find-fline      "/home/live/config/package-lists/")
# (find-asrootfile "/home/live/config/package-lists/my.list.chroot")

sudo lb clean   |& tee clean.log
sudo lb build   |& tee build2.log
sudo lb build   |& tee build3.log
sudo lb build   |& tee build4.log

# (find-fline "/home/live/")
# (find-sh "cd /home/live/ && sudo find * | sort")
# (find-fline "/home/live/config/bootstrap" "LB_DISTRIBUTION")
# (find-fline "/home/live/build1.log")
# (find-fline "/home/live/build1.log" "that does not conform to ISO-9660")
# (find-fline "/home/live/build3.log")
# (find-fline "/home/live/" "binary.hybrid.iso")

[2018-05-18 01:20:46] lb_chroot_linux-image 
--2018-05-18 01:20:47--  http://ftp.debian.org/debian//dists/stretch/Contents-amd64.gz
Resolving ftp.debian.org (ftp.debian.org)... 2001:67c:2564:a119::148:12, 130.89.148.12
Connecting to ftp.debian.org (ftp.debian.org)|2001:67c:2564:a119::148:12|:80... connected.
HTTP request sent, awaiting response... 404 Not Found




#####
#
# debian-live-make-ISO
# 2018mai16
#
#####

# «debian-live-make-ISO» (to ".debian-live-make-ISO")
# file:///usr/share/doc/live-manual/html/live-manual/the-basics.en.html#171





#####
#
# Debian-live IRC channel
# 2018mai15
#
#####

# «debian-live-irc» (to ".debian-live-irc")
# «irc-channel» (to ".irc-channel")
# https://www.debian.org/devel/debian-live/
#      -> irc://irc.debian.org/debian-live
# file:///usr/share/doc/live-manual/html/live-manual.en.html#103
#      -> #debian-live channel on irc.debian.org (OFTC)

# (erc-select :server "irc.debian.org" :port 6667)
# (find-ebuffer "irc.debian.org:6667")
# (find-ebuffer "#debian-live")

# (find-eev "eev-rcirc.el")
# (find-rcirc-buffer-2a "irc.debian.org" "#debian-live" nil "#debian-live")
# (find-rcirc-buffer-3a "irc.debian.org" "#debian-live" nil "#debian-live")





#####
#
# debian-live-mailing-list
# 2018mai15
#
#####

# «debian-live-mailing-list» (to ".debian-live-mailing-list")
# «mailing-list» (to ".mailing-list")
# https://www.debian.org/devel/debian-live/ ->
# https://lists.debian.org/debian-live/











# (find-es "debrepository" "debootstrap")
# (find-es "debrepository" "debootstrap-2018")
















# (find-sh "locate ext4")
http://blog.desdelinux.net/como-instalar-linux-en-un-usb-en-forma-persistente/
http://alexsleat.co.uk/2011/02/06/howto-mount-usb-persistent-casper-rw-file-in-linux/
http://www.doudoulinux.org/web/english/documentation-7/advanced-tools/article/data-persistence.html#types
http://code.metager.de/source/xref/linux/stable/Documentation/filesystems/sharedsubtree.txt

# (find-man "8 mount")
# (find-man "8 mount" "The bind mounts")
# (find-man "8 mount" "The shared subtrees operations")
# (find-man "8 mount")

Documentation/filesystems/sharedsubtree.txt
# (find-sh "locate Documentation/filesystems/sharedsubtree.txt")










file:///usr/share/doc/live-manual/html/live-manual.en.html#downloading-prebuilt-im
file:///usr/share/doc/live-manual/html/live-manual.en.html#husing-hdd-image
file:///usr/share/doc/live-manual/html/live-manual.en.html#hapt-pinning
file:///usr/share/doc/live-manual/html/live-manual.en.html#hpersistence
file:///usr/share/doc/live-manual/html/live-manual.en.html#using-usb-extra-space

ages



http://dwm.suckless.org/





#  Local Variables:
#  coding:               utf-8-unix
#  End: