- Shutdown your system.
- Boot from a USB-stick (or any other live medium) with a Linux distro
- After booting install tools for messing around with btrfs. (I am assuming your usb-stick is also a ubuntu):
sudo apt install btrfs-progson Ubuntu 20 orsudo apt install btrfs-toolson older systems. (It will be installed in memory) - Install tools to mess around with the disk at hardware level:
sudo apt install smartmontools - Mount your disk read-only:
mkdir /mnt/baddisk && mount -o ro /dev/sdb1 /mnt/baddisk(sdb1will probably be different in your case) - Backup your data:
rsync -Havz /mnt/baddisk someothersystem:/dataofbuggydisk/
Only now you can play around.
- Use
smartctl -a /dev/sdbto see if reallocation is actually still a option. Reallocation will be handled low level by your disk itself, not by btrfs.
If the disk can't do this you will certainly not be able to do this. - You can play around with
btrfs rescueandbtrfs checkif needed. But if you only have a couple of bad sectors this will probably not be needed. A regular Ubuntu config makes sure that the filesystem is always in the best condition possible.
Normally the only thing you should worry about is what SMART tells you about this disk. Usesmartctlto check it from to time. (It could be that nowadays Ubuntu also does this for you and warns you when necessary but I'm not sure about this, also do it manually just to be safe.)
Edit: I just noticed that you mentioned that Ubuntu placed your disk in read-only mode. When it decides to do this you have real problems. This can usually only happen when:
- The system was shutdown uncleanly, but you don't mention it so it's probably not the case
- You have low-level (disk, not filesystem) problems.
I would strongly advice not to use this disk again. In theory it's certainly possible to recover the filesystem and continue using this disk for a while, but you will end up with large problems sooner or later...