Skip to content

Instantly share code, notes, and snippets.

@pklaus
Last active February 3, 2023 01:58

Revisions

  1. pklaus revised this gist Jan 19, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,10 @@ dmesg | tail
    echo -e "\nChoose sd card (like /dev/sdX):\n"
    read SDCARD

    echo -e "\nYou chose $SDCARD\nAre you sure to continue? Press Ctrl-C to abort!"
    echo -e "\n\nCurrent partitioning of $SDCARD:\n"
    parted $SDCARD print

    echo -e "\n\nYou chose $SDCARD\nAre you sure to continue? Press Ctrl-C to abort!"
    read

    cd /tmp
  2. pklaus revised this gist Jan 19, 2018. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,11 @@ echo -e "\n\nArch Linux ARM to SD Card"
    echo -e "For the Raspberry Pi 3, if you want to use the unofficial arm64 variant."
    echo -e "(Otherwise use the Raspberry Pi 2 version of this script!)\n\n"

    if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
    fi

    echo -e "\nAll drives on this computer:\n"
    ls -1 /dev/sd?

    @@ -18,11 +23,6 @@ read SDCARD
    echo -e "\nYou chose $SDCARD\nAre you sure to continue? Press Ctrl-C to abort!"
    read

    if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
    fi

    cd /tmp

    echo -e "\nDownloading the Arch Linux ARM root filesystem (if needed):\n"
  3. pklaus revised this gist Jan 19, 2018. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,6 @@

    # <https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3>

    set -x

    echo -e "\n\nArch Linux ARM to SD Card"
    echo -e "For the Raspberry Pi 3, if you want to use the unofficial arm64 variant."
    echo -e "(Otherwise use the Raspberry Pi 2 version of this script!)\n\n"
  4. pklaus revised this gist Jan 19, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,9 @@

    set -x

    echo -e "\n\nArch Linux ARM to SD Card\n"
    echo -e "for the Raspberry Pi 3\n\n"
    echo -e "\n\nArch Linux ARM to SD Card"
    echo -e "For the Raspberry Pi 3, if you want to use the unofficial arm64 variant."
    echo -e "(Otherwise use the Raspberry Pi 2 version of this script!)\n\n"

    echo -e "\nAll drives on this computer:\n"
    ls -1 /dev/sd?
  5. pklaus revised this gist Jan 3, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -27,9 +27,9 @@ fi
    cd /tmp

    echo -e "\nDownloading the Arch Linux ARM root filesystem (if needed):\n"
    #URL=http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz
    # usually this mirror (^) is much faster than the main download server:
    URL=http://archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz
    # Sometimes the download server is slow. In that case, try a different one instead:
    #URL=http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz
    FNAME=$(basename "$URL")
    FSIZE=$(curl --head --location --silent "$URL" --write-out '%{http_code} %{size_download} \n' | tac | grep -m1 Content-Length | cut -f 2 -d' ' | tr -d '\r')
    if [ -n "$FNAME" ]
  6. pklaus revised this gist Jan 3, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ if [[ $EUID -ne 0 ]]; then
    exit 1
    fi

    #cd /tmp
    cd /tmp

    echo -e "\nDownloading the Arch Linux ARM root filesystem (if needed):\n"
    #URL=http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz
    @@ -86,4 +86,4 @@ rmdir boot root
    echo "Insert the SD card into the Raspberry Pi 2, connect ethernet, and apply 5V power."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The username/password combination is alarm/alarm. The default root password is 'root'."

    #cd -
    cd -
  7. pklaus revised this gist Feb 28, 2017. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -27,9 +27,9 @@ fi
    #cd /tmp

    echo -e "\nDownloading the Arch Linux ARM root filesystem (if needed):\n"
    #URL=http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    #URL=http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz
    # usually this mirror (^) is much faster than the main download server:
    URL=http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    URL=http://archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz
    FNAME=$(basename "$URL")
    FSIZE=$(curl --head --location --silent "$URL" --write-out '%{http_code} %{size_download} \n' | tac | grep -m1 Content-Length | cut -f 2 -d' ' | tr -d '\r')
    if [ -n "$FNAME" ]
    @@ -72,7 +72,7 @@ mount ${SDCARD}1 boot
    mount ${SDCARD}2 root

    echo -e "\nExtracting the root filesystem\n"
    bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
    bsdtar -xpf ArchLinuxARM-rpi-3-latest.tar.gz -C root
    sync

    echo -e "\nMoving boot files to the first partition\n"
  8. pklaus renamed this gist Feb 28, 2017. 1 changed file with 23 additions and 10 deletions.
    33 changes: 23 additions & 10 deletions rpi2-arch-linux-to-sdcard.sh → rpi3-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    #!/bin/bash

    # <http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2>
    # <https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3>

    set -x

    echo -e "\n\nArch Linux ARM to SD Card\n"
    echo -e "for the Raspberry Pi 2\n\n"
    echo -e "for the Raspberry Pi 3\n\n"

    echo -e "\nAll drives on this computer:\n"
    ls -1 /dev/sd?
    @@ -22,15 +24,23 @@ if [[ $EUID -ne 0 ]]; then
    exit 1
    fi

    cd /tmp

    echo "Removing any downloaded and leftover Arch Linux ARM image"
    rm ArchLinuxARM-rpi-2-latest.tar.gz
    #cd /tmp

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    wget http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    echo -e "\nDownloading the Arch Linux ARM root filesystem (if needed):\n"
    #URL=http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    # usually this mirror (^) is much faster than the main download server:
    #wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    URL=http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    FNAME=$(basename "$URL")
    FSIZE=$(curl --head --location --silent "$URL" --write-out '%{http_code} %{size_download} \n' | tac | grep -m1 Content-Length | cut -f 2 -d' ' | tr -d '\r')
    if [ -n "$FNAME" ]
    then
    CURSIZE=$(wc -c <"$FNAME")
    if [ $CURSIZE -ne $FSIZE ]; then
    rm "$FNAME"
    echo "Removing any downloaded and leftover Arch Linux ARM image"
    fi
    fi
    curl --location --remote-name --time-cond "$FNAME" "$URL"
    if [ $? -ne 0 ]; then
    echo "Could not download the image file, please check the mirror"
    exit 1
    @@ -52,6 +62,9 @@ parted -s $SDCARD unit s print
    mkfs.vfat ${SDCARD}1
    mkfs.ext4 ${SDCARD}2

    rm -rf boot
    rm -rf root

    mkdir boot
    mkdir root

    @@ -73,4 +86,4 @@ rmdir boot root
    echo "Insert the SD card into the Raspberry Pi 2, connect ethernet, and apply 5V power."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The username/password combination is alarm/alarm. The default root password is 'root'."

    cd -
    #cd -
  9. pklaus revised this gist Sep 8, 2015. 1 changed file with 12 additions and 8 deletions.
    20 changes: 12 additions & 8 deletions rpi2-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,18 @@ fi

    cd /tmp

    echo "Removing any downloaded and leftover Arch Linux ARM image"
    rm ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    wget http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    # usually this mirror (^) is much faster than the main download server:
    #wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    if [ $? -ne 0 ]; then
    echo "Could not download the image file, please check the mirror"
    exit 1
    fi

    echo -e "\nUnmounting partitions found on ${SDCARD}\n"
    for MOUNT in ${SDCARD}?
    do
    @@ -46,14 +58,6 @@ mkdir root
    mount ${SDCARD}1 boot
    mount ${SDCARD}2 root

    echo "Removing any downloaded and leftover Arch Linux ARM image"
    rm ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    wget http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    # usually this mirror (^) is much faster than the main download server:
    #wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nExtracting the root filesystem\n"
    bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
    sync
  10. pklaus revised this gist Sep 3, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion rpi2-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -64,7 +64,9 @@ mv root/boot/* boot
    echo -e "\nUnmounting the two partitions\n"
    umount boot root

    rmdir boot root

    echo "Insert the SD card into the Raspberry Pi 2, connect ethernet, and apply 5V power."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The default root password is 'root'."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The username/password combination is alarm/alarm. The default root password is 'root'."

    cd -
  11. pklaus revised this gist Sep 3, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion rpi2-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,9 @@ echo "Removing any downloaded and leftover Arch Linux ARM image"
    rm ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    wget http://de7.mirror.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
    # usually this mirror (^) is much faster than the main download server:
    #wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nExtracting the root filesystem\n"
    bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
  12. pklaus revised this gist Aug 3, 2015. No changes.
  13. pklaus revised this gist Aug 3, 2015. No changes.
  14. pklaus renamed this gist Aug 3, 2015. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions arch-linux-to-sdcard.sh → rpi2-arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    #!/bin/bash

    # <http://archlinuxarm.org/platforms/armv6/raspberry-pi>
    # <http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2>

    echo -e "\n\nArch Linux ARM for Raspberry Pi to SD Card\n\n"
    echo -e "\n\nArch Linux ARM to SD Card\n"
    echo -e "for the Raspberry Pi 2\n\n"

    echo -e "\nAll drives on this computer:\n"
    ls -1 /dev/sd?
    @@ -46,13 +47,13 @@ mount ${SDCARD}1 boot
    mount ${SDCARD}2 root

    echo "Removing any downloaded and leftover Arch Linux ARM image"
    rm ArchLinuxARM-rpi-latest.tar.gz
    rm ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
    wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

    echo -e "\nExtracting the root filesystem\n"
    bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
    bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
    sync

    echo -e "\nMoving boot files to the first partition\n"
    @@ -61,7 +62,7 @@ mv root/boot/* boot
    echo -e "\nUnmounting the two partitions\n"
    umount boot root

    echo "Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power."
    echo "Insert the SD card into the Raspberry Pi 2, connect ethernet, and apply 5V power."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The default root password is 'root'."

    cd -
  15. pklaus revised this gist Dec 17, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -45,6 +45,9 @@ mkdir root
    mount ${SDCARD}1 boot
    mount ${SDCARD}2 root

    echo "Removing any downloaded and leftover Arch Linux ARM image"
    rm ArchLinuxARM-rpi-latest.tar.gz

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz

  16. pklaus revised this gist Dec 17, 2014. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    echo -e "\n\nArch Linux ARM for Raspberry Pi to SD Card\n\n"

    echo -e "\nAll drives on this computer:\n"
    ls /dev/sd?
    ls -1 /dev/sd?

    echo -e "\nLast messages in syslog:\n"
    dmesg | tail
    @@ -23,8 +23,12 @@ fi

    cd /tmp

    echo -e "\nUnmounting $(ls $SDCARD*)\n"
    umount ${SDCARD}*
    echo -e "\nUnmounting partitions found on ${SDCARD}\n"
    for MOUNT in ${SDCARD}?
    do
    echo $MOUNT
    umount $MOUNT
    done

    parted -s $SDCARD unit s print
    parted -s $SDCARD mktable msdos
    @@ -57,3 +61,4 @@ umount boot root
    echo "Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The default root password is 'root'."

    cd -
  17. pklaus revised this gist Dec 16, 2014. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,15 @@

    # <http://archlinuxarm.org/platforms/armv6/raspberry-pi>

    echo -e "\n\nArch Linux ARM for Raspberry Pi to SD Card\n\n"

    echo -e "\nAll drives on this computer:\n"
    ls /dev/sd?

    echo -e "\nLast messages in syslog:\n"
    dmesg | tail

    echo -e "\nChoose sd card:\n"
    echo -e "\nChoose sd card (like /dev/sdX):\n"
    read SDCARD

    echo -e "\nYou chose $SDCARD\nAre you sure to continue? Press Ctrl-C to abort!"
    @@ -40,15 +42,16 @@ mount ${SDCARD}1 boot
    mount ${SDCARD}2 root

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    #wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
    echo -e "\nExtracting the root filesystem:\n"
    wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz

    echo -e "\nExtracting the root filesystem\n"
    bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
    sync

    echo -e "\nMoving boot files to the first partition:\n"
    echo -e "\nMoving boot files to the first partition\n"
    mv root/boot/* boot

    echo -e "\nUnmounting the two partitions:\n"
    echo -e "\nUnmounting the two partitions\n"
    umount boot root

    echo "Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power."
  18. pklaus created this gist Dec 16, 2014.
    56 changes: 56 additions & 0 deletions arch-linux-to-sdcard.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    #!/bin/bash

    # <http://archlinuxarm.org/platforms/armv6/raspberry-pi>

    echo -e "\nAll drives on this computer:\n"
    ls /dev/sd?

    echo -e "\nLast messages in syslog:\n"
    dmesg | tail

    echo -e "\nChoose sd card:\n"
    read SDCARD

    echo -e "\nYou chose $SDCARD\nAre you sure to continue? Press Ctrl-C to abort!"
    read

    if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
    fi

    cd /tmp

    echo -e "\nUnmounting $(ls $SDCARD*)\n"
    umount ${SDCARD}*

    parted -s $SDCARD unit s print
    parted -s $SDCARD mktable msdos
    parted -s $SDCARD mkpart primary fat32 8192s 128MiB
    parted -s $SDCARD mkpart primary 128MiB 100%
    parted -s $SDCARD unit s print

    mkfs.vfat ${SDCARD}1
    mkfs.ext4 ${SDCARD}2

    mkdir boot
    mkdir root

    mount ${SDCARD}1 boot
    mount ${SDCARD}2 root

    echo -e "\nDownloading the Arch Linux ARM root filesystem:\n"
    #wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
    echo -e "\nExtracting the root filesystem:\n"
    bsdtar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
    sync

    echo -e "\nMoving boot files to the first partition:\n"
    mv root/boot/* boot

    echo -e "\nUnmounting the two partitions:\n"
    umount boot root

    echo "Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power."
    echo "Use the serial console or SSH to the IP address given to the board by your router. The default root password is 'root'."