Difference between revisions of "SnapRAID / MergerFS"
From Briki
(→Identifying/Fixing a bad block) |
(→Identifying/Fixing a bad block) |
||
Line 36: | Line 36: | ||
ddrescue --ask --verbose --binary-prefixes --idirect --force /dev/sdX /dev/null sdX.map | ddrescue --ask --verbose --binary-prefixes --idirect --force /dev/sdX /dev/null sdX.map | ||
</pre> | </pre> | ||
− | * ddrescue will write out a map file containing start positions and sizes (all in bytes) | + | * ddrescue will write out a map file containing start positions and sizes (all in bytes) of good (+) and bad (-) byte ranges |
* Get the block size for the volume with <code>tune2fs -l /dev/sdXY | grep "Block size"</code> (we'll call this '''B'''). In my case this is 4096. | * Get the block size for the volume with <code>tune2fs -l /dev/sdXY | grep "Block size"</code> (we'll call this '''B'''). In my case this is 4096. | ||
* Get the sector size for the disk with <code>fdisk -l /dev/sdX | grep Units</code> (we'll call this '''S'''). In my case this is 512. | * Get the sector size for the disk with <code>fdisk -l /dev/sdX | grep Units</code> (we'll call this '''S'''). In my case this is 512. | ||
* Identify the starting sector for the /dev/sdXY volume (eg. /dev/sda1) with <code>fdisk -l /dev/sdX</code> (we'll call this '''T'''). In my case this is 2048. | * Identify the starting sector for the /dev/sdXY volume (eg. /dev/sda1) with <code>fdisk -l /dev/sdX</code> (we'll call this '''T'''). In my case this is 2048. | ||
− | * | + | * Run ddrescuelog to list out the bad block locations (using the block size B): |
+ | <pre> | ||
+ | ddrescuelog -b B --list-blocks=- sdX.map | ||
+ | </pre> | ||
+ | * For each of these, convert to a block location in the volume (rather than the disk) by subtracting <code>(T * S / B)</code>. In my case that's 256. | ||
+ | |||
More details: | More details: | ||
* https://www.smartmontools.org/wiki/BadBlockHowto | * https://www.smartmontools.org/wiki/BadBlockHowto | ||
* [[Mdadm#Repairing_failing_disk_on_degraded_array]] | * [[Mdadm#Repairing_failing_disk_on_degraded_array]] |
Revision as of 08:31, 26 April 2022
Contents
SnapRAID / MergerFS
Setup
https://zackreed.me/setting-up-snapraid-on-ubuntu/
Note that if (like me) you use a dedicated snapraid content directory then you'll need to create that by hand for each disk with:
mkdir /mnt/data/disk1/.snapraid
Partitioning a new data disk
Note: "-m 2" here reserves 2% of the filesystem for root-owned files (eg. .../.snapraid/content)
sudo parted -a optimal -s /dev/sdX -- mklabel gpt mkpart primary 0% 100% sudo mkfs.ext4 -m 2 -T largefile4 /dev/sdX1
Partitioning a new parity disk
Note: "-m 0" here reserves 0% of the filesystem, ensuring that the parity disks are slightly larger than the data disks
sudo parted -a optimal -s /dev/sdX -- mklabel gpt mkpart primary 0% 100% sudo mkfs.ext4 -m 0 -T largefile4 /dev/sdX1
Adding a new data disk to mergerfs
From: https://zackreed.me/mergerfs-neat-tricks/ From within the root of the mergerfs filesystem (eg. /srv)
xattr -w user.mergerfs.srcmounts '+>/mnt/data/disk4/srv' .mergerfs
Removing a data disk from mergerfs
From within the root of the mergerfs filesystem (eg. /srv)
xattr -w user.mergerfs.srcmounts '-/mnt/data/disk4/srv' .mergerfs
Forcing a resync
sudo snapraid sync
Identifying/Fixing a bad block
- Run ddrescue to identify the failing bytes on the disk:
ddrescue --ask --verbose --binary-prefixes --idirect --force /dev/sdX /dev/null sdX.map
- ddrescue will write out a map file containing start positions and sizes (all in bytes) of good (+) and bad (-) byte ranges
- Get the block size for the volume with
tune2fs -l /dev/sdXY | grep "Block size"
(we'll call this B). In my case this is 4096. - Get the sector size for the disk with
fdisk -l /dev/sdX | grep Units
(we'll call this S). In my case this is 512. - Identify the starting sector for the /dev/sdXY volume (eg. /dev/sda1) with
fdisk -l /dev/sdX
(we'll call this T). In my case this is 2048. - Run ddrescuelog to list out the bad block locations (using the block size B):
ddrescuelog -b B --list-blocks=- sdX.map
- For each of these, convert to a block location in the volume (rather than the disk) by subtracting
(T * S / B)
. In my case that's 256.
More details: