Home > Backend Development > PHP Tutorial > On the Linux platform, is there any software that can create virtual files that point to multiple files to avoid duplication of space?

On the Linux platform, is there any software that can create virtual files that point to multiple files to avoid duplication of space?

WBOY
Release: 2023-03-03 08:12:02
Original
1094 people have browsed it

Running platform: CentOS

Requirements: similar to this

/opt/virtual.file points to: /opt/1.file /opt/2.file /opt/3.file

First of all, I know the merge command, but this will create a new file and take up space

What I want is to access /opt/virtual.file, ​​which is equivalent to the system dynamically merging these three files into one and accessing them as one

This requirement is not a request to merge js/css using nginx_http_concat

In order to ensure stability when uploading files, upload them separately according to 5M/block. Although you can also use a program to merge these blocks, is there any software that allows the system to make virtual files and point to these blocks? No need to merge

Reply content:

Running platform: CentOS

Requirements: similar to this

/opt/virtual.file points to: /opt/1.file /opt/2.file /opt/3.file

First of all, I know the merge command, but this will create a new file and take up space

What I want is to access /opt/virtual.file, ​​which is equivalent to the system dynamically merging these three files into one and accessing them as one

This requirement is not a request to merge js/css using nginx_http_concat

In order to ensure stability when uploading files, upload them separately according to 5M/block. Although you can also use a program to merge these blocks, is there any software that allows the system to make virtual files and point to these blocks? No need to merge

This must be implemented using fuse, and written by a master: https://github.com/schlaile/c...

  1. Install and compile concatfs

    <code>yum install fuse fuse-devel
    git clone https://github.com/schlaile/concatfs.git
    cd concatfs/src
    gcc -Wall concatfs.c `pkg-config fuse --cflags --libs` -o concatfs
    cp ./concatfs /bin</code>
    Copy after login
  2. Start a directory using mounting method
    Original directory:
    /opt/www/website/
    It contains files
    index.html test.html
    Create a directory to be mounted
    mkdir /opt/www/website_mnt
    Execute
    concatfs /opt/www/website/ /opt/www/website_mnt
    No error is reported and it is already running in the background

  3. Create a special filename containing -concat-

    As long as -concat- is included, it will be specially parsed by concatfs

    <code>vim /opt/www/website/1-concat-.txt</code>
    Copy after login

    Content

    <code>index.html
    test.html</code>
    Copy after login

    Note that the end column also needs to have a carriage return character LF, otherwise the last file will not be loaded

  4. Now visit /opt/www/website_mnt/1-concat-.txt and the data after merging these two files will be returned
    It is equivalent to the two files being dynamically merged, but in fact they are not merged physically
    Note It is the website_mnt/1-concat-.txt directory
    Access the original directory website/1-concat-.txt It is still the original file

  5. PS: There is no test of writing /opt/www/website_mnt/1-concat-.txt

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template