[raspberry-vi] Re: Can one write image of SD card to mounted memory stick

  • From: "Fanus Buys" <buys.fanus@xxxxxxxxx>
  • To: <raspberry-vi@xxxxxxxxxxxxx>
  • Date: Sun, 23 Aug 2020 19:39:03 +0200

Hello Mike
Thanks much. Maybe I should have asked the question differently: is there a way 
to make a copy or image of the SD card so that when one inserts a new card into 
the PI one can just write the copy back onto the new card without havig to 
setup Espeak and other software?
Regards
Fanus
 

-----Original Message-----
From: raspberry-vi-bounce@xxxxxxxxxxxxx 
[mailto:raspberry-vi-bounce@xxxxxxxxxxxxx] On Behalf Of Michael A Ray ;(Redacted 
sender "mike.ray" for DMARC)
Sent: Sunday, August 23, 2020 1:14 PM
To: raspberry-vi@xxxxxxxxxxxxx
Subject: [raspberry-vi] Re: Can one write image of SD card to mounted memory 
stick


That depends on what you mean by 'write to a mounted memory stick'.

If you want to write the image, or an image to a memory stick, then no,
see later.

But if you want to write the contents of your entire running Pi to a
memory stick then yes.

To write all the contents to a mounted memory stick, mount the stick to
/mnt/something.

For example:

mkdir /mnt/usb0

Then mount the memory stick:

sudo mount /dev/sdx /mnt/usb0

Change the x in sdx to the letter of the memory stick.

Now you will have:

/mnt/usb0/<lots of files>

Now use rsync to write the whole of the card to the stick, but, and this
is the trick...

YOU MUST use the rsync option to prevent it from crossing partition
boundaries.

In other words, if you do not do this and you try to write the contents
of the card to /mnt/usb, you will disappear up your own bottom, because
you are trying to recursively copy what you copied.

The rsync option for this is either -x or --one-file-system, which means
do not cross file system boundaries.

Now the later bit...

To write an image to the memory stick, assuming the memory stick is NOT
mounted and is /dev/sdx, and the image file is image.img:

dd bs=512 if=image.img of=/dev/sdx status=progress

I can't remember whether you will need sudo for that, I think you will.

And the status=progress is only possible with later versions of dd, but
it should work with Debian Buster or later, and certainly works with
Ubuntu 18.04 or later.

NOW READ THIS:

Be very, very careful with dd.

Not for no reason do some people call it 'data destroyer'. If you give
the wrong of= argument, dd will just silently crush what was on whatever
you told it to.

IT DOES NOT GIVE YOU A SECOND CHANCE.

I suggest you read the manual page for rsync, which is a very powerful
command line program.

Mike




On 23/08/2020 11:51, Fanus Buys wrote:

Hello list
Is this possible or must PI be connected to Linux PC?
Regards
Fanus


=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of 
the Foundation.

Mike Ray, list creator, January 2013



-- 
Michael A. Ray
Analyst/Programmer
Witley, Surrey, South-east UK

"Perfection is achieved, not when there is nothing more to add, but when
there is nothing left to take away." -- A. de Saint-Exupery

https://cromarty.github.io/
http://eyesfreelinux.ninja/
http://www.raspberryvi.org/


=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

Other related posts: