The script seems not to work in ubuntu 16.04 it gives this error
`sudo ./build_raspbian_sd_card.sh
no block device given, just creating an image
3800+0 records in
3800+0 records out
3800000000 bytes (3.8 GB, 3.5 GiB) copied, 54.2209 s, 70.1 MB/s
image /home/fcon/Gits/build-raspbian-image/rpi/images/raspbian_basic_wheezy_20160916.img created and mounted as /dev/loop6
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognised partition table.
Created a new DOS disklabel with disk identifier 0x4b0b0740.
Command (m for help): Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): Partition number (1-4, default 1): First sector (2048-7421874, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-7421874, default 7421874):
Created a new partition 1 of type 'Linux' and of size 64 MiB.
Command (m for help): Selected partition 1
Partition type (type L to list all types): Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
Command (m for help): Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): Partition number (2-4, default 2): First sector (133120-7421874, default 133120): Last sector, +sectors or +size{K,M,G,T,P} (133120-7421874, default 7421874):
Created a new partition 2 of type 'Linux' and of size 3.5 GiB.
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
mkfs.fat 3.0.28 (2015-05-16)
/dev/mapper/loop6p1: No such file or directory
mke2fs 1.42.13 (17-May-2015)
The file /dev/mapper/loop6p2 does not exist and no size was specified.
mount: special device /dev/mapper/loop6p2 does not exist
/usr/sbin/debootstrap: 1368: /usr/sbin/debootstrap: cannot create /home/fcon/Gits/build-raspbian-image/rpi/rootfs/test-dev-null: Permission denied
E: Cannot install into target '/home/fcon/Gits/build-raspbian-image/rpi/rootfs' mounted with noexec or nodev
cp: cannot create regular file 'usr/bin/': Not a directory
chroot: failed to run command '/debootstrap/debootstrap': No such file or directory
mount: mount point /home/fcon/Gits/build-raspbian-image/rpi/rootfs/boot does not exist
./build_raspbian_sd_card.sh: line 178: etc/apt/sources.list: No such file or directory
./build_raspbian_sd_card.sh: line 180: boot/cmdline.txt: No such file or directory
./build_raspbian_sd_card.sh: line 184: etc/fstab: No such file or directory
./build_raspbian_sd_card.sh: line 186: etc/hostname: No such file or directory
./build_raspbian_sd_card.sh: line 193: etc/network/interfaces: No such file or directory
./build_raspbian_sd_card.sh: line 197: etc/modules: No such file or directory
chroot: failed to run command '/third-stage': No such file or directory
./build_raspbian_sd_card.sh: line 232: etc/apt/sources.list: No such file or directory
chroot: failed to run command '/cleanup': No such file or directory
umount: /dev/mapper/loop6p1: not mounted
umount: /home/fcon/Gits/build-raspbian-image/rpi/rootfs: not mounted
umount: /dev/mapper/loop6p2: not mounted
finishing /home/fcon/Gits/build-raspbian-image/rpi/images/raspbian_basic_wheezy_20160916.img
loop deleted : /dev/loop6
created image /home/fcon/Gits/build-raspbian-image/rpi/images/raspbian_basic_wheezy_20160916.img
done.
`
Tested in vm whit 14.04 seems to work fine.