strawberrytau
Posts: 67
Joined: Wed May 30, 2012 7:56 am

Replacing boot partition without reimaging SD

Fri Jun 08, 2012 9:34 pm

I have a Debian Squeeze install. The boot partition seems to have corrupted (rainbow screen of death), and I'd like to replace the boot partition, but I don't want to reflash. I have a lot of data and settings on the SD card which I don't want to wipe.

Is it possible to replace the boot partition on the SD card without reflashing?

If so, please can you give instructions?

Edit: I use a Mac.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4247
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Replacing boot partition without reimaging SD

Fri Jun 08, 2012 11:37 pm

The easiest way is with a second SD card. Flash that one with the image, then open it on the Mac, copy all of the files out of the boot partition -- the small one. Then insert the old card and copy all the files onto its boot partition.

sharpapotheosis
Posts: 58
Joined: Thu May 24, 2012 6:47 pm

Re: Replacing boot partition without reimaging SD

Sat Jun 09, 2012 3:23 pm

Alternatively I think and I'm not promising this to work, but if you copy the contents of the larger partition across to a folder on your Mac, re-flash the SD card and then copy the contents back, that should restore all your settings and files.

User avatar
nick.mccloud
Posts: 804
Joined: Sat Feb 04, 2012 4:18 pm

Re: Replacing boot partition without reimaging SD

Sat Jun 09, 2012 3:35 pm

sharpapotheosis wrote:Alternatively I think and I'm not promising this to work, but if you copy the contents of the larger partition across to a folder on your Mac, re-flash the SD card and then copy the contents back, that should restore all your settings and files.
Mac's are good, but they ain't quite clever enough to see an ext4 partition's files without some serious hacking. Go with rurwin's suggestion.

strawberrytau
Posts: 67
Joined: Wed May 30, 2012 7:56 am

Re: Replacing boot partition without reimaging SD

Sat Jun 09, 2012 3:41 pm

I had the same idea as sharp and it seems to have worked.

I used MacFuse to read and write to the ext formatted partition and it worked well. I backed up, reflashed and restored and copied the files back.

No permissions problems, I hope, as I used sftp with the appropriate user to copy the files.

Only downside - this took a very long time!

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Replacing boot partition without reimaging SD

Tue Jun 12, 2012 1:17 pm

You could always use dd to do it - I believe Macs have dd ? correct me if I'm wrong though.
But you need to mount the img file first so you can take an image of the boot partition of the image...if that makes sense.

I'm about to test this method now...so I'll report back with results soon.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4247
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Replacing boot partition without reimaging SD

Tue Jun 12, 2012 1:24 pm

If you can mess around with images of part of the drive and stuff, then you can do it the proper way: mount the image on the Mac as a loopback mount, and copy the files off that onto the card.

I've never got into loopback mounts myself, but I understand they are easy and powerful. Doing it on a Mac may be more difficult, but it is BSD under the covers.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Replacing boot partition without reimaging SD

Tue Jun 12, 2012 1:33 pm

I don't have a Mac myself, but I can imagine it would be easy enough.

Here's a post on how to do it in Linux
http://rackerhacker.com/2010/12/14/moun ... -in-linux/
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Replacing boot partition without reimaging SD

Tue Jun 12, 2012 1:50 pm

SirLagz wrote:I don't have a Mac myself, but I can imagine it would be easy enough.

Here's a post on how to do it in Linux
http://rackerhacker.com/2010/12/14/moun ... -in-linux/
Comments:
1) That URL is along the lines of what I had figured out myself earlier - but note that he does it with "file" and multiplies by 512, while I did it with "fdisk" and multiplied by 65536 (after subtracting 1).
2) "kpartx" looks interesting, but it seems to me that all kpartx does for you is avoids having to fiddle with offsets - i.e., it does that part for you, including the multiplication. You still do the mounting (with -o loop) yourself.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Replacing boot partition without reimaging SD

Wed Jun 13, 2012 7:33 am

You can use either file or fdisk to find the information you need. The link shows both ways.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Replacing boot partition without reimaging SD

Thu Jun 14, 2012 4:16 pm

I've just finished a script to mount img files locally if anyone is interested in it.
My webhost is currently being moved so I don't have my hosting to put it up anywhere otherwise I would.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 25 guests