[SLUG] clone non-LVM system onto new LVM drive
Scenario: * Ubuntu presently installed *without* LVM. * New hard drive formatted with: /boot ext3 partition (empty so far) LVM group containing ext3 LV I want to copy the original root partition onto the new LV so that the new hard drive and LV is a bootable clone, and the old physical drive can be removed/saved. There are three objectives: Convert to LVM Keep the original as backup Upgrade the LVM version and be able to roll back if necessary. I'm assuming that I will have to boot into a live CD and dd the original root partition onto an LV. How do I persuade this to boot correctly? Do I copy the original /boot onto the new boot partition? Do I have to make changes to the boot directory? Changes to grub? Then what? (apart from any BIOS changes, which are fairly obvious). So far I haven't been able to find the right question to ask Google. Any help would be appreciated, of if anyone could point me at a howto that covers this scenario. thanks David. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
On Tuesday, June 14, 2011 10:00:02 AM slug-requ...@slug.org.au wrote: > Scenario: > > * Ubuntu presently installed without LVM. > * New hard drive formatted with: > /boot ext3 partition (empty so far) > LVM group containing ext3 LV > > I want to copy the original root partition onto the new LV so that the > new hard drive and LV is a bootable clone, and the old physical drive > can be removed/saved. > > There are three objectives: > Convert to LVM > Keep the original as backup > Upgrade the LVM version and be able to roll back if necessary. > > I'm assuming that I will have to boot into a live CD and dd the original > root partition onto an LV. How do I persuade this to boot correctly? Do > I copy the original /boot onto the new boot partition? Do I have to make > changes to the boot directory? Changes to grub? Then what? (apart from > any BIOS changes, which are fairly obvious). > > So far I haven't been able to find the right question to ask Google. Any > help would be appreciated, of if anyone could point me at a howto that > covers this scenario. David in general avoid dd. It mirrors what you have to what you want and probably they dont fit. If you are cloning disks then yes dd. (same hw, same format) I would: boot from a live cd mount (you may even have /media/oldroot) mount (likewise new-lvm-root) from old-root: find . |cpio -pdv newroot cpio does a good job of mirroring filesystems eg preserve links, sym links, wont choke if you have created a /dev/zero, all stuff like that handled nicely RF-insert-politically-correct-word-M :-) James -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
> "Jam" == Jam writes: Jam> On Tuesday, June 14, 2011 10:00:02 AM slug-requ...@slug.org.au Jam> wrote: >> Scenario: >> >> * Ubuntu presently installed without LVM. * New hard drive >> formatted with: /boot ext3 partition (empty so far) LVM group >> containing ext3 LV >> >> I want to copy the original root partition onto the new LV so that >> the new hard drive and LV is a bootable clone, and the old physical >> drive can be removed/saved. Jam> in general avoid dd. It mirrors what you have to what you want Jam> and probably they dont fit. If you are cloning disks then yes Jam> dd. (same hw, same format) Jam> I would: boot from a live cd mount (you may even have Jam> /media/oldroot) mount (likewise new-lvm-root) from old-root: find Jam> . |cpio -pdv newroot +1 on find, but the comand line should be find . -depth -print0 | cpio -pvmd0 newroot otherwise files with spaces in the name can get trashed, and the permissions on directories may end up wrong. Peter C -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
pe...@chubb.wattle.id.au wrote: "Jam" == Jam writes: Jam> On Tuesday, June 14, 2011 10:00:02 AM slug-requ...@slug.org.au Jam> wrote: Scenario: * Ubuntu presently installed without LVM. * New hard drive formatted with: /boot ext3 partition (empty so far) LVM group containing ext3 LV I want to copy the original root partition onto the new LV so that the new hard drive and LV is a bootable clone, and the old physical drive can be removed/saved. Jam> in general avoid dd. It mirrors what you have to what you want Jam> and probably they dont fit. If you are cloning disks then yes Jam> dd. (same hw, same format) Jam> I would: boot from a live cd mount (you may even have Jam> /media/oldroot) mount (likewise new-lvm-root) from old-root: find Jam> . |cpio -pdv newroot +1 on find, but the comand line should be find . -depth -print0 | cpio -pvmd0 newroot otherwise files with spaces in the name can get trashed, and the permissions on directories may end up wrong. Thanks for the cpio hint. Next, how do I persuade the new partition to boot? Do I have to do some magic with grub? If so, what? Do I cpio the old /boot onto the new, non-LVM boot partition? or can I use /boot within the new LV? Everything I read says to put /boot into a non-lvm partition. Does grub-install from a live CD give me the opportunity to spell out the right parameters? I don't want to simply experiment in case I do bad things. I have no experience with LVM until now. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
Thanks for the cpio hint. Next, how do I persuade the new partition to boot? Do I have to do some magic with grub? If so, what? Do I cpio the old /boot onto the new, non-LVM boot partition? or can I use /boot within the new LV? Everything I read says to put /boot into a non-lvm partition. Does grub-install from a live CD give me the opportunity to spell out the right parameters? I don't want to simply experiment in case I do bad things. I have no experience with LVM until now. you may well need to build a new initrd as well dunno for sure but there is magic involving chrooting into your new lvm instance and doing stuff. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
On Tue, Jun 14, 2011 at 02:15:18PM +1000, david wrote: > Next, how do I persuade the new partition to boot? Do I have to do some > magic with grub? If so, what? Do I cpio the old /boot onto the new, > non-LVM boot partition? or can I use /boot within the new LV? > > Everything I read says to put /boot into a non-lvm partition. Does > grub-install from a live CD give me the opportunity to spell out the > right parameters? I'm trying to so the same thing right now, and I've got *almost* everything working. Now when I try to boot from the new drive, I see some error messages flash by during boot (they're not logged to syslog and don't appear when I run dmesg) saying that it can't write to /lib/modules/`uname -r`/volatile because it's a read-only filesystem. This is happening because the tmpfs that's normally mounted there isn't being mounted, and I have no idea why. I don't know where this mount is supposed to be done and I'm not having any success finding anything useful via Google, and without knowing where it's done I have no idea how to fix it. Is there anyone out there who knows how to fix this, or who can give me a clue or two to help me figure it out? This is what I've done so far: I split the new drive (/dev/sdb) into three partitions and started a degraded RAID 1 array on each of them. I formatted the first with ext3 (for /boot) the second as swap, and the third is my LVM volume with separate partitions for /, /home, /tmp, /usr and /var. I mounted all of the new filesystems under /media/lvm and copied the files from the existing drives, then created a new initramfs and installed grub, like this: # these two files are used bu update-initramfs to build the # initrd cp /proc/cmdline /media/lvm/proc/ cp /proc/modules /media/lvm/proc/ # create an mdadm.conf on the new drive mdadm -E -s >> /media/lvm/etc/mdadm/mdadm.conf # chroot into the new drive chroot /media/lvm/ # change the root device in the copy of /proc/cmdline, mine # now contains "root=/dev/mapper/vg0-root ro" vi /proc/cmdline # update the mounts in the new fstab to use the new RAID/LVM # partitions vi /etc/fstab # edit the new grub memu so that the kernel's root device is # the new LVM root device (e.g. /dev/mapper/vg0-root), the # grub root device is the new /boot partition or RAID array, # and the kernel and initrd pathnames are relative to /boot vi /boot/grub/menu.lst # create a new initrd that includes LVM and RAID support # do this once for each kernel version you want to be able # to boot (replace "`uname -r`" with the kernel version) update-initramfs -c -k `uname -r` # install grub on the new drive grub-install /dev/sdb Any suggestions on how to fix my mount problem are welcome. Thanks, John -- I don't know what Connect[.com.au] were thinking when they put sprinklers in their data centre. I wonder what they'd do if you asked for a quote for enough rack space to hold 3 servers, a router, a switch and an umbrella? -- Richard Archer -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
On Thu, Jun 30, 2011 at 02:30:41PM +1000, John Clarke wrote: > I'm trying to so the same thing right now, and I've got *almost* > everything working. Now when I try to boot from the new drive, I see > some error messages flash by during boot (they're not logged to syslog > and don't appear when I run dmesg) saying that it can't write to > /lib/modules/`uname -r`/volatile because it's a read-only filesystem. > > This is happening because the tmpfs that's normally mounted there isn't > being mounted, and I have no idea why. I don't know where this mount is > supposed to be done and I'm not having any success finding anything > useful via Google, and without knowing where it's done I have no idea > how to fix it. I've found it. It's mounted by /sbin/lrm-manager (called from /etc/rcS.d/S07linux-restricted-modules-common), but only if /lib/modules/`uname -r`/volatile/.mounted doesn't exist. The file does exist because I copied it from the running system. I did look through this script earlier but missed it. I can't do any more testing tonight though, so it'll have to wait until the morning. John -- This is yet another mission for ed. Its simplicity and elegance is well suited to the needs of the novice, and when he's ready for vi he will see it as a feature-rich upgrade. -- Patrick R. Wade -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] clone non-LVM system onto new LVM drive
On Thu, Jun 30, 2011 at 02:30:41PM +1000, John Clarke wrote: > On Tue, Jun 14, 2011 at 02:15:18PM +1000, david wrote: > > > Next, how do I persuade the new partition to boot? Do I have to do some > > magic with grub? If so, what? Do I cpio the old /boot onto the new, > > non-LVM boot partition? or can I use /boot within the new LV? > > > > Everything I read says to put /boot into a non-lvm partition. Does > > grub-install from a live CD give me the opportunity to spell out the > > right parameters? > > I'm trying to so the same thing right now, and I've got *almost* > everything working. Well it's now up and running with LVM and RAID1. I've posted a complete guide to converting a non-LVM system to LVM + RAID1 here: http://kirriwa.net/john/doc/lvm+raid1.html This includes everything you need to do to get GRUB to boot too :-) I hope it's useful to someone, somewhere. John -- "Knuth is right: computer programming is not a science, but an art. System administration is an art too, and a black one at that." -- Adam J. Thornton -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html