vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

raspberry pi win32diskimager not enough space

Thu Sep 05, 2013 5:18 pm

I have a backup image of my pi that I created in win32diskimager. My card died so I bought another but the card must be a few blocks shorter than my original card because when I try to write the img to my new card I get a not enough space error.

I tried to write my img using usbit and told it to ignore any truncation errors and it writes the image OK, but when I boot up, I get a Kernel Panic: VFS : Unable to mount root fs on unknown-block

I know the new card is good because I can write a clean img of the noobs installer just fine.

Any ideas how to get my backup img booting?
Last edited by vibez on Sat Sep 07, 2013 6:46 pm, edited 1 time in total.

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: raspberry pi win32diskimager not ebough space

Thu Sep 05, 2013 5:29 pm

I had exactly same problem, please see this post for a solution:
http://www.raspberrypi.org/phpBB3/viewt ... 12#p277212

If you have any questions, just ask.

Roman

vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

Re: raspberry pi win32diskimager not ebough space

Thu Sep 05, 2013 9:14 pm

I'll be honest, while that looks a great guide, it's a little over my head.

What I don't understand is that from reading this board, an img seems to be the preferred way to backup an sdcard, yet it seems so difficult to restore the img to any other card other than the original without jumping through all these hoops.

There has to be an easier way to handle backups?

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

Re: raspberry pi win32diskimager not ebough space

Thu Sep 05, 2013 9:47 pm

There has to be an easier way to handle backups?
It's beginning to look very much like we need to get the "rpi wriggle" concept into the mainline Raspbian (and others) distribution. The idea is that you're just killing yourself when you do the "expand rootfs" thing and use every single last available block on the SD card.

I.e., the point is this: The solutions to your problem are:

1) Step into your time machine, go back to when you expanded the rootfs and only expand it to almost fill the card. Of course, what I am really saying here is: In future use rpi-wriggle (Google it!) instead of the built-in expand_rootfs.

2) Using another Linux machine (desktop) or the Pi itself with an external SD card reader/writer, do the inverse operation(s) needed to shrink the filesystem down a bit.

3) Of course, if (as is your use case), the original SD card is unreadable/unrecoverable, then you'll have to do it on the image - which is more complex and beyond the scope of this post, but is doable.
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)

vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

Re: raspberry pi win32diskimager not ebough space

Thu Sep 05, 2013 9:59 pm

It does seem that rpi-wriggle would be a potential solution for raspian but I know some of the other distros automatically expand the file system. Openelec, xbian etc.

Personally I think I might go the rsync route and just backup the data on the cards rather than each and every block.

Which directories / partitions should I be backing up (from now on) to achieve a good enough backup strategy so I can get back to where I was before

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: raspberry pi win32diskimager not ebough space

Thu Sep 05, 2013 11:28 pm

vibez wrote:What I don't understand is that from reading this board, an img seems to be the preferred way to backup an sdcard, yet it seems so difficult to restore the img to any other card other than the original without jumping through all these hoops.

There has to be an easier way to handle backups?
There is if you're using Linux, but unfortunately when using Windows the only way to read/write the Linux filesystems (which Windows itself doesn't understand) from/to the SD card is to use low-level data-reading/writing, which is exactly what Win32DiskImager and img files do. :|

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: raspberry pi win32diskimager not ebough space

Fri Sep 06, 2013 12:15 pm

vibez wrote:I'll be honest, while that looks a great guide, it's a little over my head.
Hey vibez,

It may look complicated at the first glance, but it really isn't. I have not done it myself before, but I read about it a long time ago (10-12 years ago when DOS was still common and Windows just started).
When it happened to me recently, I did a bit of reading on the MBR structure to refresh my memory (Wikipedia is a good source) and then just dived in.

Give it a try, it's a good learning experience.

There is nothing to loose as you are manipulating backup of the backup, so if you screw something up, you can start over again until you get it right.

To protect yourself from happening it again, you can "shrink" your partition, let's say on 4GB card you shrink it to 3.9GB. You loose a bit of available space, but you will have guarantee that the image will fit on any 4GD card in the future.

Cheers and good luck,
Roman

vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

Re: raspberry pi win32diskimager not ebough space

Fri Sep 06, 2013 1:11 pm

Shrinking the ext4 partition gives me a kernel panic error when it boots

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: raspberry pi win32diskimager not ebough space

Fri Sep 06, 2013 2:07 pm

vibez wrote:Shrinking the ext4 partition gives me a kernel panic error when it boots
What I meant was that once you shrink the image (with the method described in my post) and your restored card boots up correctly, without any issues, then you can shrink your partition by mounting the card on another system (you can use Live CD of your favorite distribution if you do not have another system with Linux installed) and using gparted or similar tool to shrink the partition.

Do you have a dropbox or some other cloud storage?
If you get me your image file I can resize it for you, if you think that the process is too complicated for you.

Cheers,
Roman

vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

Re: raspberry pi win32diskimager not ebough space

Fri Sep 06, 2013 3:28 pm

I've hosed the original image trying various things. But what I would like to do is test preventing this situation in the future.

Here is what I've done

Installed raspian via noobs to sdcard

Shrank the ext4 partition with gparted by 500mb

Booted up resized rasbiam and ran dd against mmcblk0 to create an image

Flashed the dd image back to a smaller card using win32diskimager

Booted up the smaller card

Kernel panic!


Is there a step a have missed?

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: raspberry pi win32diskimager not ebough space

Fri Sep 06, 2013 4:03 pm

vibez wrote:....
Booted up resized rasbiam and ran dd against mmcblk0 to create an image
If I understand correctly, you run dd to create a backup image on the running system?

It is not recommended to run dd backup on running system.
Mount the card on another system and run dd image backup like that.
Then flash that image to a card and try to boot.

Roman

vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

Re: raspberry pi win32diskimager not ebough space

Fri Sep 06, 2013 4:38 pm

Oh right. I was looking for an automatic way to backup. I think I will have to look for another solution. Thanks for your help though :)

RomanG
Posts: 41
Joined: Fri Aug 17, 2012 11:56 am
Location: Ottawa, Canada

Re: raspberry pi win32diskimager not ebough space

Sat Sep 07, 2013 1:36 am

vibez wrote:Oh right. I was looking for an automatic way to backup. I think I will have to look for another solution. Thanks for your help though :)
If you are trying to back up running system, you may run in to the same problem with other application/utility.
Do you need to back up whole image/SD card or are you trying to back up only some data?

Roman

vibez
Posts: 27
Joined: Thu Aug 15, 2013 11:30 am

Re: raspberry pi win32diskimager not ebough space

Sat Sep 07, 2013 6:35 am

I suppose I'm trying to backup

1: a complete card so if mine dies, I can completely and quickly restore

2: important configurations so I can roll back if misconfigure something. This I can already do via rsync but I'm not entirely sure which folders to backup

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

Re: raspberry pi win32diskimager not ebough space

Sat Sep 07, 2013 7:38 am

I was working on a script that could make a working copy of a Raspbian system to another card on a Pi using just a USB card reader. By running it in "safe mode", the OS was completely held in RAM, so no problems with the card being updated during the copy.

One advantage of it was that it would transfer the contents of the card to another card of sufficient size. The new card doesn't have to be the same size as the old one. I did a test with transferring a system from an 8GB card (only 2.5GB used) to a 4 GB card. It takes a few minutes to run, depending on the amount of data to transfer, and makes a fully usable backup card - just swap the cards and power up.

I got it working, but there are a few bits to tidy up and make more friendly. Also it won't work with a NOOBS installation. I never got around to finishing it off as I use a Linux PC to backup my card contents.

Return to “General discussion”