User:Wuseman/rar2fs

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

sys-fs/rar2fs is a FUSE based file system that can mount a source RAR archive/volume or a directory containing any number of RAR archives and read the contents as regular files on-the-fly. Non-archived files located in the source directory are handled transparently.

Installation

USE Flags

USE flags for sys-fs/rar2fs A FUSE based filesystem that can mount one or multiple RAR archive(s)

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces

Emerge

root #emerge --ask sys-fs/rar2fs

Installation from Source

Dependencies

Install necessary dependencies:

root #emerge --ask sys-fs/fuse
root #emerge --ask app-arch/rar
root #emerge --ask app-arch/unrar

Install Rar

Download and install rar and unrar from rarlab:

1. Download and extract RarLinux from source:

user $tar -xvzf /tmp/rarlinux-x64-701.tar.gz -C /tmp/

2. Build and install RarLinux:

root #make -j$(($(nproc)+1)) -l$(($(nproc)+2)) -f /tmp/rar/makefile -C /tmp/rar

Install Unrar

Download and install the latest unrarlib from source:

FILE Build and Install Unrar from Sourceunrarsrc-installer.sh
#!/bin/sh 

# This script automates the download, compilation, and installation of unrar from source.

# Download unrarsrc-7.0.8.tar.gz from rarlab.com
wget https://www.rarlab.com/rar/unrarsrc-7.0.8.tar.gz -P /tmp/

# Extract the downloaded archive to /tmp/
tar -xvzf /tmp/unrarsrc-7.0.8.tar.gz -C /tmp

# Build libunrar.so with maximum threads available
make lib -j$(($(nproc) + 1)) -l$(($(nproc) + 2)) -C /tmp/unrar

# Install libunrar.so to system directories
make install-lib -C /tmp/unrar -f /tmp/unrar/makefile

# Clean the build directory (this is for avoid issues with libunrar.so)
# https://github.com/hasse69/rar2fs/wiki#q-23-i-get-the-libfuseso-or-compatible-library-not-found-message-when-i-try-to-run
make clean -j$(($(nproc) + 1)) -l$(($(nproc) + 2)) -C /tmp/unrar -f /tmp/unrar/makefile

# Compile unrar binary with multiple threads
make -j$(($(nproc) + 1)) -l$(($(nproc) + 2)) -C /tmp/unrar -f /tmp/unrar/makefile

# Install unrar binary to system
make install -C /tmp/unrar

# Cleanup extracted files
rm -rf -v /tmp/unrar{-7.0.8.tar.gz}

Install rar2fs

Clone the sys-fs/rar2fs repository and install:

FILE Installer for rar2fsrar2fs-installer.sh
#!/bin/sh git clone https://github.com/hasse69/rar2fs.git -C /tmp/rar2fs
cd /tmp/rar2fs
autoreconf -f -i
./configure --with-unrar=/tmp/unrar
make -j$(($(nproc)+1)) -l$(($(nproc)+2)) -C /tmp/rar2fs
make install -C /tmp/rar2fs

Usage

Mounting

Mount a RAR archive:

user $rar2fs -o allow_other /path/to/rararchive /path/to/mount/point

Unmounting

Unmount a mounted RAR archive:

user $fusermount -u /path/to/mount/point

Automount with /etc/fstab

To enable automounting of rar archives using rar2fs, follow these steps:

1. Install fuse if not already installed:

root #emerge --ask sys-fs/fuse

2. Edit /etc/fstab to include the automount entry:

Use your preferred text editor to open /etc/fstab:

user $vim /etc/fstab

3. Add the following line at the end of the file:

FILE /etc/fstab/etc/fstab
rar2fs#/path/to/rararchive /path/to/mountpoint fuse allow_other,--seek-length=1 0 0

4. Save and close the file.

5. Test the /etc/fstab entry:

root #mount -a

This command mounts all filesystems listed in /etc/fstab, including the new rar2fs entry.

Replace ~/rar/path with the actual path to your RAR archive and /mnt/rar2fs with the directory where you want to mount the archive.

Autofs

Autofs provides on-demand mounting and unmounting of filesystems based on access needs. It helps manage resources efficiently by automatically mounting filesystems when they are accessed and unmounting them after a period of inactivity.

Setting Up Autofs

To set up Autofs for managing RAR archives with sys-fs/rar2fs, follow these steps:

1. Install Autofs if not already installed:

root #emerge --ask sys-fs/autofs

2. Edit /etc/auto.master to include the configuration for RAR archives:

Use your preferred text editor to open /etc/auto.master:

user $vim /etc/auto.master

3. Add the following line at the end of the file to include the configuration for rar2fs:

FILE /etc/auto.master/etc/auto.master
/mnt/rar2fs        /etc/auto.rar2fs        --timeout=120 --ghost

This configuration specifies that Autofs should manage mounts under /mnt/rar2fs using the settings defined in /etc/auto.rar2fs.

4. Create /etc/auto.rar2fs to define the mount points and options:

Use your preferred text editor to create /etc/auto.rar2fs:

user $vim /etc/auto.rar2fs

5. Add the following lines to define the mount points and options for rar2fs:

FILE /etc/auto.rar2fsConfiguring mount points and options for rar2fs
/mnt/rar2fs/rar-movies  -fstype=fuse,ro,allow_other,noatime,umask=222,--seek-length=2  :rar2fs#/mnt/rar2fs/nas1/rar-movies
/mnt/rar2fs/rar-videos  -fstype=fuse,ro,allow_other,noatime,umask=222,--seek-length=2  :rar2fs#/mnt/rar2fs/nas2/rar-videos

Restart Autofs to apply the changes:

Restart autofs

OpenRC

To restart autofs using OpenRC, use the following command:

root #/etc/init.d/autofs restart

Systemd

To restart autofs using systemd, follow these steps:

1. Reload systemd daemon to apply any changes in configuration files:

root #systemctl daemon-reload

2. Restart the autofs service:

root #systemctl restart autofs

FUSE Options

The following are additional FUSE options that can be used with rar2fs:

user $rar2fs --help
usage: rar2fs source mountpoint [options]

general options:
    -o opt,[opt...]        mount options
    -h   --help            print help
    -V   --version         print version

FUSE options:
    -d   -o debug          enable debug output (implies -f)
    -f                     foreground operation
    -s                     disable multi-threaded operation

    -o allow_other         allow access to other users
    -o allow_root          allow access to root
    -o auto_unmount        auto unmount on process termination
    -o nonempty            allow mounts over non-empty file/dir
    -o default_permissions enable permission checking by kernel
    -o fsname=NAME         set filesystem name
    -o subtype=NAME        set filesystem type
    -o large_read          issue large read requests (2.4 only)
    -o max_read=N          set maximum size of read requests

    -o hard_remove         immediate removal (don't hide files)
    -o use_ino             let filesystem set inode numbers
    -o readdir_ino         try to fill in d_ino in readdir
    -o direct_io           use direct I/O
    -o kernel_cache        cache files in kernel
    -o [no]auto_cache      enable caching based on modification times (off)
    -o umask=M             set file permissions (octal)
    -o uid=N               set file owner
    -o gid=N               set file group
    -o entry_timeout=T     cache timeout for names (1.0s)
    -o negative_timeout=T  cache timeout for deleted names (0.0s)
    -o attr_timeout=T      cache timeout for attributes (1.0s)
    -o ac_attr_timeout=T   auto cache timeout for attributes (attr_timeout)
    -o noforget            never forget cached inodes
    -o remember=T          remember cached inodes for T seconds (0s)
    -o nopath              don't supply path if not necessary
    -o intr                allow requests to be interrupted
    -o intr_signal=NUM     signal to send on interrupt (10)
    -o modules=M1[:M2...]  names of modules to push onto filesystem stack

    -o max_write=N         set maximum size of write requests
    -o max_readahead=N     set maximum readahead
    -o max_background=N    set number of maximum background requests
    -o congestion_threshold=N  set kernel's congestion threshold
    -o async_read          perform reads asynchronously (default)
    -o sync_read           perform reads synchronously
    -o atomic_o_trunc      enable atomic open+truncate support
    -o big_writes          enable larger than 4kB writes
    -o no_remote_lock      disable remote file locking
    -o no_remote_flock     disable remote file locking (BSD)
    -o no_remote_posix_lock disable remove file locking (POSIX)
    -o [no_]splice_write   use splice to write to the fuse device
    -o [no_]splice_move    move data while splicing to the fuse device
    -o [no_]splice_read    use splice to read from the fuse device

Module options:

[iconv]
    -o from_code=CHARSET   original encoding of file names (default: UTF-8)
    -o to_code=CHARSET      new encoding of the file names (default: UTF-8)

[subdir]
    -o subdir=DIR           prepend this directory to all paths (mandatory)
    -o [no]rellinks         transform absolute symlinks to relative

rar2fs options:
    --exclude=F1[;F2...]    exclude file filter
    --seek-length=n         set number of volume files that are traversed in search for headers [0=All]
    --iob-size=n            I/O buffer size in 'power of 2' MiB (1,2,4,8, etc.) [4]
    --hist-size=n           I/O buffer history size as a percentage (0-75) of total buffer size [50]
    --save-eof              force creation of .r2i files (end-of-file chunk)
    --no-lib-check          disable validation of library version(s)
    --no-expand-cbr         do not expand comic book RAR archives
    --no-smp                disable SMP support (bind to CPU #0)
    --relatime              update file access times relative to modify or change time
    --relatime-rar          like --relatime but also update main archive file(s)
    --date-rar              use file date from main archive file(s)
    --config=file           config file name [source/.rarconfig]
    --no-inherit-perm       do not inherit file permission mode from archive

    -o locale=LOCALE        set the locale for file names (default: according to LC_*/LC_CTYPE)
    -o warmup[=THREADS]     start background cache warmup threads (default: 5)