Andrew Lutomirski
2011-Mar-29 20:09 UTC
How to remove a device on a RAID-1 before replacing it?
I have a disk with a SMART failure. It still works but I assume it''ll fail sooner or later. I want to remove it from my btrfs volume, replace it, and add the new one. But the obvious command doesn''t work: # btrfs device delete /dev/dm-5 /mnt/foo ERROR: error removing the device ''/dev/dm-5'' dmesg says: btrfs: unable to go below two devices on raid1 With mdadm, I would fail the device, remove it, run degraded until I get a new device, and hot-add that device. With btrfs, I''d like some confirmation from the fs that data is balanced appropriately so I won''t get data loss if I just yank the drive. And I don''t even know how to tell btrfs to release the drive so I can safely remove it. (Mounting with -o degraded doesn''t help. I could umount, remove the disk, then remount, but that feels like a hack.) This is 2.6.38.1 running Fedora 14''s version of btrfs-progs, but btrfs-progs-unstable git does the same thing, as does btrfs-vol -r. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Mar 29, 2011 at 2:09 PM, Andrew Lutomirski <luto@mit.edu> wrote:> I have a disk with a SMART failure. It still works but I assume it''ll > fail sooner or later. > > I want to remove it from my btrfs volume, replace it, and add the new > one. But the obvious command doesn''t work: > > # btrfs device delete /dev/dm-5 /mnt/foo > ERROR: error removing the device ''/dev/dm-5'' > > dmesg says: > btrfs: unable to go below two devices on raid1 > > With mdadm, I would fail the device, remove it, run degraded until I > get a new device, and hot-add that device. > > With btrfs, I''d like some confirmation from the fs that data is > balanced appropriately so I won''t get data loss if I just yank the > drive. And I don''t even know how to tell btrfs to release the drive > so I can safely remove it. > > (Mounting with -o degraded doesn''t help. I could umount, remove the > disk, then remount, but that feels like a hack.)There''s no "nice" way to remove a failing disk in btrfs right now ("btrfs dev delete" is more of a online management thing to politely remove a perfectly functional disk you''d like to use for something else.) As I understand things, the only way to do it right now is the umount, remove disk, remount w/ degraded, and then btrfs add the new device. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Helmut Hullen
2011-Mar-29 20:45 UTC
Re: How to remove a device on a RAID-1 before replacing it?
Hallo, cwillu, Du meintest am 29.03.11:>> I have a disk with a SMART failure. It still works but I assume >> it''ll fail sooner or later. >> >> I want to remove it from my btrfs volume, replace it, and add the >> new one. But the obvious command doesn''t work:[...]> There''s no "nice" way to remove a failing disk in btrfs right now > ("btrfs dev delete" is more of a online management thing to politely > remove a perfectly functional disk you''d like to use for something > else.)Nice hope, but even "btrfs device delete /dev/sdxn /mnt/btr" doesn''t work well. I''ve tried it, with kernel 2.6.38.1 ... # mkfs.btrfs -L SCSI -m raid0 /dev/sda1 # mount LABEL=SCSI /mnt/btr # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 1 FS bytes used 28.00KB devid 1 size 4.04GB used 20.00MB path /dev/sda1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data: total=8.00MB, used=0.00 System: total=4.00MB, used=8.00KB Metadata: total=8.00MB, used=20.00KB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 4232556 28 4220224 1% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data #------------------------------------------------------------ # btrfs device add /dev/sdc1 /mnt/btr # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 2 FS bytes used 28.00KB devid 1 size 4.04GB used 433.31MB path /dev/sda1 devid 2 size 8.54GB used 0.00 path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data: total=421.31MB, used=0.00 System: total=4.00MB, used=4.00KB Metadata: total=8.00MB, used=24.00KB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 13189632 28 13176256 1% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data #------------------------------------------------------------ # 2 GByte kopiert # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 2 FS bytes used 2.10GB devid 1 size 4.04GB used 433.31MB path /dev/sda1 devid 2 size 8.54GB used 2.25GB path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data: total=2.41GB, used=2.10GB System: total=4.00MB, used=4.00KB Metadata: total=264.00MB, used=2.79MB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 13189632 2202740 10714232 18% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data #------------------------------------------------------------ # 7 GByte kopiert # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 2 FS bytes used 9.03GB devid 1 size 4.04GB used 1.42GB path /dev/sda1 devid 2 size 8.54GB used 8.25GB path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data: total=9.41GB, used=9.02GB System: total=4.00MB, used=4.00KB Metadata: total=264.00MB, used=11.80MB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 13189632 9467164 3459032 74% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data #------------------------------------------------------------ # btrfs device add /dev/sdb1 /mnt/btr # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 3 FS bytes used 9.12GB devid 3 size 136.73GB used 0.00 path /dev/sdb1 devid 1 size 4.04GB used 1.42GB path /dev/sda1 devid 2 size 8.54GB used 8.25GB path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data: total=9.41GB, used=9.10GB System: total=4.00MB, used=4.00KB Metadata: total=264.00MB, used=11.91MB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 156562592 9559000 146739216 7% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data /dev/sdb 1 2048 286747966 136.7 GiB 0700 Linux/Windows data #------------------------------------------------------------ # btrfs filesystem balance /mnt/btr # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 3 FS bytes used 9.11GB devid 3 size 136.73GB used 10.61GB path /dev/sdb1 devid 1 size 4.04GB used 3.70GB path /dev/sda1 devid 2 size 8.54GB used 8.08GB path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data, RAID0: total=21.89GB, used=9.10GB System: total=4.00MB, used=4.00KB Metadata, RAID0: total=511.88MB, used=10.15MB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 156562592 9557196 14370128 40% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data /dev/sdb 1 2048 286747966 136.7 GiB 0700 Linux/Windows data #------------------------------------------------------------ # 8 GByte kopiert # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 3 FS bytes used 17.02GB devid 3 size 136.73GB used 10.61GB path /dev/sdb1 devid 1 size 4.04GB used 3.70GB path /dev/sda1 devid 2 size 8.54GB used 8.08GB path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data, RAID0: total=21.89GB, used=17.00GB System: total=4.00MB, used=4.00KB Metadata, RAID0: total=511.88MB, used=18.66MB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 156562592 17850436 6085608 75% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data /dev/sdb 1 2048 286747966 136.7 GiB 0700 Linux/Windows data #------------------------------------------------------------ # btrfs filesystem balance /mnt/btr # btrfs filesystem show Label: ''SCSI'' uuid: 4d834705-5a65-4d1f-a8a0-a5ea9348db50 Total devices 3 FS bytes used 17.08GB devid 3 size 136.73GB used 9.08GB path /dev/sdb1 devid 1 size 4.04GB used 2.09GB path /dev/sda1 devid 2 size 8.54GB used 8.08GB path /dev/sdc1 Btrfs Btrfs v0.19 # btrfs filesystem df /mnt/btr Data, RAID0: total=19.00GB, used=17.06GB System: total=4.00MB, used=4.00KB Metadata, RAID0: total=255.94MB, used=18.51MB # df -t btrfs Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 btrfs 156562592 17911352 6118356 75% /mnt/btr # gdisk -l /dev/sda 1 2048 8467166 4.0 GiB 0700 Linux/Windows data /dev/sdc 1 2048 17916206 8.5 GiB 0700 Linux/Windows data /dev/sdb 1 2048 286747966 136.7 GiB 0700 Linux/Windows data #------------------------------------------------------------ and then follows the problem I''ve told last year: "no space left on device ...". In this special case: even not enough place for deleting one partition. Trying "btrfs device delete ..." without previous "balance" leads to # btrfs device delete /dev/sdc1 /mnt/btr # endet mit "error removing the device ''/dev/sdc1''" Viele Gruesse! Helmut -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Andrew Lutomirski
2011-Mar-29 21:01 UTC
Re: How to remove a device on a RAID-1 before replacing it?
On Tue, Mar 29, 2011 at 4:21 PM, cwillu <cwillu@cwillu.com> wrote:> On Tue, Mar 29, 2011 at 2:09 PM, Andrew Lutomirski <luto@mit.edu> wrote: >> I have a disk with a SMART failure. It still works but I assume it''ll >> fail sooner or later. >> >> I want to remove it from my btrfs volume, replace it, and add the new >> one. But the obvious command doesn''t work: >> >> # btrfs device delete /dev/dm-5 /mnt/foo >> ERROR: error removing the device ''/dev/dm-5'' >> >> dmesg says: >> btrfs: unable to go below two devices on raid1 >> >> With mdadm, I would fail the device, remove it, run degraded until I >> get a new device, and hot-add that device. >> >> With btrfs, I''d like some confirmation from the fs that data is >> balanced appropriately so I won''t get data loss if I just yank the >> drive. And I don''t even know how to tell btrfs to release the drive >> so I can safely remove it. >> >> (Mounting with -o degraded doesn''t help. I could umount, remove the >> disk, then remount, but that feels like a hack.) > > There''s no "nice" way to remove a failing disk in btrfs right now > ("btrfs dev delete" is more of a online management thing to politely > remove a perfectly functional disk you''d like to use for something > else.) As I understand things, the only way to do it right now is the > umount, remove disk, remount w/ degraded, and then btrfs add the new > device. >Well, the disk *is* perfectly functional. It just won''t be for long. I guess what I''m saying is that either btrfs dev delete isn''t really working -- I want to be able to convert to non-RAID and back or degraged and back or something else equivalent. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hugo Mills
2011-Mar-29 21:15 UTC
Re: How to remove a device on a RAID-1 before replacing it?
On Tue, Mar 29, 2011 at 05:01:39PM -0400, Andrew Lutomirski wrote:> On Tue, Mar 29, 2011 at 4:21 PM, cwillu <cwillu@cwillu.com> wrote: > > On Tue, Mar 29, 2011 at 2:09 PM, Andrew Lutomirski <luto@mit.edu> wrote: > >> I have a disk with a SMART failure. It still works but I assume it''ll > >> fail sooner or later. > >> > >> I want to remove it from my btrfs volume, replace it, and add the new > >> one. But the obvious command doesn''t work: > >> > >> # btrfs device delete /dev/dm-5 /mnt/foo > >> ERROR: error removing the device ''/dev/dm-5'' > >> > >> dmesg says: > >> btrfs: unable to go below two devices on raid1 > >> > >> With mdadm, I would fail the device, remove it, run degraded until I > >> get a new device, and hot-add that device. > >> > >> With btrfs, I''d like some confirmation from the fs that data is > >> balanced appropriately so I won''t get data loss if I just yank the > >> drive. And I don''t even know how to tell btrfs to release the drive > >> so I can safely remove it. > >> > >> (Mounting with -o degraded doesn''t help. I could umount, remove the > >> disk, then remount, but that feels like a hack.) > > > > There''s no "nice" way to remove a failing disk in btrfs right now > > ("btrfs dev delete" is more of a online management thing to politely > > remove a perfectly functional disk you''d like to use for something > > else.) As I understand things, the only way to do it right now is the > > umount, remove disk, remount w/ degraded, and then btrfs add the new > > device. > > > > Well, the disk *is* perfectly functional. It just won''t be for long. > > I guess what I''m saying is that either btrfs dev delete isn''t really > working -- I want to be able to convert to non-RAID and back or > degraged and back or something else equivalent.RAID conversion isn''t quite ready yet, sadly. As I understand it, you''ve got two options: - Yoink the drive (thus making the fs run in degraded mode), add the new one, and balance to spread the duplicate data onto the new volume. - Add the new drive to the FS first, then use btrfs dev del to remove the original device. This should end up writing all the replicated data to the new drive as it "removes" the data from the old one. Of the two options, the latter is (for me) the favourite, as you don''t end up with a filesystem that''s running on just a single copy of the data. Hugo. -- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk == PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- Prof Brain had been in search of The Truth for 25 years, with --- the intention of putting it under house arrest.