diff options
| author | John Ogness <john.ogness@linutronix.de> | 2017-09-18 16:31:17 +0200 |
|---|---|---|
| committer | John Ogness <john.ogness@linutronix.de> | 2017-09-18 16:31:17 +0200 |
| commit | 5c876f80b9a3328b33520eb51e044cbec2ebc208 (patch) | |
| tree | 56b977f8c83b84c585ee31ac528f16640062a68f | |
| parent | 0151fc2ba3bbe33484599df6ef3c49c2b152ffad (diff) | |
update scripts and README
- removed extra dd-variation scripts
- updated script for general usage (src/dest as arguments)
- adjusted script to support modifying new image
- moves /home/* from part1 to part2
- adds /home entry to /etc/fstab
- moved manut's update-home.sh to "extra" directory
(may still be in use? until a general replacement exists)
Signed-off-by: John Ogness <john.ogness@linutronix.de>
| -rw-r--r-- | lx-trainer-vm/README | 37 | ||||
| -rwxr-xr-x | lx-trainer-vm/dd-dual.sh | 53 | ||||
| -rwxr-xr-x | lx-trainer-vm/dd-multi.sh | 99 | ||||
| -rwxr-xr-x | lx-trainer-vm/dd-single.sh | 13 | ||||
| -rwxr-xr-x | lx-trainer-vm/dd.sh | 42 | ||||
| -rwxr-xr-x | lx-trainer-vm/extra/update-home.sh (renamed from lx-trainer-vm/update-home.sh) | 0 |
6 files changed, 115 insertions, 129 deletions
diff --git a/lx-trainer-vm/README b/lx-trainer-vm/README index f1c255e..67d1266 100644 --- a/lx-trainer-vm/README +++ b/lx-trainer-vm/README @@ -1,30 +1,25 @@ lx-trainer ========== -v2015-02-05 -Manuel Traut <manut@linutronix.de> +v2017-09-18 +John Ogness <john.ogness@linutronix.de> lx-trainer is our disk image for all trainings. -To build the image, a modified elbe initvm is needed. -The default disk-size of 20GB is not enough! +To build the image, elbe 2.1 or higher is needed. It is recommended to run +elbe from nereus.lab.linutronix.de because toolchain and eclipse software +are readily available via http mirror. -ELBE generates just the first partition. However the -system is configured that there is a second partition -mounted by label 'home' on '/home'. This was made to -reduce the time needed to 'dd' the image to the disks. +elbe generates all data on 1 partition (16GB in size). This image is fully +functional and has enough space for most trainings. -E.g. i added the following content for the yocto training: ----- - % ls home-overlay/devel/yocto/ - downloads pres_lx-trainer-vm.pdf pres_yocto-basic.pdf - meta-mini pres_yocto-advanced.pdf pres_yocto-intro.pdf ----- +The "dd-multi.sh" script will copy the generated training image in parallel +to multiple devices. It will also: -The dd scirpts provided here are just examples how to put -the image on (multiple) usb hard-drives and add the home -partition. They should be used as templates and need modifications -to fit on your environment. + - create and format a 2nd partition + - move /home/* to the new partition + - adjust /etc/fstab to mount the 2nd partition to /home -The update-home script is used to update just the '/home' -partition. E.g. collect the disks after the first training -day, and add some stuff for the 2nd day. +The script can be run like this: +(Only an example! Verify destination devices *before* running!) + + sudo ./dd-multi.sh lx-trainer.img /dev/sde /dev/sdf /dev/sdg diff --git a/lx-trainer-vm/dd-dual.sh b/lx-trainer-vm/dd-dual.sh deleted file mode 100755 index 1881221..0000000 --- a/lx-trainer-vm/dd-dual.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# delete mbr -dd if=/dev/zero of=/dev/sdb bs=512 count=1 -dd if=/dev/zero of=/dev/sdc bs=512 count=1 -dd if=/dev/zero of=/dev/sdd bs=512 count=1 -dd if=/dev/zero of=/dev/sde bs=512 count=1 - -sync -partprobe - -cat build/lx-trainer.img | tee \ - >(dd of=/dev/sde) \ - >(dd of=/dev/sdb) \ - >(dd of=/dev/sdc) \ - | dd of=/dev/sdd - -sync - -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdb -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdc -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdd -echo -e "n\np\n\n\n\nw" | fdisk /dev/sde -partprobe - -mkfs.ext4 -F -L lxhome /dev/sdb2 -mkfs.ext4 -F -L lxhome /dev/sdc2 -mkfs.ext4 -F -L lxhome /dev/sdd2 -mkfs.ext4 -F -L lxhome /dev/sde2 - -mount /dev/sdb2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a home-overlay/* /mnt/ -umount /mnt - -mount /dev/sdc2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a home-overlay/* /mnt/ -umount /mnt - -mount /dev/sdd2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a home-overlay/* /mnt/ -umount /mnt - -mount /dev/sde2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a home-overlay/* /mnt/ -umount /mnt diff --git a/lx-trainer-vm/dd-multi.sh b/lx-trainer-vm/dd-multi.sh new file mode 100755 index 0000000..b715681 --- /dev/null +++ b/lx-trainer-vm/dd-multi.sh @@ -0,0 +1,99 @@ +#!/bin/sh +set -e + +usage_exit() +{ + echo + echo "usage: $0 src dest [dest]..." + echo + echo "example: copying image to devs sde, sdf, sdg" + echo "$0 lx-trainer.img /dev/sde /dev/sdf /dev/sdg" + echo + exit 1 +} + +# minimum 2 arguments +if [ $# -lt 2 ]; then + echo "error: invalid arguments" + usage_exit +fi + +SRC="$1" +shift +DESTS="$@" + +# source must be file or block device +if [ ! -f "$SRC" -a ! -b "$SRC" ]; then + echo "error: invalid src" + usage_exit +fi + +# destination must be block device +for dest in $DESTS; do + if [ ! -b $dest ]; then + echo "error: invalid dest: $dest" + usage_exit + fi +done + +# check if we are root (but keep going) +if [ `id -u` -ne 0 ]; then + echo "warning: not root, may not work" +fi + +# delete mbr +for dest in $DESTS; do + dd if=/dev/zero of=$dest bs=1M count=1 & +done +wait + +partprobe + +# efficiently copy source to all destinations +cat $SRC | tee $DESTS > /dev/null + +partprobe + +# add 2nd partition +for dest in $DESTS; do + /bin/echo -e "n\np\n\n\n\nw" | fdisk $dest & +done +wait + +partprobe + +# create ext4 on 2nd partition +for dest in $DESTS; do + mkfs.ext4 -L lxhome ${dest}2 & +done +wait + +# setup temp directory for mountpoints +TMP_ROOT="/tmp/dd-multi-`date +%s`.$$" +rm -rf $TMP_ROOT +mkdir -p $TMP_ROOT +echo "using temp directory $TMP_ROOT" + +for dest in $DESTS; do + # create mountpoints + mkdir -p ${TMP_ROOT}${dest}1 + mkdir -p ${TMP_ROOT}${dest}2 + + # mount partitions + mount ${dest}1 ${TMP_ROOT}${dest}1 + mount ${dest}2 ${TMP_ROOT}${dest}2 + + # move home directories to 2nd partition + mv ${TMP_ROOT}${dest}1/home/* ${TMP_ROOT}${dest}2/ + + # setup 2nd partition to be mounted as /home + echo 'LABEL=lxhome /home ext4 defaults 0 0' | \ + tee -a ${TMP_ROOT}${dest}1/etc/fstab + + # unmount partitions + umount ${TMP_ROOT}${dest}1 + umount ${TMP_ROOT}${dest}2 +done + +# cleanup temp directory +rm -rf $TMP_ROOT diff --git a/lx-trainer-vm/dd-single.sh b/lx-trainer-vm/dd-single.sh deleted file mode 100755 index 1c17f5e..0000000 --- a/lx-trainer-vm/dd-single.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -dd if=build/lx-trainer.img of=/dev/sdb bs=5M - -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdb -partprobe - -mkfs.ext4 -F -L scratch /dev/sdb2 - -mount /dev/sdb2 /mnt -mkdir /mnt/devel -cp -a scratch/* /mnt/ -umount /mnt diff --git a/lx-trainer-vm/dd.sh b/lx-trainer-vm/dd.sh deleted file mode 100755 index 44685bc..0000000 --- a/lx-trainer-vm/dd.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -cat build/lx-trainer.img | tee \ - >(dd of=/dev/sde) \ - >(dd of=/dev/sdb) \ - >(dd of=/dev/sdc) \ - | dd of=/dev/sdd - -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdb -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdc -echo -e "n\np\n\n\n\nw" | fdisk /dev/sdd -echo -e "n\np\n\n\n\nw" | fdisk /dev/sde -partprobe - -mkfs.ext4 -F -L scratch /dev/sdb2 -mkfs.ext4 -F -L scratch /dev/sdc2 -mkfs.ext4 -F -L scratch /dev/sdd2 -mkfs.ext4 -F -L scratch /dev/sde2 - -mount /dev/sdb2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a scratch/* /mnt/ -umount /mnt - -mount /dev/sdc2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a scratch/* /mnt/ -umount /mnt - -mount /dev/sdd2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a scratch/* /mnt/ -umount /mnt - -mount /dev/sde2 /mnt -mkdir /mnt/devel -chown 1000:1000 /mnt/devel -cp -a scratch/* /mnt/ -umount /mnt diff --git a/lx-trainer-vm/update-home.sh b/lx-trainer-vm/extra/update-home.sh index 2bdbf37..2bdbf37 100755 --- a/lx-trainer-vm/update-home.sh +++ b/lx-trainer-vm/extra/update-home.sh |
