How to remount btrfs without compression?
Hello,
Is there any possibility to remount a compressed btrfs without any compression at all?
Syslinux bootloader does not understand any btrfs compression and whenever I edit syslinux.cfg on my compressed / subvolume, the file becomes compressed and thus unreadable by syslinux on the next boot.
I tried to remount / without the 'compress' option (and edit syslinux.cfg in uncompressed state) and while the "mount" command would not show compression any more, I can see in the /proc/mounts that compression is still there and the file still gets compressed after editing. But there seem to be no mount option like compress=none or something.
The only workaround I found is to boot from a live CD mount / without any compression and re-save syslinux.cfg. Then it the file gets uncompressed.
Are there any other options except for this workaround to temporarily remount btrfs without compression?
thanks
Am Montag, 7. November 2011 schrieb dima:
Quoted 1 line
Hello,
Hi Dima,
=20
Quoted 9 lines
Is there any possibility to remount a compressed btrfs without any compression at all?
=20
Syslinux bootloader does not understand any btrfs compression and whenever I edit syslinux.cfg on my compressed / subvolume, the file becomes compressed and thus unreadable by syslinux on the next boot. =20
I tried to remount / without the 'compress' option (and edit syslinux.cfg in uncompressed state) and while the "mount" command wou=
ld
Quoted 11 lines
not show compression any more, I can see in the
/proc/mountsthat compression is still there and the file still gets compressed after editing. But there seem to be no mount option like compress=3Dnone or something.
=20
The only workaround I found is to boot from a live CD mount / without any compression and re-save syslinux.cfg. Then it the file gets uncompressed.
=20
Are there any other options except for this workaround to temporarily remount btrfs without compression?
What does lsattr show on the file? Have you tried chattr -c on the file= ? It=20
might help to do a btrfs filesystem defrag on the file to remove=20 compression, cause I don=C2=B4t think chattr -c itself will uncompress = it.
As far as I understand it is possible to individually set compression=20 on/off on single files. Although the global thing should work as well I= MHO=20
as least when the file is rewritten.
Ciao,
--=20
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA B82F 991B EAAC A599 84C7
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Martin Steigerwald
Am Montag, 7. November 2011 schrieb dima:
Quoted 1 line
Hello,
Hi Dima,
Quoted 9 lines
Is there any possibility to remount a compressed btrfs without any compression at all?
Syslinux bootloader does not understand any btrfs compression and whenever I edit syslinux.cfg on my compressed / subvolume, the file becomes compressed and thus unreadable by syslinux on the next boot.
I tried to remount / without the 'compress' option (and edit syslinux.cfg in uncompressed state) and while the "mount" command wo=
uld
Quoted 3 lines
Quoted 3 lines
not show compression any more, I can see in the
/proc/mountsthat compression is still there and the file still gets compressed after editing. But there seem to be no mount option like compress=3Dnone o=
r
Quoted 3 lines
Quoted 3 lines
something.
The only workaround I found is to boot from a live CD mount / withou=
t
Quoted 4 lines
Quoted 4 lines
any compression and re-save syslinux.cfg. Then it the file gets uncompressed.
Are there any other options except for this workaround to temporaril=
y
Quoted 3 lines
Quoted 1 line
remount btrfs without compression?
What does lsattr show on the file? Have you tried chattr -c on the fi=
le? It
Quoted 2 lines
might help to do a btrfs filesystem defrag on the file to remove compression, cause I don=C2=B4t think chattr -c itself will uncompres=
s it.
Hi Martin,
Thanks for your reply.
Yes, I did check out lsattr. It shows that no flags are set. Setting=20 chattr +c then chattr -c and re-saving file has no effect either.
I also tried to defragment the file itself and the directory where it=20 was in without setting -c but it would not have any effect because / is= =20
mounted with compression.
Quoted 2 lines
As far as I understand it is possible to individually set compression on/off on single files.
Could not find how to turn it off though.
thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · dima
Quoted 3 lines · Martin Steigerwald
Am Montag, 7. November 2011 schrieb dima:
Quoted 1 line
Hello,
Quoted 8 lines
Quoted 8 lines
Hi Dima,
Quoted 6 lines
Is there any possibility to remount a compressed btrfs without any compression at all?
Syslinux bootloader does not understand any btrfs compression and whenever I edit syslinux.cfg on my compressed / subvolume, the file becomes compressed and thus unreadable by syslinux on the next boot=
=2E
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I tried to remount / without the 'compress' option (and edit syslinux.cfg in uncompressed state) and while the "mount" command w=
ould
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
not show compression any more, I can see in the
/proc/mountsthat compression is still there and the file still gets compressed after editing. But there seem to be no mount option like compress=3Dnone =
or
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
something.
The only workaround I found is to boot from a live CD mount / witho=
ut
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
any compression and re-save syslinux.cfg. Then it the file gets uncompressed.
Are there any other options except for this workaround to temporari=
ly
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
remount btrfs without compression?
What does lsattr show on the file? Have you tried chattr -c on the file? It
might help to do a btrfs filesystem defrag on the file to remove compression, cause I don=C2=B4t think chattr -c itself will uncompre=
ss it.
Quoted 8 lines
Hi Martin,
Thanks for your reply.
Yes, I did check out lsattr. It shows that no flags are set. Setting chattr +c then chattr -c and re-saving file has no effect either.I also tried to defragment the file itself and the directory where it was in without setting -c but it would not have any effect because / =
is
Quoted 3 lines
mounted with compression.
Quoted 1 line
As far as I understand it is possible to individually set compressio=
n
Quoted 7 lines
Quoted 1 line
on/off on single files.
Could not find how to turn it off though.
thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs=
" in
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hey Dima, I know if you install a system without the compress flag=20 already done, you can force BTRFS to compress everything post-install b= y=20
teling it to "rebalance" the filesystem. I'm under Win7 right now so I=20 dont know the exact command. Check btrfs --help for that.
I dont know if it works in reverse, but you can definitely try it. Edit= =20
your fstab, remove the compress flag, reboot. Tell btrfs to rebalance=20 the system, reboot again. And I -THINK- that'll decompress all the file= s
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Eric Griffith
Edit your
fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system, reboot again. And I -THINK- that'll decompress all the files
I think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
AFAIK there's no way to do that.
Signature · 1 line
Fajar
Quoted 11 lines · Fajar A. Nugraha
Quoted 3 lines · Eric Griffith
Edit your
fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system, reboot again. And I -THINK- that'll decompress all the filesI think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
AFAIK there's no way to do that.
Whoops! Misunderstood the question haha. Yeah, as far as decompressing just a single file; from what I've read, thats impossible.
Quoted 12 lines · Eric Griffith
Quoted 11 lines · Fajar A. Nugraha
Quoted 4 lines · Eric Griffith
Edit your
fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
reboot again. And I -THINK- that'll decompress all the filesI think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
Quoted 5 lines
Quoted 2 lines
AFAIK there's no way to do that.
Whoops! Misunderstood the question haha. Yeah, as far as decompressing just a single file; from what I've read, thats impossible.
Eric, Fajar,
Thanks. Understood.
Yes, it is possible to remove the compress flag from fstab, reboot and even do not do any defragmentation/rebalancing - just re-save the file and it will be saved uncompressed. This works. But only with reboot...
Quoted 20 lines · dima
Quoted 12 lines · Eric Griffith
Quoted 11 lines · Fajar A. Nugraha
Quoted 4 lines · Eric Griffith
Edit your
fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
reboot again. And I -THINK- that'll decompress all the filesI think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
Quoted 5 lines
Quoted 2 lines
AFAIK there's no way to do that.
Whoops! Misunderstood the question haha. Yeah, as far as decompressing just a single file; from what I've read, thats impossible.
Quoted 7 lines
Eric, Fajar,
Thanks. Understood.Yes, it is possible to remove the compress flag from fstab, reboot and even do not do any defragmentation/rebalancing - just re-save the file and it will be saved uncompressed. This works. But only with reboot...
chattr -c on the file should work (followed by defrag or rewriting the file). I just retested and it seems to be broken right now.
I'll track it down.
-chris
Quoted 29 lines · Chris Mason
Quoted 20 lines · dima
Quoted 12 lines · Eric Griffith
Quoted 11 lines · Fajar A. Nugraha
Quoted 4 lines · Eric Griffith
Edit your
fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
reboot again. And I -THINK- that'll decompress all the filesI think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
Quoted 5 lines
Quoted 2 lines
AFAIK there's no way to do that.
Whoops! Misunderstood the question haha. Yeah, as far as decompressing just a single file; from what I've read, thats impossible.
Quoted 7 lines
Eric, Fajar,
Thanks. Understood.Yes, it is possible to remove the compress flag from fstab, reboot and even do not do any defragmentation/rebalancing - just re-save the file and it will be saved uncompressed. This works. But only with reboot...
Quoted 4 lines
chattr -c on the file should work (followed by defrag or rewriting the file). I just retested and it seems to be broken right now.
I'll track it down.
Ok, I had forgotten. chattr -c clears the compression flag bug doesn't set the no compress flag. We looks like we need to patch chattr for this.
-chris
Quoted 33 lines · Chris Mason
Quoted 32 lines · Chris Mason
Quoted 20 lines · dima
Quoted 12 lines · Eric Griffith
Quoted 11 lines · Fajar A. Nugraha
Quoted 4 lines · Eric Griffith
Edit your
fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
reboot again. And I -THINK- that'll decompress all the filesI think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
Quoted 5 lines
Quoted 2 lines
AFAIK there's no way to do that.
Whoops! Misunderstood the question haha. Yeah, as far as decompressing just a single file; from what I've read, thats impossible.
Quoted 7 lines
Eric, Fajar,
Thanks. Understood.Yes, it is possible to remove the compress flag from fstab, reboot and even do not do any defragmentation/rebalancing - just re-save the file and it will be saved uncompressed. This works. But only with reboot...
chattr -c on the file should work (followed by defrag or rewriting the file). I just retested and it seems to be broken right now.
Quoted 8 lines
Quoted 1 line
I'll track it down.
Ok, I had forgotten. chattr -c clears the compression flag bug doesn't set the no compress flag. We looks like we need to patch chattr for this.
-chris
Just for the record - I could find a solution thanks to the btrfs wiki being online again. In Gotchas it says
mount -o nodatacow also disables compression
and indeed it does. Remounting with this option and re-saving the file makes it uncompressed. However, I could not find how to remount the filesystem afterwards without nodatacow.
~dima
dima, Wed, 09 Nov 2011 10:01:13 +0900:
Quoted 47 lines · Chris Mason
Quoted 33 lines · Chris Mason
Quoted 32 lines · dima
Quoted 20 lines · Eric Griffith
Quoted 11 lines · Fajar A. Nugraha
Quoted 10 lines
Quoted 3 lines · Eric Griffith
Edit your fstab, remove the compress flag, reboot. Tell btrfs to rebalance the system,
reboot again. And I -THINK- that'll decompress all the filesI think the original question was how to force uncompressed mode, whether specific to a file or to a whole filesystem, without having to reboot :)
Quoted 6 lines
Quoted 3 lines
AFAIK there's no way to do that.
Whoops! Misunderstood the question haha. Yeah, as far as decompressing just a single file; from what I've read, thats impossible.
Quoted 7 lines
Eric, Fajar,
Thanks. Understood.Yes, it is possible to remove the compress flag from fstab, reboot and even do not do any defragmentation/rebalancing - just re-save the file and it will be saved uncompressed. This works. But only with reboot...
chattr -c on the file should work (followed by defrag or rewriting the file). I just retested and it seems to be broken right now.
Quoted 9 lines
Quoted 1 line
I'll track it down.
Ok, I had forgotten. chattr -c clears the compression flag bug doesn't set the no compress flag. We looks like we need to patch chattr for this.
-chris
Just for the record - I could find a solution thanks to the btrfs wiki being online again. In Gotchas it says
Quoted 7 lines
mount -o nodatacow also disables compression
and indeed it does. Remounting with this option and re-saving the file makes it uncompressed. However, I could not find how to remount the filesystem afterwards without nodatacow.
~dima
Sorry for possibly OT question - when I have historical btrfs system mounted with zlib compression,
can I remount it with lzo ? What will happen? Will the COW be broken and the files taking duplicate space? Or will the Universe explode and be replaced with something even more bizzare?
Thank you
Lubos
Quoted 6 lines · Lubos Kolouch
Sorry for possibly OT question - when I have historical btrfs system mounted with zlib compression,
can I remount it with lzo ? What will happen? Will the COW be broken and the files taking duplicate space? Or will the Universe explode and be replaced with something even more bizzare?
Hello Lubos
If you have a kernel that supports lzo (don't quite remember when it got in), why can't you?
Absolutely nothing will happen, and only the new/updated files will be with lzo compression. You can remount on the fly switching b/w the two compression options without any problems.
Dmitry Olenin, Wed, 09 Nov 2011 17:03:39 +0900:
Quoted 8 lines · Lubos Kolouch
Quoted 6 lines
Sorry for possibly OT question - when I have historical btrfs system mounted with zlib compression,
can I remount it with lzo ? What will happen? Will the COW be broken and the files taking duplicate space? Or will the Universe explode and be replaced with something even more bizzare?
Quoted 5 lines
Hello Lubos If you have a kernel that supports lzo (don't quite remember when it got in), why can't you?
Absolutely nothing will happen, and only the new/updated files will be with lzo compression. You can remount on the fly switching b/w the two compression options without any problems.
Hello Dmitry,
By the way, this is interesting question to me - I mounted the filesystem with -o compress=lzo, in dmesg showed btrfs: use lzo compression,
but - the lzo module was not loaded (not shown in lsmod - and yes, I have it as a module).
When I do modprobe lzo, it shows there.
Isn't it a bit strange? So btrfs is using lzo module that was not loaded? (and says so in the dmesg output)?
Thank you
Lubos
Quoted 21 lines · Lubos Kolouch
Dmitry Olenin, Wed, 09 Nov 2011 17:03:39 +0900:
Quoted 8 lines · Lubos Kolouch
Quoted 6 lines
Sorry for possibly OT question - when I have historical btrfs system mounted with zlib compression,
can I remount it with lzo ? What will happen? Will the COW be broken and the files taking duplicate space? Or will the Universe explode and be replaced with something even more bizzare?
Quoted 5 lines
Hello Lubos If you have a kernel that supports lzo (don't quite remember when it got in), why can't you?
Absolutely nothing will happen, and only the new/updated files will be with lzo compression. You can remount on the fly switching b/w the two compression options without any problems.Hello Dmitry,
By the way, this is interesting question to me - I mounted the filesystem with -o compress=lzo, in dmesg showed btrfs: use lzo compression,
Quoted 7 lines
but - the lzo module was not loaded (not shown in lsmod - and yes, I have it as a module).
When I do modprobe lzo, it shows there.
Isn't it a bit strange? So btrfs is using lzo module that was not loaded? (and says so in the dmesg output)?
Hello Lubos
Yes, I was wondering about this too when I started doing lzo.
The lzo module you load most likely has nothing to do with btrfs. This is the only explanation. I would think that lzo for btrfs is built into kernel. Unfortunately I don't have my .config with me at the moment to check it.
Quoted 4 lines · Lubos Kolouch
Sorry for possibly OT question - when I have historical btrfs system mounted with zlib compression,
can I remount it with lzo ?
yes
Quoted 3 lines
What will happen? Will the COW be broken
and the files taking duplicate space? Or will the Universe explode and be replaced with something even more bizzare?
New written block/extents will use lzo compression (if it's compressible, or if it's mounted with compress-force). Old, unmodified block/extents will remain unchanged, using zlib or uncompressed.
Signature · 1 line
Fajar
Quoted 8 lines · Fajar A. Nugraha
Quoted 4 lines · Lubos Kolouch
Sorry for possibly OT question - when I have historical btrfs system mounted with zlib compression,
can I remount it with lzo ?
yes
Quoted 7 lines
Quoted 3 lines
What will happen? Will the COW be broken
and the files taking duplicate space? Or will the Universe explode and be replaced with something even more bizzare?New written block/extents will use lzo compression (if it's compressible, or if it's mounted with compress-force). Old, unmodified block/extents will remain unchanged, using zlib or uncompressed.
This is correct, your old stuff will be zlib and your new stuff lzo. The compression type is recorded on a per-extent basis and the global switch just decides what type of compression to use for new writes.
-chris
Quoted 8 lines · dima
Just for the record - I could find a solution thanks to the btrfs wiki being online again. In Gotchas it says
mount -o nodatacow also disables compression
and indeed it does. Remounting with this option and re-saving the file makes it uncompressed. However, I could not find how to remount the filesystem afterwards without nodatacow.
I saw this mentioned on irc today (that nodatacow diasables compression). There is a way how to turn off compression on a file -- with help of the NOCOW _file_ attribute, ie. you don't have to remount.
* create the file, compression enabled
* set NOCOW (with the attached single-purpose nocow.c utility)
* btrfs fi defrag the_file
Make sure you have enough free space for the uncompressed file size. You can compare the extent layout before and after the defrag with "filefrag -v" .
I did a test first, here's what I saw with a ~60M file (filled with zeros, suitable for compression):
# filefrag -v zerofile2 Filesystem type is: 9123683e File size of zerofile2 is 69927424 (17073 blocks, blocksize 4096) ext logical physical expected length flags 0 0 2700 32 1 32 2942 2731 32 2 64 2943 2973 32 3 96 2944 2974 32 4 128 2945 2975 32 ... 533 17039 2641 2671 32 534 17071 2643 2672 2 eof zerofile2: 535 extents found
# btrfs fi defrag zerofile2
# filefrag -v zerofile2 Filesystem type is: 9123683e File size of zerofile2 is 69927424 (17073 blocks, blocksize 4096) ext logical physical expected length flags 0 0 20992 2107 1 2107 23552 23098 1581 2 3688 16400 25132 1185 3 4873 12410 17584 889 4 5762 14762 13298 667 5 6429 15881 15428 500 6 6929 17585 16380 751 7 7680 23099 18335 375 8 8055 25133 23473 376 9 8431 3072 25508 2160 10 10591 5632 5231 1620 11 12211 8192 7251 2431 12 14642 18432 10622 2431 eof zerofile2: 13 extents found
david
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <string.h>
#include <linux/types.h>
#include <stdio.h>
#include <errno.h>
#ifndef FS_IOC_SETFLAGS
#define FS_IOC_SETFLAGS _IOW('f', 2, long)
#warning defining SETFLAGS locally
#endif
#ifndef FS_IOC_GETFLAGS
#define FS_IOC_GETFLAGS _IOR('f', 1, long)
#warning defining GETFLAGS locally
#endif
#ifndef FS_NOCOW_FL
#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
#endif
int main(int argc, char **argv)
{
int fd;
int r;
long flags;
if (argc < 2) {
printf("usage: %s file\n", argv[0]);
exit(1);
}
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
perror("open()");
return 1;
}
printf("GETFLAGS ioctl 0x%x\n", FS_IOC_GETFLAGS);
printf("SETFLAGS ioctl 0x%x\n", FS_IOC_SETFLAGS);
r = ioctl(fd, FS_IOC_GETFLAGS, &flags);
if (r == -1) {
perror("ioctl(GETFLAGS)");
return 1;
} else {
printf("file flags: 0x%lx\n", flags);
}
printf("Set NOCOW flag for %s\n", argv[1]);
flags |= FS_NOCOW_FL;
r = ioctl(fd, FS_IOC_SETFLAGS, &flags);
printf("ioctl returned: %d\n", r);
if (r == -1) {
perror("ioctl()");
return 1;
}
return 0;
}Quoted 14 lines · David Sterba
Quoted 8 lines · dima
Just for the record - I could find a solution thanks to the btrfs wiki being online again. In Gotchas it says
mount -o nodatacow also disables compression
and indeed it does. Remounting with this option and re-saving the file makes it uncompressed. However, I could not find how to remount the filesystem afterwards without nodatacow.
I saw this mentioned on irc today (that nodatacow diasables compression). There is a way how to turn off compression on a file -- with help of the NOCOW _file_ attribute, ie. you don't have to remount.
Quoted 7 lines
* create the file, compression enabled
* set NOCOW (with the attached single-purposenocow.cutility)
* btrfs fi defragthe_fileMake sure you have enough free space for the uncompressed file size. You can compare the extent layout before and after the defrag with "filefrag -v" .
Hello David,
Thank you, I will try it out tonight. Is there any way to see if nocow attribute was set on a particular file, and is there any way to unset it?
thanks
~dima
Quoted 24 lines · dima
Quoted 14 lines · David Sterba
Quoted 8 lines · dima
Just for the record - I could find a solution thanks to the btrfs wiki being online again. In Gotchas it says
mount -o nodatacow also disables compression
and indeed it does. Remounting with this option and re-saving the file makes it uncompressed. However, I could not find how to remount the filesystem afterwards without nodatacow.
I saw this mentioned on irc today (that nodatacow diasables compression). There is a way how to turn off compression on a file -- with help of the NOCOW _file_ attribute, ie. you don't have to remount.
Quoted 7 lines
* create the file, compression enabled
* set NOCOW (with the attached single-purposenocow.cutility)
* btrfs fi defragthe_fileMake sure you have enough free space for the uncompressed file size. You can compare the extent layout before and after the defrag with "filefrag -v" .
Quoted 4 lines
Hello David,
Thank you, I will try it out tonight. Is there any way to see if nocow attribute was set on a particular file, and is there any way to unset it?
Hi David
I tried the nocow utility. It worked.
First I made sure to re-save the syslinux.cfg file while btrfs was mounted with lzo to ensure that it is compressed, then I set the NOCOW flag with your utility. Then I checked fragmentation of the file and since it was a small one it was not fragmented. So when I ran btrfs fi defrag syslinux.cfg it did not have any effect and file was not uncompressed. Then I simply re-saved the file and it got uncompressed fine since bootloader could read it on reboot.
thanks