summaryrefslogtreecommitdiffstats
path: root/initramfs
diff options
context:
space:
mode:
authorRobert "ar" Gerus <ar@bash.org.pl>2013-04-30 05:24:09 +0200
committerRobert "ar" Gerus <ar@bash.org.pl>2013-04-30 05:24:09 +0200
commitfaaf03e081b1dc455e803b0411fffbeb183fe3db (patch)
tree34370f03d571cc239479688c2d9e5881cf32744d /initramfs
parent5f2e7203af404afe4083eff0675c755e27b6d074 (diff)
downloadtar-xz-loading-initramfs-faaf03e081b1dc455e803b0411fffbeb183fe3db.tar.gz
tar-xz-loading-initramfs-faaf03e081b1dc455e803b0411fffbeb183fe3db.tar.bz2
tar-xz-loading-initramfs-faaf03e081b1dc455e803b0411fffbeb183fe3db.zip
v0.4 - Now with README!
Diffstat (limited to 'initramfs')
-rw-r--r--initramfs/bin/.gitignore2
-rw-r--r--initramfs/dev/.gitignore2
-rwxr-xr-xinitramfs/init115
-rw-r--r--initramfs/mnt/.gitignore2
-rw-r--r--initramfs/proc/.gitignore2
-rw-r--r--initramfs/roottmpfs/.gitignore2
-rw-r--r--initramfs/sbin/.gitignore2
7 files changed, 127 insertions, 0 deletions
diff --git a/initramfs/bin/.gitignore b/initramfs/bin/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/initramfs/bin/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/initramfs/dev/.gitignore b/initramfs/dev/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/initramfs/dev/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/initramfs/init b/initramfs/init
new file mode 100755
index 0000000..8286f69
--- /dev/null
+++ b/initramfs/init
@@ -0,0 +1,115 @@
+#!/busybox sh
+
+die() {
+ echo ""
+ echo "Shit broke! Panic shell!"
+ echo ""
+ /busybox --install -s
+ exec /bin/sh
+}
+
+
+info() {
+ echo -n "-|-" ${@} "... "
+}
+
+isok() {
+ if [[ $1 -eq 0 ]]; then
+ echo "[ OK ]"
+ else
+ echo "[ FUCK ]"
+ die
+ fi
+}
+
+info "disabling console blanking, hopefully"
+echo -e '\033[9;0]\033[14;0]' > /dev/console
+
+info "waiting for usb devices to settle"
+echo ""
+for i in 10 9 8 7 6 5 4 3 2 1 0; do
+ echo -en ${i}'\r'
+ /busybox sleep 1
+done
+echo ""
+isok 0
+
+info "mounting devtmpfs"
+/busybox mount -n -t devtmpfs devtmpfs ./dev
+isok $?
+
+info "mounting proc"
+/busybox mount -n -t proc proc ./proc
+isok $?
+
+# rootfs_location_uuid=f822d881-d88a-4200-a9cf-6986c5a3e69a
+info "looking for device with rootfs"
+for var in $(cat /proc/cmdline); do
+ if [[ ${var/=*} = rootfs_location_uuid ]]; then
+ uuid="${var/*=}"
+ fi
+done
+device=$(findfs UUID=${uuid})
+isok $?
+
+# rootfs_filename=rootfs.tar.xz
+info "getting rootfs filename"
+for var in $(cat /proc/cmdline); do
+ if [[ ${var/=*} = rootfs_filename ]]; then
+ filename="${var/*=}"
+ fi
+done
+if [[ -z ${filename} ]]; then
+ info "going with default: rootfs.tar.xz"
+ filename="rootfs.tar.xz"
+fi
+isok 0
+
+info "getting root tmpfs size"
+for var in $(cat /proc/cmdline); do
+ if [[ ${var/=*} = rootfs_size ]]; then
+ size=${var/*=}
+ fi
+done
+if [[ -z ${size} ]]; then
+ info "going with default: 4G"
+ size="4G"
+fi
+isok 0
+
+info "trying to mount ${device}"
+/busybox mount -n -o ro ${device} /mnt
+isok $?
+
+info "trying to mount root tmpfs"
+/busybox mount -n -o size=${size} -t tmpfs roottmpfs /roottmpfs
+isok $?
+
+info "checking if ${filename} exists"
+[[ -e /mnt/${filename} ]]
+isok $?
+
+info "unpacking; will take some time"
+/pv /mnt/${filename} | /busybox tar -C /roottmpfs -xJf -
+
+info "unmounting rootfs package location"
+/busybox umount -n /mnt
+isok $?
+
+info "unmounting /dev"
+/busybox umount -n /dev
+isok $?
+
+info "unmounting /proc"
+/busybox umount -n /proc
+isok $?
+
+info "trying to switch root"
+exec /busybox switch_root /roottmpfs /sbin/init
+
+echo ""
+echo "we should not reach this place! here be dragons!"
+echo ""
+
+die
+
diff --git a/initramfs/mnt/.gitignore b/initramfs/mnt/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/initramfs/mnt/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/initramfs/proc/.gitignore b/initramfs/proc/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/initramfs/proc/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/initramfs/roottmpfs/.gitignore b/initramfs/roottmpfs/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/initramfs/roottmpfs/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/initramfs/sbin/.gitignore b/initramfs/sbin/.gitignore
new file mode 100644
index 0000000..d6b7ef3
--- /dev/null
+++ b/initramfs/sbin/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore