Lotus Breath Blog

  • Magento - No more available Inodes for your disk ?

    I encountered a problem on my Magento site that my disk is still available for space, but the new files can not be stored any more. It maybe strange!

    Actually, beside a limit of amount of space for a disk, Linux has also a limit of number of Inodes. Linux stores some information for each file in Inodes. Each file has a respective inode. If you want know how many Inodes are used or still be available on your disk, you can type a command

    $df -i

    Filesystem Inodes IUsed IFree IUse% Mounted on
    /dev/sda1 2621440 1773765 847675 68% /
    udev 472926 281 472645 1% /dev
    tmpfs 475124 318 474806 1% /run
    tmpfs 475124 1 475123 1% /dev/shm
    tmpfs 475124 8 475116 1% /run/lock
    tmpfs 475124 13 475111 1% /sys/fs/cgroup

    If your disk has no available inodes you can not create any files on your disk. The more files are created the more inodes are made. In order to frees inodes, you need to delete unnecessary files. In Magento, files are stored in folder /var/session and /var/report  are created frequently. For session files, it stores session information while client users are interacting with your site but they will not be used anymore when a session is terminated or expired. Maybe it has a lot of session files in your server, maybe more than ten thousands.

    There are several ways to delete those files, you can delete folder session and create it again. For me, I type a command below to delete all session files that created from the past to yesterday.

    sudo find [Magento Root]/var/session/ -type f -mtime +1 -delete;

    You can use other command to do it, example :

    find var/session/* -mtime +X -exec rm {} \;

    X is number of days

    But a best way to prevent this problem is to configure a php settings to remove expired session files automatically

    ; The probability is calculated by using gc_probability/gc_divisor,
    ; e.g. 1/100 means there is a 1% chance that the GC process starts
    ; on each request.
    session.gc_probability = 1
    session.gc_divisor = 100
    ; After this number of seconds, stored data will be seen as 'garbage' and
    ; cleaned up by the garbage collection process.
    session.gc_maxlifetime = 1440

    It's done. And You can forget it right away!!!

  • Resize AWS EC2 Disk - Debian

    How to resize a disk size attached to your AWS EC2 instance? Here something I did to and it was working well for me.

    I do something on AWS console to change my disk size, ex resizing a disk from 40G to 80G

    Then I go to my server via SSH. Firstly,  type command to list all block devices attached to my instance


    $ lsblk


    xvda 202:0 0 80G 0 disk

    └─xvda1 202:1 0 40G 0 part / xvdb 202:16 0 30G 0 disk

    /mnt xvdf 202:80 0 35G 0 disk └─xvdf1 202:81 0 8G 0 part


    For example,  My Xvda1 only takes 40G but I want to use all 80G for it.

    I use comand parted  to attach 100% disk ( 80G ) amount to  my xvda1

    parted ---pretend-input-tty /dev/xvda resizepart 1 yes 100%

    Warning: Partition /dev/xvda1 is being used. Are you sure you want to continue? Information: You may need to update /etc/fstab.

    I check again, I can see full 80G to attached to xvda1



    xvda 202:0 0 80G 0 disk

    └─xvda1 202:1 0 80G 0 part / xvdb 202:16 0 30G 0 disk

    /mnt xvdf 202:80 0 35G 0 disk └─xvdf1 202:81 0 8G 0 part


    Finally, I type a resize2fs /dev/xvda1. You also can reboot your instance.

    It's done!!!!

  • Inserting widgets to product description editor

    Magento 1.x does not allow to add a widget from a product description editor. But in some cases, we need to have this functionality to add some dynamic content ( widgets, blocks). So we create a small patch to solve this problem. Please download and try it in your store from here https://github.com/LotusBreath/Magento1xFixing/tree/master/product_editor



3 Item(s)