2

I have a Ubuntu 19-04 LVM installation I am wanting to convert to RAID 1 using this tutorial here:

https://www.prado.lt/how-to-set-up-software-raid1-on-a-running-lvm-system-incl-grub2-configuration-ubuntu-18-04

Before I try this on my real system I want to see it working on a virtual machine. So I have created a Ubuntu 19-04 LVM virtual machine with a 250GB virtual disk on VirtualBox. I then created a second 250GB virtual disk.

After running:

sfdisk -d /dev/sda | sfdisk --force /dev/sdb

This is the output of fdisk -l:

Disk /dev/sda: 250 GiB, 268435456000 bytes, 524288000 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3f9af72a

Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1  *     2048 524285951 524283904  250G 8e Linux LVM


Disk /dev/sdb: 250 GiB, 268435456000 bytes, 524288000 sectors
Disk model: VBOX HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3f9af72a

Both drives have exactly the same number of bytes and sectors.

When I got to this bit:

mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1

Terminal output was:

mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device.  If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? 

I note this was not mentioned in the tutorial. Can anyone explain to me why I have got this message and what it means?

[Edit: According this this post this is nothing to worry about: https://www.howtoforge.com/how-to-set-up-software-raid1-on-a-running-lvm-system-incl-grub2-configuration-debian-squeeze-p2]

Anyway I said yes and carried on.

When I got to this bit:

pvmove -i 2 /dev/sda1 /dev/md0

Terminal output was:

root@Ubuntu19:/home/mike# pvmove -i 2 /dev/sda1 /dev/md0
Insufficient free space: 63991 extents needed, but only 63967 available
Unable to allocate mirror extents for ubuntu-vg/pvmove0.
Failed to convert pvmove LV to mirrored.

Both of these drives are exactly the same size so I do not understand why there would not be enough space.

What is the solution to this? Should I reduce the size of my logical volume? Reduce the size of the physical volume? Or something else?

Edit:

I thought I would try and reduce the size of the LVM so I booted in to a live CD. The output of:

root@ubuntu:/home/ubuntu# lvdisplay
WARNING: Device for PV FvC0uz-efgT-zqqB-NK3f-2yTZ-QWlO-vXuneh not found 
rejected by a filter.
--- Logical volume ---
LV Path                /dev/ubuntu-vg/root
LV Name                root
VG Name                ubuntu-vg
LV UUID                RJi0Hn-fuk3-kEEe-xVeG-FqeJ-OUXR-iTpW8Y
LV Write Access        read/write
LV Creation host, time ubuntu, 2019-04-15 08:25:48 +0000
LV Status              NOT available
LV Size                249.01 GiB
Current LE             63747
Segments               1
Allocation             inherit
Read ahead sectors     auto

--- Logical volume ---
LV Path                /dev/ubuntu-vg/swap_1
LV Name                swap_1
VG Name                ubuntu-vg
LV UUID                JX3Scc-fGIM-e8Z1-zwY3-1ACM-U70M-m8OshG
LV Write Access        read/write
LV Creation host, time ubuntu, 2019-04-15 08:25:48 +0000
LV Status              NOT available
LV Size                976.00 MiB
Current LE             244
Segments               1
Allocation             inherit
Read ahead sectors     auto

When I tried

root@ubuntu:/home/ubuntu# resize2fs /dev/ubuntu-vg/root 248GB

I got:

resize2fs 1.44.6 (5-Mar-2019)
open: No such file or directory while opening /dev/ubuntu-vg/root
Jedi
  • 491

1 Answers1

1

Ok I figured it out.

After I ran:

sfdisk -d /dev/sda | sfdisk --force /dev/sdb  

and before changing the partition type with fdisk I booted into a live CD and did:

ubuntu@ubuntu:~$ sudo su
root@ubuntu:/home/ubuntu# lvdisplay
--- Logical volume ---
LV Path                /dev/ubuntu-vg/root
LV Name                root
VG Name                ubuntu-vg
LV UUID                RJi0Hn-fuk3-kEEe-xVeG-FqeJ-OUXR-iTpW8Y
LV Write Access        read/write
LV Creation host, time ubuntu, 2019-04-15 08:25:48 +0000
LV Status              available
# open                 0
LV Size                249.01 GiB
Current LE             63747
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:0

--- Logical volume ---
LV Path                /dev/ubuntu-vg/swap_1
LV Name                swap_1
VG Name                ubuntu-vg
LV UUID                JX3Scc-fGIM-e8Z1-zwY3-1ACM-U70M-m8OshG
LV Write Access        read/write
LV Creation host, time ubuntu, 2019-04-15 08:25:48 +0000
LV Status              available
# open                 0
LV Size                976.00 MiB
Current LE             244
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:1

root@ubuntu:/home/ubuntu# e2fsck -f /dev/ubuntu-vg/root
e2fsck 1.44.6 (5-Mar-2019)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/ubuntu-vg/root: 201304/16326656 files (0.1% non-contiguous), 
2764077/65276928 blocks

root@ubuntu:/home/ubuntu# resize2fs /dev/ubuntu-vg/root 247G
resize2fs 1.44.6 (5-Mar-2019)
Resizing the filesystem on /dev/ubuntu-vg/root to 65011712 (4k) 
blocks.
The filesystem on /dev/ubuntu-vg/root is now 65011712 (4k) blocks 
long.

root@ubuntu:/home/ubuntu# lvreduce -L 248G /dev/ubuntu-vg/root
WARNING: Reducing active logical volume to <248.82 GiB.
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce ubuntu-vg/root? [y/n]: y
Size of logical volume ubuntu-vg/root changed from 249.01 GiB (63747
extents) to <248.82 GiB (63697 extents).
Logical volume ubuntu-vg/root successfully resized.
root@ubuntu:/home/ubuntu# 

Booted back into my virtual machine and after that it was plain sailing.

Jedi
  • 491