0095-x86-fix-sysupgrades-on-disks-with-4k-block-size.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Wed, 25 Jan 2017 08:13:11 +0100
  3. Subject: x86: fix sysupgrades on disks with 4k block size
  4. Even when the disk uses 4k blocks, the partition table still uses units
  5. of 512 byte sectors. Always use ibs=512 for the offsets
  6. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  7. Backport of LEDE e9ecb228c9d80605884058d7653e2eb56ba64051
  8. diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
  9. index 8850917062618985126b5086dccfe11506ed1fbb..d3e9f360aadedad0995da55205364940c9884ba4 100644
  10. --- a/target/linux/x86/base-files/lib/upgrade/platform.sh
  11. +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
  12. @@ -21,20 +21,13 @@ platform_copy_config() {
  13. }
  14. platform_do_upgrade() {
  15. - local diskdev partdev ibs diff
  16. + local diskdev partdev diff
  17. if export_bootdevice && export_partdevice diskdev 0; then
  18. sync
  19. if [ "$SAVE_PARTITIONS" = "1" ]; then
  20. get_partitions "/dev/$diskdev" bootdisk
  21. - #get block size
  22. - if [ -f "/sys/block/$diskdev/queue/physical_block_size" ]; then
  23. - ibs="$(cat "/sys/block/$diskdev/queue/physical_block_size")"
  24. - else
  25. - ibs=512
  26. - fi
  27. -
  28. #extract the boot sector from the image
  29. get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
  30. @@ -54,7 +47,7 @@ platform_do_upgrade() {
  31. while read part start size; do
  32. if export_partdevice partdev $part; then
  33. echo "Writing image to /dev/$partdev..."
  34. - get_image "$@" | dd of="/dev/$partdev" ibs="$ibs" obs=1M skip="$start" count="$size" conv=fsync
  35. + get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
  36. else
  37. echo "Unable to find partition $part device, skipped."
  38. fi