Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

Through Xbuntu 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

2

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.