Dragan
Posts: 14
Joined: Wed Feb 06, 2013 4:34 pm

What is my SD card location

Fri Feb 22, 2013 7:52 pm

Hello,
i am trying to back up my RPi SD card with dd command like this:
dd if=/dev/sdx of=/path/to/image bs=1M
I am not entirely sure what my SD card location is though, and by reading the various forums, i should double check it, because dd is supposedly be very scary :).
My df -l

Code: Select all

Filesystem      Size  Used Avail Use% Mounted on
rootfs          1.8G  1.5G  167M  91% /
/dev/root       1.8G  1.5G  167M  91% /
devtmpfs         85M     0   85M   0% /dev
tmpfs            19M  716K   18M   4% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            37M     0   37M   0% /run/shm
/dev/mmcblk0p1   56M   19M   38M  34% /boot
/dev/sda1        15G  455M   15G   3% /media/usbtest
/dev/sdb1        15G  455M   15G   3% /media/624C20AA4C207B45
My mount:

Code: Select all

/dev/root on / type ext4 (rw,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=86184k,nr_inodes=21546,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=18888k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=37760k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=ascii,shortname=mixed,errors=remount-ro)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /media/usbtest type fuseblk (rw,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdb1 on /media/624C20AA4C207B45 type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: What is my SD card location

Fri Feb 22, 2013 8:23 pm

Before you insert the SD run the df command as:

Code: Select all

df > ~/mounts.tx
Then put the Sd in and re-run the df again with:

Code: Select all

df > ~/mounts-too.txt
Now you have 2 ffiles in your home directory, so do 'a diff' on them to highlight the mount created by the SD:

Code: Select all

diff ~/mounts.txt ~/mounts-too.txt
Job done

Dragan
Posts: 14
Joined: Wed Feb 06, 2013 4:34 pm

Re: What is my SD card location

Fri Feb 22, 2013 8:46 pm

Thank you for the fast answer. One question though. How can i even run the RPi without the SD card. The system is on it after all? I probably didn't explain properly. I would like to make that backup straight from the Raspberry Pi if possible.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: What is my SD card location

Fri Feb 22, 2013 8:51 pm

If you mean you want to make a backup of the SD card your P is running off (yes, can be a bit scary, but will usually work), the card is /dev/mmcblk0 (for whole card), /dev/mmcblk0p1 for /boot only, and /dev/mmcblk0p2 for the root fs /

If you have it plugged in via a card reader then it will be /dev/sdX, /dev/sdX1 and /dev/sdX2, where X is "a" for first card reader connected, "b" for second (if you have one) and so on.

Try the "blkid" command to see what is connected.

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: What is my SD card location

Fri Feb 22, 2013 9:05 pm

I'm not sure that would be a good idea at all.
You're proposing a byte-by-byte copy of a live filesystem, during the time of the copy the system will be changing in an indeterminate way. Hate to think what the end result would be; backups are meant to be robust and reproducible, everything that this isn't!

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: What is my SD card location

Fri Feb 22, 2013 9:30 pm

I'd unmount /boot and back that up, then mount it again. Then do a file level copy or backup of the root system - preferably with as many services stopped as possible.

The safest way, of course, is to boot of a spare SD card and backup the main one using that.

Dragan
Posts: 14
Joined: Wed Feb 06, 2013 4:34 pm

Re: What is my SD card location

Sat Feb 23, 2013 12:04 am

Oh ok, i get it. its not recommended doing a dd backup of a system that is up and running. I don't have a card reader so i was wondering if its possible to make a full backup (image) of my raspberry pi system SD straight from the RPi.
As for the sudo blkid, i get this:

Code: Select all

/dev/mmcblk0p1: SEC_TYPE="msdos" UUID="C522-EA52" TYPE="vfat"
/dev/mmcblk0p2: UUID="62ba9ec9-47d9-4421-aaee-71dd6c0f3707" TYPE="ext4"
/dev/sdb1: UUID="624C20AA4C207B45" TYPE="ntfs"
I might be pointlessly complicating things here but what do you think if i mounted this SD card straight from the Pi to another Linux system over the network and then used the DD backup? Would that work? Might sound strange but i asked that for the educational purposes :)

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: What is my SD card location

Sat Feb 23, 2013 2:16 am

A live back up is possible. But you have to copy the whole filesystem preserving all the user permissions, which means a linux not an ntfs style drive, and then do not restore any files which have a modified date newer than the backup creation date, so that restoring the backup will not overwrite newer information. It needs care, and writing your own script to do this is fraught with accidental destructive potential.

You will find it very hard to use dd for this, as the restore process would need quite a detailed understanding of ext4 inodes, sector formats and directory allocation. An offline backup is therefore much easier, and less hazardous.

My advice would be copy your home directory, /etc, and that covers most of the personalization so any reinstall, is a set of apt-get and copying back your home and possibly settings into /etc.
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

Return to “Beginners”