pileogoo/scripts/extract_root.sh

14 lines
343 B
Bash
Raw Normal View History

2021-12-18 20:56:45 +00:00
#!/bin/bash
TMPDIR=$(mktemp -d)
losetup -Pf rpi.img
LODEVICE=$(losetup -j rpi.img | cut -d ':' -f 1)
mount "${LODEVICE}p2" "${TMPDIR}"
tar -C "${TMPDIR}" -czf root.tar.gz .
mount "${LODEVICE}p1" "${TMPDIR}/boot"
tar -C "${TMPDIR}/boot" -czf boot.tar.gz .
umount "${TMPDIR}/boot"
umount "${TMPDIR}"
rm -rf "${TMPDIR}"
losetup -D "${LODEVICE}"