1

Topic: [SOLVED] SD Card Shrink Btrfs Partition: No space left on device

Trying to resize (shrink) a partition on a micro SD card.

Getting a "No space left on device" error?

Thoughts on how to resolve??

Following is the log:

GParted 1.2.0
configuration --enable-libparted-dmraid --enable-online-resize
libparted 3.4

========================================

Device:    /dev/sda
Model:    ATA Debian GNU Linux
Serial:    none
Sector size:    512
Total sectors:    134217728
 
Heads:    255
Sectors/track:    2
Cylinders:    263172
 
Partition table:    msdos
 
Partition   Type       Start       End         Flags   Partition Name   File System   Label   Mount Point
/dev/sda1   Primary         2048   132216831   boot                     ext4                  /
/dev/sda2   Extended   132218878   134215679                            extended        
/dev/sda5   Logical    132218880   134215679                            linux-swap        

========================================

Device:    /dev/sde
Model:    FCR-HS3 -3
Serial:    
Sector size:    512
Total sectors:    249737216
 
Heads:    255
Sectors/track:    2
Cylinders:    489680
 
Partition table:    msdos
 
Partition   Type      Start    End         Flags       Partition Name   File System   Label   Mount Point
/dev/sde1   Primary     2048      524287   boot, esp                    fat16         boot    
/dev/sde2   Primary   524288   249737182                                btrfs         root    

========================================

Shrink /dev/sde2 from 118.83 GiB to 4.80 GiB  00:01:00    ( ERROR )
        
calibrate /dev/sde2  00:00:00    ( SUCCESS )
        
path: /dev/sde2 (partition)
start: 524288
end: 249737182
size: 249212895 (118.83 GiB)
check file system on /dev/sde2 for errors and (if possible) fix them  00:00:08    ( SUCCESS )
        
btrfs check '/dev/sde2'  00:00:08    ( SUCCESS )
        
Opening filesystem to check...
Checking filesystem on /dev/sde2
UUID: 916ed486-0d67-414c-987d-5709ce79d98c
cache and super generation don't match, space cache will be invalidated
found 5158817792 bytes used, no error found
total csum bytes: 3505416
total tree bytes: 264175616
total fs tree bytes: 246218752
total extent tree bytes: 12976128
btree space waste bytes: 45150888
file data blocks allocated: 7240921088
referenced 8254730240
[1/7] checking root items
[2/7] checking extents
[3/7] checking free space tree
[4/7] checking fs roots
[5/7] checking only csums items (without verifying data)
[6/7] checking root refs
[7/7] checking quota groups skipped (not enabled on this FS)
shrink file system  00:00:52    ( ERROR )
        
mkdir -v /tmp/gparted-ekvg70  00:00:00    ( SUCCESS )
        
Created directory /tmp/gparted-ekvg70
mount -v -t btrfs '/dev/sde2' '/tmp/gparted-ekvg70'  00:00:00    ( SUCCESS )
        
mount: /dev/sde2 mounted on /tmp/gparted-ekvg70.
btrfs filesystem resize 1:5033984K '/tmp/gparted-ekvg70'  00:00:51    ( ERROR )
        
Resize '/tmp/gparted-ekvg70' of '1:5033984K'
ERROR: unable to resize '/tmp/gparted-ekvg70': No space left on device
umount -v '/tmp/gparted-ekvg70'  00:00:01    ( SUCCESS )
        
umount: /tmp/gparted-ekvg70 unmounted
rmdir -v /tmp/gparted-ekvg70  00:00:00    ( SUCCESS )
        
Removed directory /tmp/gparted-ekvg70

Many thanks.

2

Re: [SOLVED] SD Card Shrink Btrfs Partition: No space left on device

Thanks for including the GParted Details.  That tells me what is happening and what went wrong.

The btrfs file system is very complicated and computing the minimum size a specific btrfs file system can be shrunk is difficult.  In this case you happen to be trying to shrink the file system to size "5033984K" (5154799616 bytes) which is smaller than "btrfs check" reports as used ("found 5158817792 bytes used").

I recommend trying to shrink the partition to a larger size.  Try 10G (10240 MiB).

3

Re: [SOLVED] SD Card Shrink Btrfs Partition: No space left on device

Yup. That was the trick.

Setting the new partition size to 8GB (8192 MiB - about 2x the occupied space) had the card resized in no time.

Thanks for the reply & a great utility.

Have a great one!