Skip to content

Commit 2842de0

Browse files
sashasimkinigorpecovnik
authored andcommitted
bugfix: use --nodeps instead of | head -1 in lsblk calls for predictable output
for some reason lsblk order for -o X is different between EMMC and NVME see #8805 (comment)
1 parent b47445c commit 2842de0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/bsp/common/usr/lib/armbian/armbian-resize-filesystem

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ do_expand_partition()
1717
echo -e "\n### [resize2fs] Trying to resize partition $partdev:\n"
1818

1919
# make sure the target is a partition
20-
local parttype=$(lsblk -n -o TYPE $partdev | head -1)
20+
local parttype=$(lsblk -n -d -o TYPE $partdev)
2121
if [[ "$parttype" != "part" ]]; then
2222
echo -e "\n$partdev isn't a partition: $parttype" >&2
2323
return 1
2424
fi
2525

26-
local diskdevname=$(lsblk -n -o PKNAME $partdev | head -1) # i.e. mmcblk0 or sda
26+
local diskdevname=$(lsblk -n -d -o PKNAME $partdev) # i.e. mmcblk0 or sda
2727
# due to the bug in util-linux 2.34 which fails to show device, let's use this failover:
2828
[[ -z $diskdevname ]] && diskdevname=$(echo $partdev | sed -e "s/^\/dev\///" | sed "s/p.*//")
2929
local diskdev="/dev/$diskdevname" # i.e. /dev/mmcblk0, /dev/sda
@@ -166,7 +166,7 @@ do_expand_partition()
166166
touch /var/run/resize2fs-reboot
167167
fi
168168

169-
local partsize=$(lsblk -n -b -o SIZE $partdev | head -1)
169+
local partsize=$(lsblk -n -d -b -o SIZE $partdev)
170170
local actualsize=$(( $sectorsize * ($lastsector - $partstart + 1) ))
171171
if [[ $actualsize -ne $partsize ]]; then
172172
echo -e "\n### [resize2fs] Automated reboot needed to finish the resize procedure"
@@ -183,7 +183,7 @@ do_resize_crypt()
183183
{
184184
local dev=$1
185185
local parentdev=$2
186-
local name=$(lsblk -n -o NAME $dev | head -1) # i.e. armbian-root
186+
local name=$(lsblk -n -d -o NAME $dev) # i.e. armbian-root
187187

188188
echo -e "\n### [resize2fs] Start resizing LUKS container now\n"
189189
# It's probably no need to run 'cryptsetup resize'.
@@ -196,7 +196,7 @@ do_resize_crypt()
196196
cryptsetup resize "$name"
197197
fi
198198

199-
local parentsize=$(lsblk -n -b -o SIZE $parentdev | head -1)
199+
local parentsize=$(lsblk -n -d -b -o SIZE $parentdev)
200200

201201
local sectorsize=$(cryptsetup status $name | awk -F':' '/^ *sector size/ {print $2}' | tr -c -d '[:digit:]')
202202
local offset=$(cryptsetup status $name | awk -F':' '/^ *offset/ {print $2}' | tr -c -d '[:digit:]')
@@ -243,7 +243,7 @@ do_expand_filesystem()
243243
esac
244244

245245
# check whether reboot is necessary for resize2fs to take effect
246-
local devsize=$(lsblk -n -b -o SIZE $partdev | head -1)
246+
local devsize=$(lsblk -n -d -b -o SIZE $partdev)
247247
local fssize=$(findmnt -n -b -o SIZE --target $mountpoint)
248248
if [[ $(( 100 * $fssize / $devsize )) -lt 90 ]]; then
249249
echo -e "\n### [resize2fs] Automated reboot needed to finish the resize procedure"
@@ -272,8 +272,8 @@ main()
272272

273273
# check for crypt
274274
local cryptname=""
275-
if [[ "$(lsblk -n -o TYPE $rootdev | head -1)" == "crypt" ]]; then
276-
local cryptname=$(lsblk -n -o NAME $rootdev | head -1) # i.e. armbian-root
275+
if [[ "$(lsblk -n -d -o TYPE $rootdev)" == "crypt" ]]; then
276+
local cryptname=$(lsblk -n -d -o NAME $rootdev) # i.e. armbian-root
277277
local parent_uuid=$(cat /etc/crypttab | awk "{if(\$1 == \"$cryptname\"){print \$2}}" | sed 's/UUID=//')
278278
local parentdev=$(blkid -U $parent_uuid) # i.e. /dev/mmcblk0p1 or /dev/sda1
279279

0 commit comments

Comments
 (0)