diff --git a/build.sh b/build.sh index b5ebe90..79193f0 100755 --- a/build.sh +++ b/build.sh @@ -38,7 +38,8 @@ fi # the absolute minimum for extroot to work at all (i.e. when the disk is already set up, for example by hand). # this list may be smaller and/or different for your router, but it works with my ath79. -PREINSTALLED_PACKAGES="block-mount kmod-fs-ext4 kmod-usb-storage" +# blockdev is needed to re-read the partition table using `blockdev --rereadpt /dev/sdX` +PREINSTALLED_PACKAGES="block-mount kmod-fs-ext4 kmod-usb-storage blockdev" # some kernel modules may also be needed for your hardware #PREINSTALLED_PACKAGES+=" kmod-usb-uhci kmod-usb-ohci" diff --git a/image-extras/common/root/autoprovision-stage1.sh b/image-extras/common/root/autoprovision-stage1.sh index 85b57f3..55b5385 100755 --- a/image-extras/common/root/autoprovision-stage1.sh +++ b/image-extras/common/root/autoprovision-stage1.sh @@ -31,14 +31,24 @@ hasBigEnoughPendrive() fi } +rereadPartitionTable() +{ + log "Rereading partition table" + blockdev --rereadpt /dev/sda +} + setupPendrivePartitions() { + log "Erasing partition table" # erase partition table dd if=/dev/zero of=/dev/sda bs=1M count=1 + rereadPartitionTable + + log "Creating partitions" # sda1 is 'swap' # sda2 is 'root' - # sda3 is 'data' + # sda3 is 'data', if there's any space left fdisk /dev/sda <<EOF o n @@ -64,7 +74,7 @@ q EOF log "Finished partitioning /dev/sda using fdisk" - sleep 2 + rereadPartitionTable until [ -e /dev/sda1 ] do @@ -76,6 +86,7 @@ EOF mkfs.ext4 -F -L root -U $rootUUID /dev/sda2 mkfs.ext4 -F -L data -U $dataUUID /dev/sda3 + rereadPartitionTable log "Finished setting up filesystems" }