📜 ⬆️ ⬇️

Gentoo: configuring and connecting via / dev / loop filesystem with compression using Reiser4 as an example

Small is smaller
I have several VPS'ok with Gentoo, running under VMWare, for which I, having shabby, allocated only 7G of disk space. Once, after the release of the next version of gcc, one of them ran out of space. Rummaging, I discovered that the main consumers were the directories / usr / src and / usr / portage. Immediately the idea was born to move them to a file system with compression (yeah, to NTFS) and the choice fell on Reiser4, since this data is ideal for it - a lot of files and they are all small.

There is a lot of conflicting information about this file system on the network (2013), but perhaps you should read the article (2010) by the lead developer.
Quote from the article:
over the past four years, I don’t remember that someone would lose data on the reiser4 section when the hardware is working properly. I was approached by several people complaining about the work of fsck. In the end, they all received both their data and a working fsck.
Do not be afraid of her ...

I want to emphasize that, as they are often confused among themselves, Reiser4 is not the same as ReiserFS. These are two different file systems! ReiserFS has long been living in the main kernel of the kernel, but for Reiser4, although it was born back in 2004, it will have to apply a patch, which, it should be noted, is regularly updated for new kernel versions.

Download and apply the patch according to your kernel version (on my linux-3.10.25-gentoo system) from this page
')
Let's say it can be done like this:
cd /usr/src/linux wget -O reiser4-for-3.10.patch.gz 'http://downloads.sourceforge.net/project/reiser4/reiser4-for-linux-3.x/reiser4-for-3.10.patch.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Freiser4%2Ffiles%2Freiser4-for-linux-3.x%2F&ts=1393599138&use_mirror=heanet' gunzip reiser4-for-3.10.patch.gz && patch -p1 < reiser4-for-3.10.patch 

We configure our core. Please note - ReiserFS support is not required. The screen of my particular system, yours may have other settings, but now we are only interested in:
File Systems -> Reiser4
image

and do not forget about:
Device Drivers> Block devices -> Loopback device support
image

Here is an example of a real sequence of commands and actions that I performed on my server, all of a sudden, someone will come in handy:
 ;    make menuconfig ;   : ;   ,     make && make modules_install ;     /boot,   .   : mount /boot && cp arch/x86_64/boot/bzImage /boot/kernel-3.10.25 && cp .config /boot/.config-3.10.25 

Since I put a completely new kernel, I need to correct the bootloader settings, I use GRUB:
 vi /boot/grub/grub.conf 

The working entry for the new kernel looks like this (just for example, you may have something completely different):
 title Gentoo Linux 3.10.25 md0 root (hd0,0) kernel /boot/kernel-3.10.25 root=/dev/md0 net.ifnames=0 

You shouldn’t do it by default with the default configuration; first, we restart the server and make sure that everything is fine.

We make a control measurement of free disk space:
 df -h ;  (    ) Filesystem Size Used Avail Use% Mounted on /dev/md0 7.4G 4.1G 2.9G 59% / ;      du --summarize -h /usr/portage ; 2.2G /usr/portage du --summarize -h /usr/src ; 766M /usr/src 

We stock up on popcorn with validol and ...
 umount /boot && reboot 

Do not forget the pens to choose a new kernel configuration to boot:
image
I hope your server is still with you ...

We have already eaten the first and second, we proceed to the dessert - creating a loop device and mounting a disk image with Reiser4 onto it:
 ;      Reiser4 emerge reiser4progs ;        cd /mnt && truncate -s 2G reiser4.img ;      du -h reiser4.img ; 0 reiser4.img du --apparent-size -h reiser4.img ;2.0G reiser4.img ;      /dev/loop0 losetup /dev/loop0 /mnt/reiser4.img ;      gzip (  lzo,    , ,   ,   ).   ,         Reiser4 mkfs.reiser4 -f -o create=ccreg40,compress=gzip1 /dev/loop0 

image

Finally, we mount our new "drive":
 ;  ,     /etc/fstab echo '/mnt/reiser4.img /mnt/reiser4 reiser4 loop,noatime 0 0' >> /etc/fstab ;    mkdir reiser4 ;  ... ... mount /mnt/reiser4 ; ... ,    mount | grep mnt ;  - /mnt/reiser4.img on /mnt/reiser4 type reiser4 (rw,noatime) 

We move the required directories to a new place of residence (here you can drink a cup of coffee and do other things)
 mv /usr/portage /mnt/reiser4 && ln -s /mnt/reiser4/portage /usr/portage mv /usr/src /mnt/reiser4 && ln -s /mnt/reiser4/src /usr/src 

Everything, you can make a control and calculate the profit:
 df -h ;  -      1.2G Filesystem Size Used Avail Use% Mounted on /dev/md0 7.4G 2.9G 4.2G 41% / devtmpfs 1004M 0 1004M 0% /dev tmpfs 201M 392K 201M 1% /run shm 1004M 0 1004M 0% /dev/shm cgroup_root 10M 0 10M 0% /sys/fs/cgroup /dev/loop1 2.0G 1.8G 191M 91% /mnt/reiser4 ;  - reiser4.img  1.8G ;              : mount | grep mnt ;  - /mnt/reiser4.img on /mnt/reiser4 type reiser4 (rw,noatime) ;   portage,  emerge -p world 

Total: our source took 3.9G, after packaging this value decreased to 1.8G, or 46% (shrunk more than twice!) From the original size. Trifle, of course, but nice.

I have been using this configuration for about a year without any problems, 2G has never ended, the kernel did not panic, and the CPU did not deal with it during emerge -DNu world. However, there is still one drawback, if in such a container the place runs out, in order to increase its size, you will have to create a new file of a larger size and pour all the contents from the old file into it. Unfortunately, the resize_reiser4 utility is still not written by anyone. Perhaps, if someone knows another way to increase the size of this file system, please share in the comments. And in what file systems, besides NTFS and BRTFS, is there support for transparent data compression?

Quote from the article, a link to which is given at the beginning of the post:
It has been shown that it has been a limited number of cases. There is no major development for users of the Linux system. At this time, however, it’s not a formal plan for merging.

Source: https://habr.com/ru/post/214255/


All Articles