Sunday, 17 September 2017

Raspbian back ups and shrinking

After backing up a 16GB SD card from my Raspberry Pi, it wouldn't restore on any other card, even though they are all 16GB???

Here is what I did: 

1:  Shrink the image on the SD card - use gparted to look at the image, select the main partition, then select resize and slide the arrow to just before where your image is written, (the darker part) leave about 10MiB of blank space to be sure your not going to overwrite your image and apply. 

2: Back up the image from SD card  sudo dd bs=4M if=/dev/sdb of=raspbian.img
this creates a backup image in your home folder 

3: Cut off the unused space from your backed up image with the following method.

a) fdisk -l myimage.img - this outputs the start and end of the image.

b) Use the end figure of the image in the next command to cut off that amount from the backup.
I will use the figure 4434269 as an example in the command below but make sure you 
replace my figure with your own one

c) run the next command to cut off the unused space on your image
 truncate --size=$[(4434269+1)*512] myimage.img 

(make sure you replace 4434269 with your fdisk end figure)

Now you can copy your image to another card to test, you should have saved a nice amount of space,
my image is now small enough to use an 8GB card card.

Router security part 3 (Quad9)

You know how DNS works from part 2, so now it how to change your DNS. my favourite 2 providers: 1 Open DNS family friendly. great fo...