Solved: How to shrink BTRFS image
|
31st Mar, 2016, 12:57 AM
Post: #1
|
|||
|
|||
How to shrink BTRFS image
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! |
|||
31st Mar, 2016, 01:29 AM
(This post was last modified: 31st Mar, 2016 01:31 AM by Nachteule.)
Post: #2
|
|||
|
|||
RE: How to shrink BTRFS image
You can do it while fs is mounted
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 |
|||
31st Mar, 2016, 01:42 AM
Post: #3
|
|||
|
|||
RE: How to shrink BTRFS image
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 |
|||
31st Mar, 2016, 02:11 AM
Post: #4
|
|||
|
|||
RE: How to shrink BTRFS image
Wow! Thank you!
I like the second method best! - Less things for me to screw up! 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).... |
|||
31st Mar, 2016, 02:41 AM
Post: #5
|
|||
|
|||
RE: How to shrink BTRFS image
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 |
|||
31st Mar, 2016, 04:49 AM
Post: #6
|
|||
|
|||
RE: How to shrink BTRFS image
Woah! - This feature should be shouted from the rooftops!
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! 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? |
|||
31st Mar, 2016, 10:25 PM
Post: #7
|
|||
|
|||
RE: How to shrink BTRFS image
Quote:I guess that it is not currently possible to restore the image by reversing the process is it? Does this makes sense? |
|||
1st Apr, 2016, 03:45 AM
Post: #8
|
|||
|
|||
RE: How to shrink BTRFS image
(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? It does to me! 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!) But it would be nice to have. |
|||
1st Apr, 2016, 03:57 AM
Post: #9
|
|||
|
|||
RE: How to shrink BTRFS image
(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!) There was one request from mk01 to integrate this feature into XBian installer. But unfortunately this never happened BUT linux user does not need this, because dd if=image of=/dev/sdX is just easy to do |
|||
1st Apr, 2016, 04:11 AM
Post: #10
|
|||
|
|||
RE: How to shrink BTRFS image
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. Please read before you post How to post a log file If you liked my help, click on "Thanks" to show your appreciation.
|
|||
1st Apr, 2016, 04:43 AM
Post: #11
|
|||
|
|||
RE: How to shrink BTRFS image
One possible solution: you put a tiny rescue system into initramfs, boot from it and restore image with dd
|
|||
1st Apr, 2016, 04:53 AM
Post: #12
|
|||
|
|||
RE: How to shrink BTRFS image
Well it was just a thought.
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€ 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? |
|||
« Next Oldest | Next Newest »
|
Possibly Related Threads... | |||||
Thread: | Author | Replies | Views: | Last Post | |
Resize (shrink) Image the safest way? | Skywatch | 6 | 20,608 |
5th Apr, 2013 04:36 AM Last Post: zilexa |