aboutsummaryrefslogtreecommitdiffstats
path: root/initramfs-init.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-10-27 09:54:59 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-10-27 12:11:47 +0000
commit60821c8ba0118d231cd3b4fd008cd42868337439 (patch)
treeffd55ee5d0fe934410936e579a20fde0da32f408 /initramfs-init.in
parent33efee8d373c7b58402305ce3149905708135b9f (diff)
downloadmkinitfs-60821c8ba0118d231cd3b4fd008cd42868337439.tar.bz2
mkinitfs-60821c8ba0118d231cd3b4fd008cd42868337439.tar.xz
init: try detect alpine_dev filesystem if not specified
Note that ext4 will be detected as ext3
Diffstat (limited to 'initramfs-init.in')
-rwxr-xr-xinitramfs-init.in22
1 files changed, 21 insertions, 1 deletions
diff --git a/initramfs-init.in b/initramfs-init.in
index 0e30137..7c477c7 100755
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -255,6 +255,20 @@ relocate_alpine_mnt() {
fi
}
+# detect filesystem type on given device/UUID
+find_fs_type() {
+ local dev=$(findfs $1)
+ local i=
+ for i in $(blkid $dev); do
+ case $i in
+ TYPE=*) eval "$i"
+ echo $TYPE
+ return
+ ;;
+ esac
+ done
+}
+
# gotta start from somewhere :)
echo "Alpine Init $VERSION"
@@ -314,7 +328,7 @@ case "$ALPINE_DEV" in
UUID=*|LABEL=*) ;;
*) ALPINE_DEV=/dev/$ALPINE_DEV ;;
esac
-
+
# look for standard mountpoint locations
ALPINE_MNT=$(find_mnt $ALPINE_DEV /etc/fstab)
[ -z "$ALPINE_MNT" ] && ALPINE_MNT=/media/${ALPINE_DEV##*/}
@@ -398,6 +412,12 @@ start_lvm
# locate boot media and mount it
ebegin "Mounting boot media"
mkdir -p $ALPINE_MNT
+
+# try detect the filesystem
+if [ -z "$ALPINE_DEV_FS" ]; then
+ ALPINE_DEV_FS=$(find_fs_type $ALPINE_DEV)
+fi
+
if [ -n "$ALPINE_DEV_FS" ]; then
mount_opts="-t $ALPINE_DEV_FS"
fi