Fix #774: Don't create device-mapper mapping without subpartitions (#775)

This causes initramfs to skip calling 'kpartx' when pmOS has been
installed on an external disk (e.g. sdcard). Fixes mounting pmOS_boot
by label (#774).
This commit is contained in:
clayton craft 2017-10-20 10:20:40 -07:00 committed by Oliver Smith
parent 3ba6f372b5
commit e1cfbc4776
2 changed files with 6 additions and 15 deletions

View File

@ -1,5 +1,5 @@
pkgname=postmarketos-mkinitfs
pkgver=0.5.0
pkgver=0.5.1
pkgrel=0
pkgdesc="Tool to generate initramfs images for postmarketOS"
url="https://github.com/postmarketOS"
@ -22,5 +22,5 @@ package() {
mkdir -p "$pkgdir/etc/postmarketos-mkinitfs/hooks/"
}
sha512sums="e1849a13ee696e76dc6c734eda984bcc6a6e2e3d8a62a4df0778a8e338dc0bf9d967fa263ae6e57c14a0cb516c6004c6e251262a1711ad47f1ce4c622727a1d7 init.sh.in
e01ecaf38b0e09558812b7031451bf02afad5e3e409919d69006e2b137b7e9c578dec2d9a1de09b81c0bd360cdef66aff1b7b4e1e5873418eb7ec7a1211d4f82 init_functions.sh
d6eb7c1cd5ddf110996db1523db68a9cf13b980f25dc60a7bfc79d7c911558f46487708299bd84499ef04f61e129ab0b8186e4b1761c1479c6fec0f92232e001 init_functions.sh
3948f1f49a6d9b9817dbc4ac14f2609b10e9bd6f819b6556477d400bae0226dc64cb2702ca7afd75c10aa8917fe82622b39cbf5df94412df9bcd97d84687e245 mkinitfs.sh"

View File

@ -39,6 +39,10 @@ setup_mdev() {
}
mount_subpartitions() {
# Do not create subpartition mappings if pmOS_boot
# already exists (e.g. installed on an sdcard)
blkid |grep -q "pmOS_boot" && return
for i in /dev/mmcblk*; do
case "$(kpartx -l "$i" 2>/dev/null | wc -l)" in
2)
@ -61,19 +65,6 @@ find_root_partition() {
#
# mount_subpartitions() must get executed before calling
# find_root_partition(), so partitions from b) also get found.
#
# However, after executing mount_subpartitions(), the partitions
# from a) get mounted to /dev/mapper - and then you can only use
# the ones from /dev/mapper, not the original partition paths (they
# will appear as busy when trying to mount them). This is an
# unwanted side-effect, that we must deal with.
# The subpartitions from b) get mounted to /dev/mapper, and this is
# what we want.
#
# To deal with the side-effect, we use the partitions from
# /dev/mapper and /dev/dm-* first, and then fall back to partitions
# with all paths (in case the user inserted an SD card after
# mount_subpartitions() ran!).
# Try partitions in /dev/mapper and /dev/dm-* first
for id in pmOS_root crypto_LUKS; do