LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-09-2014, 11:38 AM   #1
Ian D
Member
 
Registered: Aug 2005
Location: Solihull, UK
Distribution: Fedora 39
Posts: 215

Rep: Reputation: 18
How to use dd to backup an SD card


I have a RaspberryPi with its OS on an SD card. Sometimes, the SD card gets corrupted and I have to rebuild from scratch.

I am sure that I can use dd (on a different machine) to make a backup copy (and have seen other posts which confirm this).

My question is, on my 'other' box, when I plug in the SD card, how do I know which entry in /dev is the one I need to back up? (Presumably, when the card is inserted and File Manager asks if I want to mount it and open with File Manager, I say 'No')?

Ian
 
Old 03-09-2014, 01:52 PM   #2
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
Code:
sudo fdisk -l
Plug in the card
Code:
sudo fdisk -l
You will see the new entry.
 
Old 03-09-2014, 06:13 PM   #3
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
I prefer blkid to fdisk, but both will give you the information. They give different information in different formats, but both will give you the /dev/ info you need.

For making a backup of a boot disk in its entirety, make sure you use, for example, /dev/sdd, and not /dev/sdd1. You want to copy all the partitions, not just one. Back up to a drive at least as large as the one you are using, of course, and realize that after running dd, the drive you backed up to will now only be the size of the SD card, with any excess unallocated.
 
Old 03-10-2014, 03:26 AM   #4
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
did you try lsusb to find the device then dmesg to see where the kernel placed that device. blkid will give you some good info also.

Last edited by Drakeo; 03-10-2014 at 11:11 AM.
 
Old 03-10-2014, 10:13 AM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Either run fdisk -l before and after plugging in the card, or run "tail -f /var/log/messages" while plugging in the card. It doesn't have to be any more complicated than that.

Quote:
Originally Posted by sgosnell View Post
of course, and realize that after running dd, the drive you backed up to will now only be the size of the SD card, with any excess unallocated.
Only if he copies it to a raw device, which would be rather pointless (unless he's trying to duplicate the SD card rather than back it up). Copy it to a file and it's a non-issue.
 
Old 03-12-2014, 07:15 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
It may still get mounted even though you choose to not open a folder in your file manager. A good idea is to check and umount any drives associated with the SD card before you perform the dd command.
 
Old 03-12-2014, 08:42 AM   #7
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
I was assuming the OP was making another bootable SD card. Perhaps a bad assumption.
 
Old 03-12-2014, 08:48 AM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by Ian D View Post
I have a RaspberryPi with its OS on an SD card. Sometimes, the SD card gets corrupted and I have to rebuild from scratch.

I am sure that I can use dd (on a different machine) to make a backup copy (and have seen other posts which confirm this).

My question is, on my 'other' box, when I plug in the SD card, how do I know which entry in /dev is the one I need to back up? (Presumably, when the card is inserted and File Manager asks if I want to mount it and open with File Manager, I say 'No')?

Ian
df -h worx for me.

this is what i do to duplicate usb's/sd's of the same size (or if the output drive is bigger):
Code:
dd bs=8192 if=/dev/sdx of=/dev/sdy
since this is very destructive i usually do this to have an interim backup:
http://www.linuxquestions.org/questi...3/#post4981710

this will make it compress better:
http://www.linuxquestions.org/questi...7/#post5097181

and one can use gparted to expand the boundery of the new sd-card if it is bigger.

Last edited by schneidz; 03-12-2014 at 09:22 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup SD Card CincinnatiKid Linux - Software 1 04-02-2013 02:32 PM
[SOLVED] DD question for making duplicate OS of SD card Raspberri Pi backup lleb Linux - Newbie 3 03-14-2013 07:59 AM
backup of a cf card with a booting system binary_dreamer Linux - General 6 07-18-2012 11:48 AM
SCSI Card + Tape Backup Rembrant Linux - Hardware 6 08-18-2005 03:53 PM
Embeded linux PCI card backup system Nigel_Tufnel Linux - Hardware 2 05-05-2004 05:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration