LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   RAID1, mdadm, and slightly mismatched PV sizes (Ubuntu) (https://www.linuxquestions.org/questions/linux-software-2/raid1-mdadm-and-slightly-mismatched-pv-sizes-ubuntu-4175447788/)

jollypirate 01-29-2013 11:25 PM

RAID1, mdadm, and slightly mismatched PV sizes (Ubuntu)
 
I'm a newbie to the world of setting up software RAID with mdadm and am confused about why one of my PVs is ending up smaller than I expect it to.

Trying to follow this very clear FAQ http://www.howtoforge.com/how-to-set...n-ubuntu-10.04 to set up RAID1 on my box.

My system setup is:
  • Ubuntu
  • 2x 2TB drives
  • Default Ubuntu partitions on drive 1 (/dev/sda), empty drive 2 (/dev/sdb)

All is well until I use mdadm to create the two RAID volumes md0 and md1 and then do a pvcreate on md1.

Quote:

captain@risa:~$ sudo mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
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? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
captain@risa:~$ sudo mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb5
mdadm: /dev/sdb5 appears to contain an ext2fs file system
size=976510976K mtime=Wed Dec 31 19:00:00 1969
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? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
captain@risa:~$ sudo cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdb5[1]
976379712 blocks super 1.2 [2/1] [_U]

md0 : active raid1 sdb1[1]
248640 blocks super 1.2 [2/1] [_U]

unused devices: <none>
captain@risa:~$ sudo lvdisplay
--- Logical volume ---
LV Name /dev/risa/root
VG Name risa
LV UUID pk44SY-IPxT-226g-aBK8-lnc3-k5YE-KIhyvj
LV Write Access read/write
LV Status available
# open 1
LV Size 923.33 GiB
Current LE 236373
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Name /dev/risa/swap_1
VG Name risa
LV UUID TnG5BB-LRuM-N8sx-BTvZ-q38E-IupP-lHevaD
LV Write Access read/write
LV Status available
# open 2
LV Size 7.89 GiB
Current LE 2021
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

captain@risa:~$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name risa
PV Size 931.27 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238405
Free PE 11
Allocated PE 238394
PV UUID OFPdJC-0p17-Rkeh-H1mZ-3FeL-mdKZ-vAkw5o

captain@risa:~$ sudo pvcreate /dev/md1
Physical volume "/dev/md1" successfully created
captain@risa:~$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name risa
PV Size 931.27 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238405
Free PE 11
Allocated PE 238394
PV UUID OFPdJC-0p17-Rkeh-H1mZ-3FeL-mdKZ-vAkw5o

"/dev/md1" is a new physical volume of "931.15 GiB"
--- NEW Physical volume ---
PV Name /dev/md1
VG Name
PV Size 931.15 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Q73v6U-pYT4-GfLJ-ua9L-Kaw0-lDGZ-VgkIXQ
You can see the PV size for /dev/md1 is *ever so slightly* smaller than the existing PV for /dev/sda5, which makes an attempted "pvmove -i 2 /dev/sda5 /dev/md1" very unhappy. If I do a straight pvcreate on /dev/sdb5 the resulting PV is the same size as /dev/sda5 (931.27 GiB, instead of 931.15).

So, er, into which arcane vortex is that tiny bit of extra space going? Is it as simple as that metadata the mdadm is complaining about during the RAID volume creation?

More importantly, is my best option to boot up from live media and shrink the filesystem and volume for /dev/sda5, or is there a less painful way to get my RAID working?

smallpond 01-30-2013 04:39 PM

Yes. Creating a RAID needs some overhead on disk in which to store metadata. Don't create a RAID without on-disk metadata unless you like taking notes and reassembling it by hand. Also make sure grub is installed in both mirrors holding /boot so either can boot after a disk failure.

I don't think I would try to do pvmove on my live system even if I did have enough space, so you're more intrepid than me.
Your idea of booting from live media sounds practical (assuming you have good backups).
You could do file-by-file copy using rsync. That would be a lot slower than block copy, tho.

Personally I've just reloaded the system rather than attempt to convert a non-RAID system to mirrored. Please post back and let us know how it worked out.


All times are GMT -5. The time now is 02:34 PM.