Skip to content

Commit

Permalink
add initramfs_pack and initramfs_unpack to copied files to the live OS
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas-M committed Jan 21, 2023
1 parent 951ad84 commit 5787075
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions Slax/slackware15/modules/01-core/rootcopy/usr/bin/initramfs_pack
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "" ]; then
echo ""
echo "Create initramfs image from a tmpfs-mounted directory tree"
echo "Usage: $0 [source_directory]"
echo ""
exit 2
fi

IMG="$(readlink -f "$1")"
touch "$IMG.2" # ends if error

(cd "$IMG"; find . -print | cpio -o -H newc 2>/dev/null) | xz -T0 -f --extreme --check=crc32 >"$IMG.2"
umount "$IMG"
rmdir "$IMG"
mv "$IMG.2" "$IMG"
20 changes: 20 additions & 0 deletions Slax/slackware15/modules/01-core/rootcopy/usr/bin/initramfs_unpack
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "" ]; then
echo ""
echo "Unpack initramfs image so it becomes a directory"
echo "Usage: $0 [source_initramfs_file.img]"
echo ""
exit 2
fi

IMG="$(readlink -f "$1")"

mv "$IMG" "$IMG.2"
mkdir -p "$IMG"
mount -t tmpfs tmpfs "$IMG"

(cd "$IMG"; xz -d | cpio -idv >/dev/null 2>&1) < "$IMG.2"
rm "$IMG.2"

0 comments on commit 5787075

Please sign in to comment.