Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

531
Views
Yii2: Reducing inodes usage on vServer

On my Linux vServer the inodes are limited (e.g. 250.000). I found that an Yii2 installation requires quite a lot of inodes. The number of inode is roughly the number of files and directories.

The number of inodes used in the current directory and its subdirectories can be determined with

find .  -xdev -printf '%h\n' | sort | uniq -c | awk '{total = total + $1}END{print total}'

An average of my Yii2 projects is about 30k inodes. There are not much in files in ./web/assets, in the ./runtime or ./web/images folders. Most of the inodes are used in the ./vendor directory.

So the number of my Yii2 projects is limited to 8 projects.

What can I do to reduce inode usage in Yii2 projects?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Assuming you have root in your Linux vServer, you can embed a new filesystem in a single file and mount it. Such a file would take only a single inode in the parent filesystem while the number of inodes within the image is up to you.

# dd if=/dev/zero of=myfs bs=1MB count=512
512+0 records in
512+0 records out
512000000 bytes (512 MB) copied, 4.10134 s, 125 MB/s
# losetup --find --show `pwd`/myfs
/dev/loop0
# mkfs -t ext4 -i 1024 /dev/loop0
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done
Creating filesystem with 500000 1k blocks and 500464 inodes
Filesystem UUID: fef5ab29-8991-4f99-8a27-80b4d11b3133
Superblock backups stored on blocks:
        8177, 24529, 40881, 57233, 73585, 204401, 220753, 400625

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

# mount /dev/loop0 /mnt
# df -i | sed -n '1p;/mnt/p'
Filesystem     Inodes  IUsed  IFree IUse% Mounted on
/dev/loop0     500464     11 500453    1% /mnt

Here, I chose ext4 and set the bytes-per-inode, -i, to its minimum value, giving the largest inode count, 500464, for 512MiB on ext4.

You could make multiple filesystems this way, one for each project, or make a much larger one with many more inodes.

To mount the image at the next reboot, add a line to /etc/fstab.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!