markfasheh / duperemove

Tools for deduping file systems
GNU General Public License v2.0
816 stars 81 forks source link

Error 30: Read-only file system with snapper ro snapshots #162

Closed darkbasic closed 7 years ago

darkbasic commented 7 years ago

Hi, I would like to use duperemove 0.11 git in a btrfs fs with with snapper snapshots. Unfortunately I get tons of "Error 30: Read-only file system while opening "/.../@snapshots/4385/...". How should I use duperemove in a fs with tons of snapper snapshots?

I do not run duperemove from a live distro, instead I run it directly from the system I want to deduplicate:

sudo mount -o noatime,compress=lzo,autodefrag /dev/mapper/cryptroot /home/niko/nosnap/rootfs/ sudo duperemove -drh --hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

I should also probably add --dedupe-options=nofiemap but this has nothing to do with this issues.

darkbasic commented 7 years ago

Here is my workaround:

sudo mount -o noatime,compress=lzo,autodefrag /dev/mapper/cryptroot /home/niko/nosnap/rootfs/

rm ro_snapshots;

for snapshot in $(sudo btrfs subvolume list -p /home/niko/nosnap/rootfs | awk '{ print $11 }'); do
  ro=$(btrfs property get -ts /home/niko/nosnap/rootfs/${snapshot} | awk -F  "=" '{print $2}');
  if [ "${ro}" == "true" ]; then
    sudo btrfs property set -ts /home/niko/nosnap/rootfs/${snapshot} ro false;
  fi;
done

time sudo duperemove -drh --dedupe-options=nofiemap --hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

for snapshot in $(cat ro_snapshots); do
  sudo btrfs property set -ts /home/niko/nosnap/rootfs/${snapshot} ro true;
done

sudo umount rootfs/