diff options
author | Andrew Cady <d@jerkface.net> | 2023-06-21 23:53:06 -0400 |
---|---|---|
committer | u <u@billy> | 2023-11-17 08:44:10 -0500 |
commit | 069b67461cc33d373d030b87744e11ea87fe927e (patch) | |
tree | 596a982f313910e341d32f788598d2a9972450ed /src/initrd/btrfs-create.sh | |
parent | 191905e493e680dc8a36bce7d28d7e912d2e98bd (diff) |
correct counting of btrfs filesystem devices
Diffstat (limited to 'src/initrd/btrfs-create.sh')
-rw-r--r-- | src/initrd/btrfs-create.sh | 12 |
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 | ||
236 | num_devices() | ||
237 | { | ||
238 | btrfs inspect-internal dump-super "$1" | sed -ne 's/^num_devices\t\t*//p' | ||
239 | } | ||
240 | |||
236 | filesystem_incomplete() | 241 | filesystem_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 | ||
243 | partition_new_hard_drive_DESTROYING_EVERYTHING() | 246 | partition_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 |