On 10/08/2018 11:21 PM, Hugo Mills wrote:
On Mon, Oct 08, 2018 at 11:01:35PM +0200, Pierre Couderc wrote:
On 10/08/2018 06:14 PM, Hugo Mills wrote:
On Mon, Oct 08, 2018 at 04:10:55PM +0000, Hugo Mills wrote:
On Mon, Oct 08, 2018 at 03:49:53PM +0200, Pierre Couderc wrote:
I ma trying to make a "RAID1" with /dev/sda2 ans /dev/sdb (or similar).
But I have stranges status or errors about "missing devices" and I
do not understand the current situation :
root@server:~# btrfs fi show
Label: none uuid: 28c2b7ab-631c-40a3-bab7-00dac5dd20eb
Total devices 1 FS bytes used 190.91GiB
devid 1 size 1.82TiB used 196.02GiB path /dev/sda2
warning, device 1 is missing
Label: none uuid: 2d45149a-fb97-4c2a-bae2-4cfe4e01a8aa
Total devices 2 FS bytes used 116.18GiB
devid 2 size 1.82TiB used 118.03GiB path /dev/sdb
*** Some devices missing
This looks like you've created a RAID-1 array with /dev/sda2 and
/dev/sdb, and then run mkfs.btrfs again on /dev/sda2, overwriting the
original [part of a] filesystem on /dev/sda2, and replacing it with a
wholly different filesystem. Since the new FS on /dev/sda2 (UUID
28c2...) doesn't have the same UUID as the original FS (UUID 2d45...),
and the original FS was made of two devices, btrfs fi show is telling
you that there's some devices missing -- /dev/sda2 is no longer part
of that FS, and is therefore a missing device.
I note that you've got data on both filesystems, so they must both
have been mounted somewhere and had stuff put on them.
I recommend doing something like this:
# mkfs /media/btrfs/myraid1 /media/btrfs/tmp
# mount /dev/sdb /media/btrfs/myraid1/
# mount /dev/sda2 /media/btrfs/tmp/ # mount both filesystems
# cp /media/btrfs/tmp/* /media/btrfs/myraid1 # put it where you want it
# umount /media/btrfs/tmp/
# wipefs /dev/sda2 # destroy the FS on sda2
# btrfs replace start 1 /dev/sda2 /media/btrfs/myraid1/
This will copy all the data from the filesystem on /dev/sda2 into
the filesystem on /dev/sdb, destroy the FS on sda2, and then use sda2
as the second device for the main FS.
*WARNING!*
Note that, since the main FS is missing a device, it will probably
need to be mounted in degraded mode (-o degraded), and that on kernels
earlier than (IIRC) 4.14, this can only be done *once* without the FS
becoming more or less permanently read-only. On recent kernels, it
_should_ be OK.
*WARNING ENDS*
Oh, and for the record, to make a RAID-1 filesystem from scratch,
you simply need this:
# mkfs.btrfs -m raid1 -d raid1 /dev/sda2 /dev/sdb
You do not need to run mkfs.btrfs on each device separately.
Hugo.
Thnk you very much. I understand a bit better. I think that I have
nothing of interest on /dev/sdb and that its contents is the result
of previous trials.
And that my system is on /dev/dsda2 as :
root@server:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 787M 8.8M 778M 2% /run
/dev/sda2 1.9T 193G 1.7T 11% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 511M 5.7M 506M 2% /boot/efi
tmpfs 100K 0 100K 0% /var/lib/lxd/shmounts
tmpfs 100K 0 100K 0% /var/lib/lxd/devlxd
root@server:~#
Is it exact ?
Yes, it looks like you're running / from the FS on /dev/sda2.
If yes, I suppose I should wipe data on /dev/sdb, then build the
RAID by expanding /dev/sda2.
Correct.
I would recommend putting a partition table on /dev/sdb, because it
doesn't take up much space, and it's always easier to have one already
there when you need it (and there's a few things that can get confused
if there isn't a partition table).
So I should :
wipefs /dev/sdb
btrfs device add /dev/sdb /
btrfs balance start -v -mconvert=raid1 -dconvert=raid1 /
Does it sound correct ? (my kernel is boot/vmlinuz-4.18.0-1-amd64)
Yes, exactly.
Hugo.
Thnk you very very much.
I do it now, as you with a partition table on /dev/sdb !