Is this even possible?

Ok, here is the current situation: My machine has two identical 500Gb drives, and two identical 1Tb drives. When I first set it up, with just the 500Gb drives, I was using a version of Linux that wouldn’t boot from mirrored lvm partitions, so I set it up

  • /dev/sda1 2Gb /boot
  • /dev/sdb1 2Gb /
  • /dev/sda2 2Gb swap
  • /dev/sdb2 2Gb swap
  • /dev/sda3 and /dev/sdb3 – turned to a mirror, /dev/md0 and then created a
    pv and a vg.

That was working fine for a number of years, and then I added the two 1Tb drives, which I created as a mirror /dev/md1 and added it to the vg.

At this time, I have more more than 500Gb free space in the vg, so I definitely could pvmove and vgreduce and get rid of that. I’d also like to somehow fix it so that / and /boot and swap are on lv and just boot from the two 1Tb drives. The reason I’d like to do that is that

  • a) It’s been bugging me for years that I’m still using physical partitions
    for / and /boot, so I can’t resize them and
  • b) I have two 2Tb disks sitting on my desk that I’d like to add, and I
    don’t think I have enough SATA ports for 6 disks and
  • c) these two 500Gb drives are ancient – they just hit their 5th birthday a
    few weeks ago.

So would it be possible to migrate everything off of /dev/sda and /dev/sdb without major surgery? Or am I going to have to bite the bullet and re-install everything?

4 thoughts on “Is this even possible?”

  1. Yuck. It should be possible, but it’d probably be more work than a reinstall.

    If you have a 3rd SATA port, it should be easy to populate one of the 2Tb drives from the live system. Otherwise, USB. You’ll probably want two partitions – one for the RAID partition which you’ll create an LVM group on, and another for swap (you probably don’t want/need to mirror your swap).

    Once the files are all copied, chroot into the new root disk, install grub, fix up /etc/fstab and reboot with the 500Gb drives removed and the 2Tb drive as /dev/sda. If that works, pop in the second drive as /dev/sdb and do a live migration to RAID-1 – there’s plenty of documentation on that out there, e.g.

    Honestly though, I would just tar up /etc and /home, maybe bits of /var if you have data in there (e.g. /var/lib/mysql), then do a fresh install to the 2x 2Tb disks and restore your data.

    On Debian, `dpkg -l > packages.txt` will record all installed packages – on RedHat derivatives, ‘rpm -qa > packages.txt’ will do the same. Pipe that back into apt-get or yum once you’re up and running on the new system. Then merge your backup of /etc, restore your home partition, and restore whatever else you took out.

    It’s a pain, but it’s probably *less* painful than migrating what you have without doing the reinstall. Less can go wrong, anyway.

  2. Just re-read the article, I missed the 2x 1Tb disks you already added.

    Chances are you do not have a 5th SATA port, but the same goes – plug in one of the 2Tb drives by USB, partition and populate the new disk from your live system, install the bootloader and make the changes to /etc/fstab, then try and boot from it.

    I would still probably prefer the clean reinstall though!

  3. I googled a bit, and it appears ‘sudo dpkg –get-selections > selections’ (which can be restored with ‘ sudo dpkg –set-selections < selections; sudo apt-get update && sudo apt-get -u dselect-upgrade' is a better way of doing the dpkg stuff. And I can make a CPAN bundle to get my perl modules back up to scratch with 'cpan -a', although I'm not sure how you actually restore that.

  4. Huh, I wish I’d known about the “selections” trick last time I did something like this! 🙂

    On the CPAN issue, dh-make-perl is a handy utility for making .deb files from CPAN modules, with automatic (sometimes) dependency resolution – if you keep those .deb files archived then you should be able to re-use them. Or just generate them again from CPAN, I guess.

    That said, these days I actually prefer to keep the system perl untouched and do all my evil Perl stuff with a wholly separate installation within my home dir, using perlbrew. Depends on what you’re doing though, really.

    There’s a Debian package for perlbrew, too, if you’re using wheezy or newer (or Ubuntu 11.10 or newer), maybe a little cleaner in terms of management:

    Finally, I hope you have better luck with your new hard drives than this poor guy did:

Comments are closed.