0

Some time ago, I moved the folder /usr to its own partition. Before this it had lived in the / partition which has a btrfs filesystem.

Accidentally, I formatted my /usr partition from my Windows XP OS.

Using an Xubuntu LiveCD, I can see there are three snapshots, two of which contain my old /usr.

I am wondering if I can recover my /usr from the snapshots taken by btrfs?

Can I just copy the contents of the snapshot to /usr?

1 Answer 1

0

Thanks to Btrfs and the good snapshots (at least it looks good to me, CoW snapshot of the whole /)

You need to mount the snapshot (it works just like a subvolume) and they copy the files over properly (using rysnc)

Steps (I recommend doing this from a Live DVD/USB system):

  1. mount the snapshot to a temporary mount point, for example /mnt/snapshot

mount -t btrfs -o subvol=apt-snapshot-xxx block_device /mnt/snapshot

  1. then you'll be able to access the contents, old /usr should be under /mnt/snapshot/usr

  2. mount your /usr to a temporary location, for example /mnt/usr

  3. Copy the contents over (be careful with the trailing / of source) from snapshot to your current /usr

sudo rsync -axHAX --progress /mnt/snapshot/usr/ /mnt/usr

Reboot and it should be good.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .