User:Quozl/Remastering

From OLPC
< User:Quozl
Revision as of 05:33, 19 November 2011 by Quozl (talk | contribs) (Created page with 'Remastering a .zd4 file without having to make a build. Useful for XO-1.75 when no ARM build machinery is on your side of a slow pipe. <pre> # the build number we are basing on…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Remastering a .zd4 file without having to make a build. Useful for XO-1.75 when no ARM build machinery is on your side of a slow pipe.

# the build number we are basing on
BUILD=11
IMAGE=os$BUILD.img

# convert the .zd file into a disk image
zdextract < os$BUILD.zd4 > $IMAGE

# build a random fill pattern for later use
dd if=/dev/urandom of=$IMAGE.fill bs=4096 count=1 2>/dev/null

# dump the partition table in case it ever changes
parted $IMAGE "unit B print"

# connect the partitions to loopback block devices
losetup -o 4194304 /dev/loop0 $IMAGE
losetup -o 71303168 /dev/loop1 $IMAGE

# mount the two filesystems
mkdir -p /mnt/root /mnt/boot
mount /dev/loop1 /mnt/root
mount /dev/loop0 /mnt/boot
ROOT=/mnt/root/versions/run/$BUILD/
USER=/mnt/root/home/olpc/

# provide local kernel
rsync -av /tmp/xo/bootpart/boot/* /mnt/boot/boot/
rsync -av /tmp/xo/lib/modules ${ROOT}/lib/

# force initial runin
# rm -f $ROOT/runin/runin-fscheck
# touch $ROOT/runin/quick

# open to your key
SSH_CONFIG=/mnt/root/home/root/.ssh
mkdir --mode=g-rwx,o-rwx $SSH_CONFIG
cat << EOF > $SSH_CONFIG/authorized_keys
(put your key here)
EOF
chmod o-rwx,g-rwx $SSH_CONFIG/authorized_keys

# save some space and therefore time
rm -rf $USER/Activities/Wikipedia*
rm -rf $USER/Activities/Scratch*
rm -rf $USER/Library/*

# enable sshd on start
cat <<EOF > $ROOT/etc/rc.local
#!/bin/sh
touch /var/lock/subsys/local
if [[ ! -f /etc/rc.local.quozl ]]; then
    service sshd start
    chkconfig sshd on
    touch /etc/rc.local.quozl
fi
(sleep 13 && touch /var/run/powerd-inhibit-suspend/1) < /dev/null > /dev/null &
EOF
chmod +x $ROOT/etc/rc.local

# reduce powerd enthusiasm
cat <<EOF >> $ROOT/etc/powerd/powerd.conf
config_PLUGGED_TIME_DIM="15"
config_PLUGGED_TIME_BLANK="30"
config_PLUGGED_TIME_SLEEP="3600"
EOF

# associate to local wireless
mkdir -p $USER/.sugar/default/nm/
chown -R 500:500 $USER/.sugar
cat <<EOF > $USER/.sugar/default/nm/connections.cfg
[Auto qz]
type = 802-11-wireless
ssid = qz
uuid = 757dc7687efb4e7250f4eb6697568482ae948526
autoconnect = True
timestamp = 1321510400

EOF

# dismount the filesystem
umount /mnt/boot
umount /mnt/root
rmdir /mnt/root /mnt/boot

# fill the free blocks, to ensure sparse output
fill-free-blocks -v /dev/loop0 $IMAGE.fill
until losetup -d /dev/loop0; do sleep 0.1; done
fill-free-blocks -v /dev/loop1 $IMAGE.fill
until losetup -d /dev/loop1; do sleep 0.1; done

# compress back to .zd format
zhashfs 0x20000 sha256 $IMAGE fs.zsp fs.zd