From 0643c3638d0684231ee800e35fd171c008551745 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Thu, 30 Apr 2020 09:49:55 +0200 Subject: [PATCH] Implemented copying --- README.md | 17 +++++++++-------- sd_setup.sh | 12 +++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e0aef4a..95c8eb7 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,15 @@ To install a Linux distribution manually on a SD card type in: To pase the configuration to the program use this syntax: ```bash ( - echo "$USER" # The username - echo "mmcblk1" # The device - echo "3" # The raspberry pi number - echo "arch" # The operation system - echo "y" # Transfer image - echo "user_password" # The user password - echo "root_password" # The root password - echo "y" # Copy wifi configurations to target system + echo "$USER" # | The username + echo "mmcblk1" # | The device + echo "3" # | The raspberry pi number + echo "arch" # | The operation system + echo "y" # | Transfer image + echo "n" # ├── Overwrite device before copying + echo "user_password" # | The user password + echo "root_password" # | The root password + echo "y" # | Copy wifi configurations to target system )| sudo bash ./sd_setup.sh ``` diff --git a/sd_setup.sh b/sd_setup.sh index 9f0f8de..d31e676 100644 --- a/sd_setup.sh +++ b/sd_setup.sh @@ -175,6 +175,16 @@ mount_partitions(){ echo "Should the image be transfered to $sd_card_path?(y/n)" && read -r transfer_image if [ "$transfer_image" = "y" ] then + + echo "Should $sd_card_path be overwritten with zeros before copying?(y/n)" && read -r copy_zeros_to_device + if [ "$copy_zeros_to_device" = "y" ] + then + echo "Overwritting..." + dd if=/dev/zero of="$sd_card_path" bs=1M || error "Overwritting $sd_card_path failed." + else + echo "Skipping Overwritting..." + fi + echo "Starting image transfer..." case "$os" in "arch") @@ -194,7 +204,7 @@ if [ "$transfer_image" = "y" ] echo "" #and then press ENTER twice to accept the default first and last sector. echo "" echo "w" #Write the partition table and exit by typing w. - )| fdisk "$sd_card_path" || error "Creating partitions failed. Try \"sudo dd if=/dev/zero of=$sd_card_path bs=1M\"" + )| fdisk "$sd_card_path" || error "Creating partitions failed. Try to execute this script with the overwritting parameter." echo "Format boot partition..." mkfs.vfat "$boot_partition_path" || error "Format boot is not possible."