[LinuxLudus] fstrim

Valerio Pachera sirio81@gmail.com
Mar 4 Lug 2017 12:37:32 CEST


Ecco qua la dimostrazione di quanto scritto sopra.
Ho fatto un thin-volume da 5G e ci ho scritto 2 file da 512M.
Poi ho cancellato uno dei file.
Ho paragonato il *mapped size* prima e dopo la rimozione e non è variato.
Ho poi eseguito fstrim e lo spazio si è liberato.

lvcreate -V5G -T pve/pve-thin -n test
  Using default stripesize 64,00 KiB.
  Logical volume "test" created.
mkfs.ext4 /dev/pve/test
mke2fs 1.43.4 (31-Jan-2017)
Discarding device blocks: fatto
Creazione del file system con 1310720 4k blocchi e 327680 inode
Etichetta del file system=c24a4410-dabe-4b98-bfdf-43777088cd55
Backup del superblocco salvati nei blocchi:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: fatto
Scrittura delle tavole degli inode: fatto
Creating journal (16384 blocks): fatto
Scrittura delle informazioni dei super-blocchi e dell'accounting del file
system: fatto

mkdir /mnt/test
mount /dev/pve/test /mnt/test
dd if=/dev/urandom of=/mnt/test/garbage1 bs=1M count=512
dd if=/dev/urandom of=/mnt/test/garbage2 bs=1M count=512

lvdisplay /dev/pve/test
  --- Logical volume ---
  LV Path                /dev/pve/test
  LV Name                test
  VG Name                pve
  LV UUID                HDvbtK-pQjQ-Izqw-KevC-obNE-100W-lU0D0e
  LV Write Access        read/write
  LV Creation host, time vmserver, 2017-07-04 12:26:12 +0200
  LV Pool name           pve-thin
  LV Status              available
  # open                 1
  LV Size                5,00 GiB
  Mapped size            22,89%
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:9


rm /mnt/test/garbage2

lvdisplay /dev/pve/test
  --- Logical volume ---
  LV Path                /dev/pve/test
  LV Name                test
  VG Name                pve
  LV UUID                HDvbtK-pQjQ-Izqw-KevC-obNE-100W-lU0D0e
  LV Write Access        read/write
  LV Creation host, time vmserver, 2017-07-04 12:26:12 +0200
  LV Pool name           pve-thin
  LV Status              available
  # open                 1
  LV Size                5,00 GiB
*  Mapped size            22,89%*
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:9


fstrim /mnt/test

lvdisplay /dev/pve/test
  --- Logical volume ---
  LV Path                /dev/pve/test
  LV Name                test
  VG Name                pve
  LV UUID                HDvbtK-pQjQ-Izqw-KevC-obNE-100W-lU0D0e
  LV Write Access        read/write
  LV Creation host, time vmserver, 2017-07-04 12:26:12 +0200
  LV Pool name           pve-thin
  LV Status              available
  # open                 1
  LV Size                5,00 GiB
*  Mapped size            12,89%*
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:9
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.linux.it/pipermail/ll/attachments/20170704/cea6daf0/attachment.html>


Maggiori informazioni sulla lista ll