Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have my /home on a BTRFS partition and I need to shrink it, unfortunately Gparted does not have the resize option for this FS. Can I resize it in any other way without losing my data?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

According to the GParted features page, btrfs shrink is supported. If the option isn't available, installing the btrfs-tools package may fix it. If that doesn't work, it could be because Ubuntu includes an older version of GParted, in which case you could use the GParted Live CD:

http://gparted.sourceforge.net/livecd.php

(which is also how Ubuntu recommends using it anyway)

share|improve this answer
add comment

According to this page in the btrfs wiki which is unfortunately currently down:

To shrink the filesystem by 4 GiB: btrfs filesystem resize -4g /mnt or btrfsctl -r -4g /mnt Set the FS size . To set the filesystem to a specific size, omit the leading + or - from the size.

The btrfs and btrfsctl commands in Ubuntu is provided by the package called btrfs-utils, which you can install in the Software Center. You run these commands in the Terminal (Ctrl+Alt+T). Replace 4g by however much you really want to shrink the partition, and /mnt by the mount point of the partition. For example, to shrink a btrfs partition mounted at /media/Alpha by 500 MiB, you would run:

btrfs filesystem resize -500m /media/Alpha

Or:

btrfsctl -r -500m /media/Alpha

Assuming the guidelines for resizing btrfs filesystems are the same as for other filesystems, you should avoid resizing a partition that is on the same physical disk as the running system. So, if necessary, boot from a live system to resize a partition on the drive that has your installed Ubuntu system. (This applies to resizing done in GParted, too.)

If some utilities or applications don't see the results of the resizing operation when it is performed, rebooting is a good idea.

See the btrfs and btrfsctl manual pages for more details about the use of these commands. And hopefully the btrfs wiki will be back up soon.

I am not personally very familiar with btrfs filesystems, but it seems strange to me that these resize commands take the mount point of the filesystem rather than the device name. If anyone can explain that, please comment or feel free to edit this answer to improve it.

share|improve this answer
    
It does seem strange, so I need to have to volume mounted to resize it? I always thought that it's much safer to do so with unmounted volumes... Anyway thanks for your answer! –  Borsook Nov 3 '11 at 16:38
2  
The commands listed resize only the filesystem, not the partition. That's why they work on a mounted system. Once you've resized the FS you should be able to use your favourite partition management tool to change the size of the actual partition. But, the latest gparted will just do it all for you, so there's little reason to bother. –  Perkins May 14 '12 at 22:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.