In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how linux uses mergefs to increase virtual storage, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Install and configure mergefs
Use sudo to install the downloaded mergefs package:
$sudo dnf install mergerfs-2.29.0-1.fc31.x86_64.rpm
Now, you can mount multiple disks as one drive. This will be convenient if you have a media server and want all media files to be displayed in one place. If you upload new files to the system, you can copy them to the mergefs directory, and mergefs will automatically copy them to a disk with enough space available.
This is an example that makes it easier for you to understand:
$df-hT | grep disk/dev/sdb1 ext4 23M 386K 21M 2% / disk1/dev/sdc1 ext4 44M 1.1M 40M 3% / disk2 $ls-l / disk1/Videos/total 1 RWKui Raffy. 1 curt curt 0 Mar 8 17:17 Our Wedding.mkv $ls-l / disk2/Videos/total 2 Murray RW Murray. 1 curt curt 0 Mar 8 17:17 Baby's first Xmas.mkv-rw-rw-r--. 1 curt curt 0 Mar 8 17:21 Halloween hijinks.mkv
In this example, two disks, disk1 and disk2, are mounted. Both drives have a Videos directory that contains files.
Now, we will mount these drives using mergefs to make them look like a larger drive.
$sudo mergerfs-o defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M / disk1:/disk2 / media
The mergefs man pages are very complex, so we will explain the options mentioned above.
Defaults: unless specified, the default settings are used.
Allow_other: allows users other than sudo or root to view the file system.
Use_ino: have mergefs provide the file / directory inode instead of libfuse. Although it is not the default value, it is recommended that you enable it so that linked files share the same inode value.
Category.create=mfs: propagates files between drives based on available space.
Moveonenospc=true: if enabled, then if the write fails, a scan will be performed to find the drive with the maximum available space.
Minfreespace=1M: the minimum usage space value.
Disk1: the first hard drive.
Disk2: second hard drive.
/ media: the directory where the drive is mounted.
It looks like this:
$df-hT | grep disk/dev/sdb1 ext4 23M 386K 21M 2% / disk1/dev/sdc1 ext4 44M 1.1M 40m 3% / disk2 $df-hT | grep media1:2 fuse.mergerfs 66M 1.4M 60M 3% / media
You can see that the total capacity displayed by the mergefs mount is 66m, which is the total capacity of the two hard drives.
Continue with the example:
There is a 30m video called Baby's second Xmas.mkv. Let's copy it to the / media folder mounted with mergerfs.
$ls-lh "Baby's second Xmas.mkv"-rw-rw-r--. 1 curt curt 30m Apr 20 08:45 Baby's second Xmas.mkv$ cp "Baby's second Xmas.mkv" / media/Videos/
This is the end result:
$df-hT | grep disk/dev/sdb1 ext4 23M 386K 21M 2% / disk1/dev/sdc1 ext4 44M 31m 9.8m 76% / disk2 $df-hT | grep media1:2 fuse.mergerfs 66M 31m 30M 51% / media
As you can see from the disk space utilization, because disk1 does not have enough free space, mergefs automatically copies files to disk2.
Here are the details of all the documents:
$ls-l / disk1/Videos/total 1 RW Murray RMI Murray. 1 curt curt 0 Mar 8 17:17 Our Wedding.mkv $ls-l / disk2/Videos/total 30003Murray RW Murray. 1 curt curt 0 Mar 8 17:17 Baby's first Xmas.mkv-rw-rw-r--. 1 curt curt 30720000 Apr 20 08:47 Baby's second Xmas.mkv-rw-rw-r--. 1 curt curt 0 Mar 8 17:21 Halloween hijinks.mkv $ls-l / media/Videos/total 30004Murray RW Murray. 1 curt curt 0 Mar 8 17:17 Baby's first Xmas.mkv-rw-rw-r--. 1 curt curt 30720000 Apr 20 08:47 Baby's second Xmas.mkv-rw-rw-r--. 1 curt curt 0 Mar 8 17:21 Halloween hijinks.mkv-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Our Wedding.mkv
When you copy a file to the mergefs mount point, it will always copy the file to a hard disk with enough free space. If all the drives in the pool do not have enough free space, you will not be able to copy them.
Thank you for reading this article carefully. I hope the article "linux how to use mergefs to increase virtual storage" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Heartbeat+DRBD+MySQL highly available scenarios =
© 2024 shulou.com SLNews company. All rights reserved.