[TriLUG] How to migrate LVM to LVM on Raid-1
Rick DeNatale
rick.denatale at gmail.com
Thu Feb 16 16:23:45 EST 2006
On 2/16/06, Brian McCullough <bdmc at bdmcc-us.com> wrote:
>
> Rick,
>
> You're laughing. Having a completely unused disk available makes the
> job _so_ much easier.
....
Okay, let me see if I understand by working through that article I
referenced before:
http://www.debian-administration.org/articles/238
I obviously still have a few blanks to fill in. Any help is appreciated.
I'm starting with these partitions on /dev/sda
$ sudo sfdisk -l /dev/sda
Disk /dev/sda: 1106 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes,
counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 30 31- 248976 83 Linux
/dev/sda2 31 1105 1075 8634937+ 5 Extended
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
/dev/sda5 31+ 1105 1075- 8634906 8e Linux LVM
I'm going to copy /dev/sda1 (the boot partition) to /dev/sdb1 and
make /dev/sda5 part of a raid1 md array with /dev/sdb5.
1. I need to change the partition type of /dev/sda5 from 8e to fd
"Linux raid auto" I can't seem to figure out how to do this with
sfdisk, so I guess I'll do that interactively with fdisk.
2. Now Partition /dev/sdb like /dev/sda
$sfdisk -d /dev/sda | sfdisk /dev/sdb
3. Now create the raid array
$mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb5
We're now going to duplicate the LVM setup which is
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name Ubuntu
PV Size 8.23 GB / not usable 0
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 2108
Free PE 0
Allocated PE 2108
PV UUID v0S4TQ-YGh6-h1I9-nlq2-r53b-Eh04-ESjBTI
$ sudo vgdisplay
--- Volume group ---
VG Name Ubuntu
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 8.23 GB
PE Size 4.00 MB
Total PE 2108
Alloc PE / Size 2108 / 8.23 GB
Free PE / Size 0 / 0
VG UUID h4Xd2k-wH06-KjGJ-tKRo-oWp4-uk1T-q8pOMg
$ sudo lvdisplay
--- Logical volume ---
LV Name /dev/Ubuntu/root
VG Name Ubuntu
LV UUID iP9OI1-Qkw4-kbla-fwmg-ipnP-g80A-VAFxQD
LV Write Access read/write
LV Status available
# open 1
LV Size 7.86 GB
Current LE 2013
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0
--- Logical volume ---
LV Name /dev/Ubuntu/swap_1
VG Name Ubuntu
LV UUID nudA40-pnMa-pjWv-0Flr-bIPM-dmcb-Q7KwXp
LV Write Access read/write
LV Status available
# open 1
LV Size 380.00 MB
Current LE 95
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:1
4. Now create a PV on the raid array
$pvcreate /dev/md0
QUESTION: Do I need to worry about the uuid of this PV vis a vis
the existing PV on /dev/sda5?
5. Now create a VG
$vgcreate Ubuntu /dev/md0
QUESTIONS: Same question about uuid, plus is it a problem having
two VGs with the same name on different devices? Note that the
original PV, VG, and LVs are still in use.
6 Create the LVs
$lvcreate -l 2013 Ubuntu -n root
$lvcreate -l 95 Ubuntu -n swap_1
QUESTIONS: Are there any other parameters I need here? are the
short names root and swap_1 ok or do I need e.g. /dev/Ubuntu/root?
7. Format the LVs
$mkfs.ext3 /dev/Ubuntu/root
$mkswap /dev/Ubuntu/swap_1
8. Mount the new root LV
$sudo mkdir /mnt/root
$sudo mount /dev/Ubuntu/root /mnt/root
QUESTION: Is it correct that this is the first point I need to
mount anything?
9. Copy the root partition
$cp -dpRx / /mnt/root
It doesn't seem to make sense to copy the swap partitition
10. Mount the boot partition and copy it.
$sudo mkfs.ext3 /dev/sdb1
$sudo mkdir /mnt/boot
$sudo mount /dev/sdb1 /mnt/boot
$sudo cp -ax /boot /mnt/boot
11. Edit /mnt/root/etc/fstab to use the md device.
/dev/sdb1 /boot ext3 defaults 0 2
HERE'S A PLACE WHERE I'M STUMPED.
Here are the lines in the current /etc/fstab for mounting / and swap
/dev/mapper/Ubuntu-root / ext3
defaults,errors=remount-ro 0 1
/dev/mapper/Ubuntu-swap_1 none swap sw 0 0
What if any changes do I need to make here? Is there some LVM
config to substitute?
11. Edit /mnt/boot/grub/menu.lst????
STUMPED AGAIN. Here's an example of a kernel line from my /boot/grub/menu.lst
kernel /vmlinuz-2.6.12-10-686-smp
root=/dev/mapper/Ubuntu-root ro quiet splash
DO I REALLY NEED TO CHANGE ANYTHING HERE??? If so how does it
interact with ubuntu/debians automagic updates to this file on new
kernel package installs?
12. Install grub on the new drive so we can still boot
$sudo grub-install /dev/sdb
grub
grub: device (hd0) /dev/sdb
grub: root (hd0,0)
grub: setup (hd0)
grub: quit
QUESTION: The debian-admin article had this as grub-install
/dev/sda but this surely must be a typo since grub is already
installed on /dev/sda YES?
13. For the triskadecaphobic, there is no step 13 <G>
14. Copy the new /etc/fstab and grub configuration to the old drive
$sudo cp -p /mnt/root/etc/fstab /etc
$sudo cp -p /mnt/boot/grub/menu.1st /boot/grub
15. Cross fingers and reboot
QUESTION: How do I know it worked. The debian-admin says to
use df and see that / is mounted on /dev/md0, but I think that it's
still going to show it mounted on /dev/mapper/Ubuntu-root
16. Now add /dev/sda5 to the raid
$sudo mdadm --add /dev/md0 /dev/sda5
17. Wait until the md finishes syncing the drives
$watch cat /proc/mdstat
It's done when this shows a status of [UU] for /dev/md0
--
Rick DeNatale
Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
More information about the TriLUG
mailing list