vendredi 20 novembre 2020

Re-create BTRFS lost filesystem

fdisk /dev/sdc, removed /dev/sdc1 partition so I can start over on the bare device. sdc is the Western Digital 2TB disk:
luc@kid2:~$ sudo fdisk -l /dev/sdc
Disk /dev/sdc: 1,84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WDC WD20EARX-00P
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Creating the first device on new BTRFS :
luc@kid2:~$ sudo mkfs.btrfs -f /dev/sdc
btrfs-progs v5.4.1 
See http://btrfs.wiki.kernel.org for more information.

Label:              (null)
UUID:               b12623df-e351-4d48-856b-867e38361682
Node size:          16384
Sector size:        4096
Filesystem size:    1.82TiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP               1.00GiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Checksum:           crc32c
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1     1.82TiB  /dev/sdc
So we have an unmounted btrfs filesystem, let's take note of the UUID and update fstab:
luc@kid2:~$ sudo btrfs fi show /dev/sdc
Label: none  uuid: b12623df-e351-4d48-856b-867e38361682
	Total devices 1 FS bytes used 128.00KiB
	devid    1 size 1.82TiB used 2.02GiB path /dev/sdc
luc@kid2:~$ sudo vi /etc/fstab     
luc@kid2:~$ sudo tail /etc/fstab 
UUID=2a51d4ad-e97f-4d6c-bde4-a44ebd1ff267 /home           ext4    defaults        0       2
# swap was on /dev/sdb3 during installation
UUID=5690db75-3d2a-4171-a789-b5179a501942 none            swap    sw              0       0
/dev/fd0        /media/floppy0  noauto    rw,user,noauto,exec,utf8 0       0

# urbackup data
UUID=b12623df-e351-4d48-856b-867e38361682 /var/backups/urbackup	btrfs defaults 0 3
#UUID=4881245e-bed5-4526-b9ff-3b5ba39b283d /var/backups/urbackup	btrfs defaults 0 3

luc@kid2:~$ sudo mount /var/backups/urbackup/
luc@kid2:~$ 
No error message. However the mount didn't happen. Apparently the system still "remembers" of a zombie BTRFS partition that used to be mounted there, from /dev/sdd. I could mount the new one (/dev/sdc) manually on another mount point (/mnt) but not on /var/backups/urbackup where I need it.

I ended up using fdisk to wipe out the BTRFS label (?) on /dev/sdd by creating then removing /dev/sdd1. After that I rebooted and the system happily mounted /dev/sdc thanks to my previous update in /etc/fstab. However there was another slight problem with permissions, the mount is only accessible by root after this point. It still needed some chown/chmod commands:

luc@kid2:/var/backups/urbackup$ sudo -u urbackup ls
luc@kid2:/var/backups/urbackup$ sudo -u urbackup touch a
touch: cannot touch 'a': Permission denied
luc@kid2:/var/backups/urbackup$ sudo chown root:urbackup .
luc@kid2:/var/backups/urbackup$ cd ..
luc@kid2:/var/backups$ sudo chmod g+w urbackup/
The Urbackup server immediately started backing up two clients. Unfortunately on one of them the external USB drive wasn't mounted so that failed. I restarted afterwards, and asked for a full backup. But that failed soon enough also, this time the new BTRFS file system had been remounted ro (readonly). Clearly something really wrong is going on with that disk drive (/dev/sdc):
luc@kid2:/var/log$ sudo fdisk /dev/sdc

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

fdisk: cannot open /dev/sdc: Input/output error
So I started back doing the same BTRFS re-creation on /dev/sdd this time. That worked fine but of course I now have only half the capacity to take backups. It should be just enough though for the moment, the server displays statistics going up to 1701GB at the moment.

Aucun commentaire: