Siduction Forum

Siduction Forum => Software - Support => Topic started by: dfe on 2013/01/08, 00:43:11

Title: [SOLVED] Btrfs compression
Post by: dfe on 2013/01/08, 00:43:11
Hi,

I installed 2012.2 - Riders on the Storm using one partition, which is formatted with Btrfs. Now I want to enable compression. There is no fstab entry for the disk, so what is the best way to set the appropriate mount options?
I noticed that the disk gets mounted with "space_cache" per default. Where does that come from?

Btw, does anybody know if grub2 can read from Btrfs partitions that are compressed with LZO? There were problems with it some time ago.

thanks
Title: Btrfs compression
Post by: devil on 2013/01/08, 01:58:00
Your partition is not in fstab? That sounds strange, if we are not speaking of a usb device. Can we see your fstab?

greetz
devil
Title: RE: Btrfs compression
Post by: dibl on 2013/01/08, 02:23:57
There has to be an /etc/fstab entry, or your partition will not be mounted on boot.

BTRFS compression is enabled with the "compress" option, like this:

UUID=c112ed57-0e33-4d4b-82c9-5c55932c529d     /mnt/DATA            btrfs        device=/dev/sdd,device=/dev/sde,compress,space_cache,inode_cache   0    0
Title: [SOLVED] Btrfs compression
Post by: dfe on 2013/01/08, 12:38:19
Here is my fstab (spaces removed):
UUID=5e9fc3a3-2854-4eba-999e-d182914f5110 none swap sw 0 0
As you can see, there is only an entry for the swap partition (bug in the installer?). Still the system boots fine because the root partition gets mounted early in the boot.

If you want further information, just tell me. :)
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/08, 13:00:47
Let's see the output of

blkid -c /dev/null -o list

please.
Title: [SOLVED] Btrfs compression
Post by: dfe on 2013/01/08, 13:06:21
blkid -c /dev/null -o list:
device     fs_type label    mount point    UUID
-------------------------------------------------------------------------------
/dev/sda1  btrfs            (in use)       9952b0b0-4ceb-4479-9158-effe64120207
/dev/sda2  swap             <swap>         5e9fc3a3-2854-4eba-999e-d182914f5110
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/08, 13:25:55
I would use that UUID for /dev/sda1 and make a mount line in /etc/fstab for /.  You can see how to do it from my line in the post above.  You don't need the "device=xxxx" part, since it's only one device.
Title: [SOLVED] Btrfs compression
Post by: dfe on 2013/01/08, 13:48:58
Thanks, I will try it.
Still it's strange that the installer didn't added the root partition to fstab.
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/08, 15:15:38
I don't know how that works, either. I have only used btrfs for a data partition, not for the OS -- obviously there's something different about the way it is being installed when you do it from the live CD.  I'm sure you have read the wiki and the numerous ubuntu posts about it.  As usual, the arch folks have some good documentation, too:

https://wiki.archlinux.org/index.php/Installing_on_Btrfs_root
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/08, 19:44:02
BTW, after considering it for awhile, I would suppose that a btrfs filesystem using compression will probably slow your OS down, as compared to ext4.  You can let us know ....

:)
Title: [SOLVED] Btrfs compression
Post by: dfe on 2013/01/08, 21:33:51
Using compression should actually boost performance. At least if you have a decent CPU.
Here's a benchmark with pretty impressive results:
http://www.phoronix.com/scan.php?page=article&item=linux_btrfs_options&num=1
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/08, 22:19:02
Verrrrry interesting --- thanks!  It is counter-intuitive -- at least to my mind, that compressing and decompressing on the fly would result in faster performance, but there you have it.  I haven't changed my /etc/fstab since zlib was the only compression available.  It looks like I could pick up a bit of performance by changing it to lzo.  Although I'm not sure what "better performance" means when playing music and watching videos and such .....    :lol:
Title: [SOLVED] Btrfs compression
Post by: timc on 2013/01/08, 22:55:30
There are currently two types of compression used by btrfs. lzo gives less compression and an overall performance boost. zlib gives more compression at the cost of performance.

I use lzo on my root filesystem. I have not done any benchmarks, but performance feels very good. I have not tried zlib compression, but obviously it would be best used for mass storage where high compression is needed and performance doesn't really matter.

https://btrfs.wiki.kernel.org/index.php/Compression

Tim
Title: [SOLVED] Btrfs compression
Post by: agaida on 2013/01/09, 02:26:27
dibl: transparent compression can improve read performance in mech. devices. Real geeks use ssd to boot, eventually with hardware compression :)
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/09, 02:37:07
Yep, Alf, this geek uses a SSD to boot, and a cheap one!:

root@imerabox:/home/don# blkid -c /dev/null -o list
device                        fs_type     label        mount point                       UUID
------------------------------------------------------------------------------------------------------------------------------
/dev/sda1                     ext4                     /                                 bea3a748-3411-4024-acd0-39f3882ddaf9
/dev/sda2                     ext4        SDA2         /mnt/SDA2                         8cfe2acc-7572-4b45-b25f-ed021bb1d78b
/dev/sdb1                     ext4        revodata     /mnt/REVODATA                     ec21f5b3-7fd4-4f4b-af8d-cf787b147ae8
/dev/sdc1                     ext2                     /boot                             ac7da829-aebb-46f0-806c-04a4d81a945a
/dev/sdc2                     swap                     <swap>                            0d939b7d-48f1-47dd-aebe-77e7bd8c3503
/dev/sdd                      btrfs                    (in use)                          c112ed57-0e33-4d4b-82c9-5c55932c529d
/dev/sde                      btrfs                    (in use)                          c112ed57-0e33-4d4b-82c9-5c55932c529d
root@imerabox:/home/don#



root@imerabox:/home/don# hdparm -iI /dev/sdc

/dev/sdc:

Model=KINGSTON SS100S216G, FwRev=D100719a, SerialNo=16GAA0002142
Config={ Fixed }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=31277232
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes:  pio0 pio3 pio4
DMA modes:  mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=yes: unknown setting WriteCache=enabled
Drive conforms to: Unspecified:  ATA/ATAPI-4,5,6,7

* signifies the current active mode


ATA device, with non-removable media
       Model Number:       KINGSTON SS100S216G                    
       Serial Number:      16GAA0002142        
       Firmware Revision:  D100719a
       Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6
Standards:
       Supported: 8 7 6 5
       Likely used: 8
Configuration:
       Logical         max     current
       cylinders       16383   16383
       heads           16      16
       sectors/track   63      63
       --
       CHS current addressable sectors:   16514064
       LBA    user addressable sectors:   31277232
       LBA48  user addressable sectors:   31277232
       Logical  Sector size:                   512 bytes
       Physical Sector size:                   512 bytes
       Logical Sector-0 offset:                  0 bytes
       device size with M = 1024*1024:       15272 MBytes
       device size with M = 1000*1000:       16013 MBytes (16 GB)
       cache/buffer size  = unknown
       Form Factor: 2.5 inch
       Nominal Media Rotation Rate: Solid State Device
Capabilities:
       LBA, IORDY(can be disabled)
       Queue depth: 32
       Standby timer values: spec'd by Standard, no device specific minimum
       R/W multiple sector transfer: Max = 16  Current = 16
       Advanced power management level: 254
       DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
            Cycle time: min=120ns recommended=120ns
       PIO: pio0 pio1 pio2 pio3 pio4
            Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
       Enabled Supported:
          *    SMART feature set
               Security Mode feature set
          *    Power Management feature set
          *    Write cache
          *    Look-ahead
          *    Host Protected Area feature set
          *    WRITE_BUFFER command
          *    READ_BUFFER command
          *    DOWNLOAD_MICROCODE
          *    Advanced Power Management feature set
               SET_MAX security extension
          *    48-bit Address feature set
          *    Device Configuration Overlay feature set
          *    Mandatory FLUSH_CACHE
          *    FLUSH_CACHE_EXT
          *    SMART error logging
          *    SMART self-test
          *    General Purpose Logging feature set
          *    WRITE_{DMA|MULTIPLE}_FUA_EXT
          *    WRITE_UNCORRECTABLE_EXT command
          *    Gen1 signaling speed (1.5Gb/s)
          *    Gen2 signaling speed (3.0Gb/s)
          *    Native Command Queueing (NCQ)
          *    Phy event counters
          *    DMA Setup Auto-Activate optimization
          *    Software settings preservation
          *    Data Set Management TRIM supported (limit unknown)
Security:
       Master password revision code = 65534
               supported
       not     enabled
       not     locked
       not     frozen
       not     expired: security count
               supported: enhanced erase
       12min for SECURITY ERASE UNIT. 12min for ENHANCED SECURITY ERASE UNIT.
Checksum: correct
Title: [SOLVED] Btrfs compression
Post by: agaida on 2013/01/09, 03:25:56
dibl: I don't like btrfs very much (performancewise). It's to slow on writing. I've benched this a time ago and i'm not impressed. I would prefer btrfs on small devices like netbooks, where the fast reading make sense and the slow writing doesn't count ( aka i never ever will compile a kernel, a office suite or a browser on a netbook). :P
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/09, 03:34:33
No.  Alf, I think you do not understand the purpose of BTRFS -- it is only for the large data filesystems.  It has no advantage for a netbook, or the OS partition on a typical Linux installation.  It is for the big data server.
Title: [SOLVED] Btrfs compression
Post by: agaida on 2013/01/09, 03:36:42
;) - i think i understand btrfs. But i will never ever use it for a data server this time. I will have a second thought about using it on a server in 10 years.
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/09, 04:35:35
Quote from: "agaida"I will have a second thought about using it on a server in 10 years.

No problem -- in 2023, on 9 JAN, we will discuss how you will install BTRFS for your data partition.

:lol:
Title: [SOLVED] Btrfs compression
Post by: dfe on 2013/01/10, 12:49:59
Now, after running with compression for a day, I can say that everything is working fine. GRUB2 has no problems booting from the compressed filesystem. Thanks for all the help here.

Maybe it's of interest how I compressed the existing files on the fs.
After adding "compress=lzo" to the mount options and rebooting, I issued the following as root:cd / && find -xdev -type f -exec btrfs fi defrag -clzo '{}' \;
That shrinked the size of my install from around 3.6GB to 2.1GB.
Title: [SOLVED] Btrfs compression
Post by: dibl on 2013/01/10, 14:21:25
Very good!  There is also a "scrub" tool for btrfs, which I have used on my filesystem.  You can read about it in the wiki.

If you will please edit the title of your original post and add "SOLVED", then perhaps another user will find this thread helpful.  Thanks!