Forum

Full Version: How to shrink BTRFS image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have been using a spare 64Gb card for xbian testing, but now want to move the working image to a 16Gb card. The question is how do I do that?

I have searched on the web but the rpi forums don't seem to talk about btrfs and I can't find a definitive answer to this problem.

I guess that btrfs filesystem resize 16:0g /mnt/tmp would work(?) but then how to resize the partition without grub or resizefs? The more I research the more confused I get!
You can do it while fs is mounted Smile

First step: shrink FS
btrfs filesystem resize 12G /

Second step: remove swap partition
swapoff -a and then remove this partition

Third step: resize partition
The trick is removing the existing one and create a new one with exactly the same start block and reduced size (16GB minus swap size minus boot part, take 15G

Fourth step: create image
make an 16GB image from this sd-card and write it back to your 16GB card

Last step: fine tuning
If system boots from your 16G card, you can do finetuning
add swap partition
and resize btrfs to max size

All these steps I already did about one year ago
Another way is using xbian-config -> XBian Copier

You can make an image from your existing 64G sd card and flash it back to your 16G
Wow! Thank you! Smile

I like the second method best! - Less things for me to screw up! Wink

So if I put "file:/mnt/nas/xbian/xbian.img" it will put the file on the nas without formatting the whole nas? - Just need to be sure before I try it!

I'll give it a try and see how it goes here (I seem to live in a Rpi haunted area)....Wink
Quote:So if I put "file:/mnt/nas/xbian/xbian.img" it will put the file on the nas without formatting the whole nas? - Just need to be sure before I try it!

Don't be afraid - it works Rolleyes
Woah! - This feature should be shouted from the rooftops! Smile

It will save me a lot of hassle backing up working xbians in the future. Now they can be saved direct to the NAS, it's brill! Smile

I admit it took a few attempts to see where I was going wrong, but once there it worked very well and the new card has booted and is working as expected.

Thank you so much (I feel that I am going to have to buy you a beer sometime for all the help)! %-}

I guess that it is not currently possible to restore the image by reversing the process is it?
Quote:I guess that it is not currently possible to restore the image by reversing the process is it?

Does this makes sense?
(31st Mar, 2016 10:25 PM)Nachteule Wrote: [ -> ]
Quote:I guess that it is not currently possible to restore the image by reversing the process is it?

Does this makes sense?

It does to me! Tongue

So say I have a corrupted install, I could launch an app on the laptop similar to xbian installer that could take the image from the server and put it on the pi sd card. I guess it would need to launch an app on the pi to load into ram to allow the process. Maybe it is totally impossible. I am not a linux expert (as you are painfully aware!) Shy

But it would be nice to have.
(1st Apr, 2016 03:45 AM)Skywatch Wrote: [ -> ]So say I have a corrupted install, I could launch an app on the laptop similar to xbian installer that could take the image from the server and put it on the pi sd card. I guess it would need to launch an app on the pi to load into ram to allow the process. Maybe it is totally impossible. I am not a linux expert (as you are painfully aware!) Shy

But it would be nice to have.

There was one request from mk01 to integrate this feature into XBian installer. But unfortunately this never happened Sad

BUT

linux user does not need this, because dd if=image of=/dev/sdX is just easy to do Big Grin
I think what you are asking is to be able to restore a backed up image to a live system. A bit like changing an engine whilst driving down the motorway/freeway at 70mph.

I don't think it's possible as the OS is running and "knows" it mount points - a restore would destroy them and... more importantly destroy the program that is running the restore.

I guess it would be possible to "make" a 2nd copy of the OS and at the last minute, modify the boot options, but you might as well stuff your hand in a bee's nest and hope you don't get stung.

I'm not even aware of any commercial system that would allow such a thing.

[Sarcasm] It's an RPi take out the SD card - it's not that difficult, I've done it :-) [/Sarcasm]

So if I understand you, you wish to boot into a RAM OS, reload the image onto disk and reboot xbian as a restored image. I guess that should be possible as many OS allow "live" images but is it, at the end of the day, worth it.
One possible solution: you put a tiny rescue system into initramfs, boot from it and restore image with dd
Well it was just a thought. Angel

If I can sit at my laptop at a remote location and make a backup of the live running xbian installation (xbian-config - Xbian-copier), then wouldn't it be good to be able to write that backup back to the pi with the same remote access if needed?

It might save a trip if the pi is located remotely i.e. at a friends/relatives house or holiday home etc.

Just my 0.02€ Wink

update...

@nightowl, that sounds like what I was trying to say. Is it possible do you think?
@IriDium, That is what I currently do but I am suggesting it for installs that are not local or easy to access to get the card and reflash it.

Would be a great feature, no?
Reference URL's