Skip to main content

How to Backup and Restore the Raspberry Pi SD Card?

How To Backup And Restore The Raspberry Pi SD Card?

How to backup and restore the Raspberry Pi SD Card?

Introduction

We use the 'dd' command to backup and restore the Raspberry Pi SD Card. Normally, We use to 4M bytes to read and write at a time in backup and restore it. There are three parameters, including 'bs', 'if' and 'of'. The 'bs' means reading and writing up to BYTES bytes at a time. The 'if' means reading from FILE instead of stdin. I think you can imagine that it is an input file to read. The 'of' means writing to FILE instead of stdout. I think you can imagine that it is an output file to write.

Equipment

Operation System: Ubuntu 14.04 LTS

Usage

The 'dd' can create a partition data into a file. So, we can backup whole partitions of an SD Card into a file. You need unmount whole partitions on the SD Card before you are backing it up. Default Raspbian installation has three partitions made on the SD Card, so we need to unmount whole partitions. To check which partition is mounted to which device, use 'df -h' and see the lines refer to as below.

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  4.9G   23G  18% /
devtmpfs        215M     0  215M   0% /dev
tmpfs            44M  280K   44M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            88M     0   88M   0% /run/shm
/dev/mmcblk0p5   60M  9.6M   50M  17% /boot
/dev/mmcblk0p3   27M  397K   25M   2% /media/SETTINGS

Then unmount the corresponding folders. If your OS is Ubuntu, you should be into the folder/node (/dev) and then find out the three devices. As long as we are unmount three partitions and then we can use the largest partition name in the SD Card to backup it.

# cd /dev
# ls
autofs              loop4                  ram10   tty1   tty30  tty51      vc-mem
block               loop5                  ram11   tty10  tty31  tty52      vcs
btrfs-control   loop6                  ram12   tty11  tty32  tty53      vcs1
bus          loop7                  ram13   tty12  tty33  tty54      vcs2
cachefiles        loop-control       ram14   tty13  tty34  tty55      vcs3
char         MAKEDEV       ram15   tty14  tty35  tty56      vcs4
console            mapper               ram2    tty15  tty36  tty57      vcs5
cpu_dma_latency  mem                     ram3    tty16  tty37  tty58      vcs6
disk         mmcblk0            ram4    tty17  tty38  tty59      vcsa
fb0           mmcblk0p1        ram5    tty18  tty39  tty6       vcsa1
fd             mmcblk0p2        ram6    tty19  tty4   tty60      vcsa2
full          mmcblk0p3        ram7    tty2   tty40  tty61      vcsa3
fuse         mmcblk0p5        ram8    tty20  tty41  tty62      vcsa4
hidraw0           mmcblk0p6        ram9    tty21  tty42  tty63      vcsa5
hidraw1           net              random  tty22  tty43  tty7       vcsa6
hidraw2           network_latency     raw     tty23  tty44  tty8       xconsole
input                network_throughput  shm     tty24  tty45  tty9       zero
kmsg               null                     snd     tty25  tty46  ttyAMA0
log           ppp                     stderr  tty26  tty47  ttyprintk
loop0               ptmx                   stdin   tty27  tty48  uinput
loop1               pts              stdout  tty28  tty49  urandom
loop2               ram0                   tty     tty29  tty5   vc-cma
loop3               ram1                   tty0    tty3   tty50  vchiq

If the Raspbian of the SD Card has three partitions, including /sdc1, /sdc3 and /sdc5, you should pick up the largest partition that is /sdc. Thus, we have the 'if' parameter that is /dev/sdc. Now, we are just setting up the 'of' parameter. It is that you want to output file name. Normally, we are just giving it a unique file name, such as '~/Image.img'. So, we need check to your hard disk space that enough saves your image file. We haven't compressed it. Therefor, The SD Card size is the image file size. To follow this command-line that you can backup your SD Card, as below.

# sudo dd bs=4M if=/dev/sdc of=~/Image.img

I prefer uncompress to create this backup SD Card. Because I have enough free space in my hard disk. I can do the restoring process to wire it to the SD Card.

# soud dd bs=4M if=~/Image.img of=/dev/sdc

You can try to do it. To backup and restore your SD Card. If you have more and more backup image, you would be safe about your Raspbian OS and your applications. There is one thing worth notice. You shouldn't use different kind of SD Card to backup and restore. Because it is very important that different kind of SD Card may be made with different size. For example, There are two 32GB SD Card. The ADATA is only 31.9GB. Another is TDK that has 32.0GB. So, we can restore smaller size into a larger size. But we cannot restore larger size into smaller size.

Acknowledge

Thank you (Ask Ubuntu) very much for this explain of the great tool.

Popular Posts

波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

最佳化處理策略之快速消除扭曲演算法

Python 日期與時間的處理

波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Image

最佳化處理策略之快速消除扭曲演算法

Image

Python 日期與時間的處理

Image

Visual Basic 6.0 程式案例學習: 10. 條碼列印程式 (2014版)

Image

Visual Basic .Net 程式案例學習: 06. 題庫測驗系統 (2014版)

Image

修復損毀的 SQLite DB 資料庫

Image

用10種程式語言做影像二值化(Image binarization)

Image

解決 ValueError: If using all scalar values, you must pass an index

Image

Visual Basic 6.0 程式案例學習: 04. 人事考勤管理系統 (2014版)

Image

Visual Basic 6.0 程式案例學習: 07. 收據列印程式 (2014版)

Image

佑佑的 Line 貼圖創作

貼圖作者網址:

https://line.me/S/shop/sticker/author/3883362

靜態貼圖

 
 
 
 
  牡羊座:狗狗角色

作者:佑佑
依照牡羊座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  金牛座:兔兔角色

作者:佑佑
依照金牛座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  雙子座:貓貓角色

作者:佑佑
依照雙子座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  巨蟹座:倉鼠角色

作者:佑佑
依照巨蟹座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  獅子座:幼獅角色

作者:佑佑
依照獅子座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  處女座:松鼠角色

作者:佑佑
依照處女座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  天秤座:鴿子角色

作者:佑佑
依照天秤座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  天蠍座:鳳凰角色

作者:佑佑
依照天蠍座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  射手座:人馬角色

作者:佑佑
依照射手座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  魔羯座:山羊角色

作者:佑佑
依照魔羯座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  水瓶座:海豚角色

作者:佑佑
依照水瓶座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  雙魚座:小丑魚角色

作者:佑佑
依照雙魚座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  上班族都變成狒狒,心裡想要說的話。

作者:佑佑
最近在台灣走紅的狒狒,用擬人化的方式,變成上班族,畫出心裡的想說的話。
購買貼圖
  接案派遣的日常

作者:佑佑
接案派遣到其他公司的日常對話,有調皮、正經、日常對話。
購買貼圖
  貓女事務員的搞笑時刻

作者:佑佑
把行政人員在職場上遇到千奇百怪的事情畫出來,用可愛的貓女來擔任行政人員的代言人。
購買貼圖
  貓貓說每天都會用到的話

作者:佑佑
日常生活常見的短句,用小貓擬人化的方式呈現,比較親切可愛。
購買貼圖
 
     
  大人的煩惱特輯:小兔角色

作者:佑佑
錢包餓了,生活苦了。變美變健康?先讓我睡飽吧。心好累,我需要充電。
購買貼圖
     

動態貼圖

 
 
 
 
  牡羊座日常交際:狗狗角色

作者:佑佑
依照牡羊座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  金牛座日常交際:兔兔角色

作者:佑佑
依照金牛座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  雙子座日常交際:貓貓角色

作者:佑佑
依照雙子座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  巨蟹座日常交際:倉鼠角色

作者:佑佑
依照巨蟹座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  獅子座日常交際:幼獅角色

作者:佑佑
依照獅子座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  處女座日常交際:松鼠角色

作者:佑佑
依照處女座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  天秤座日常交際:鴿子角色

作者:佑佑
依照天秤座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  天蠍座日常交際:鳳凰角色

作者:佑佑
依照天蠍座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  射手座日常交際:人馬角色

作者:佑佑
依照射手座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  魔羯座日常交際:山羊角色

作者:佑佑
依照魔羯座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  水瓶座日常交際:海豚角色

作者:佑佑
依照水瓶座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  雙魚座日常交際:小丑魚角色

作者:佑佑
依照雙魚座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
     
  厭世報:鬍渣男

作者:佑佑
厭世總有個理由跟原因,實在是令人不爽,為什麼最倒楣的總是我?真希望明天就是世界末日,讓大家都一樣慘。
購買貼圖
     

表情貼

 
 
 
 
  貓貓說每天都用得到的表情貼

作者:佑佑
日常生活常見的表情用語,用小貓擬人化的方式呈現,比較親切可愛。
購買貼圖
  天秤座的表情貼:鴿子角色

作者:佑佑
日常生活常見的表情用語,天秤座的鴿子擬人化方式呈現,比較親切可愛。
購買貼圖
  天蠍座的表情貼:鳳凰角色

作者:佑佑
日常生活常見的表情用語,天蠍座的鳳凰擬人化方式呈現,比較親切可愛。
購買貼圖
  射手座的表情貼:人馬角色

作者:佑佑
日常生活常見的表情用語,射手座的人馬擬人化方式呈現,比較親切可愛。
購買貼圖
 
 
 
 
  魔羯座的表情貼:山羊角色

作者:佑佑
日常生活常見的表情用語,魔羯座的山羊擬人化方式呈現,比較親切可愛。
購買貼圖
  水瓶座的表情貼:海豚角色

作者:佑佑
日常生活常見的表情用語,水瓶座的海豚擬人化方式呈現,比較親切可愛。
購買貼圖
  雙魚座的表情貼:小丑魚角色

作者:佑佑
日常生活常見的表情用語,雙魚座的小丑魚擬人化方式呈現,比較親切可愛。
購買貼圖