summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-06-21 23:53:06 -0400
committeru <u@billy>2023-11-17 08:44:10 -0500
commit069b67461cc33d373d030b87744e11ea87fe927e (patch)
tree596a982f313910e341d32f788598d2a9972450ed
parent191905e493e680dc8a36bce7d28d7e912d2e98bd (diff)
correct counting of btrfs filesystem devices
-rw-r--r--src/initrd/btrfs-create.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh
index 5a43977..efd8728 100644
--- a/src/initrd/btrfs-create.sh
+++ b/src/initrd/btrfs-create.sh
@@ -233,11 +233,14 @@ choose_uuid()
233 uniq | sort -nr | head -n1 | (read _ x; echo $x) 233 uniq | sort -nr | head -n1 | (read _ x; echo $x)
234} 234}
235 235
236num_devices()
237{
238 btrfs inspect-internal dump-super "$1" | sed -ne 's/^num_devices\t\t*//p'
239}
240
236filesystem_incomplete() 241filesystem_incomplete()
237{ 242{
238 local n 243 [ "$(num_devices "$1")" != 1 ]
239 n=$(btrfs filesystem show "$1" | sed -ne 's/.*Total devices \([^ ]*\) .*/\1/p')
240 [ "$n" != 1 ]
241} 244}
242 245
243partition_new_hard_drive_DESTROYING_EVERYTHING() 246partition_new_hard_drive_DESTROYING_EVERYTHING()
@@ -276,8 +279,7 @@ open_samizdat()
276 btrfs device scan -u || true 279 btrfs device scan -u || true
277 if ! btrfs device scan || ! btrfs device ready "$blockdev" 280 if ! btrfs device scan || ! btrfs device ready "$blockdev"
278 then 281 then
279 devcount=$(btrfs inspect-internal dump-super "$blockdev" | grep -c dev_item.devid) 282 if ! filesystem_incomplete "$blockdev"
280 if [ "$devcount" -eq 1 ]
281 then 283 then
282 btrfstune -m "$blockdev" 284 btrfstune -m "$blockdev"
283 btrfs device ready "$blockdev" || : get used to disappointment 285 btrfs device ready "$blockdev" || : get used to disappointment