Recently I wanted to upgrade (plop in a bigger) my hard drive in my laptop. Currently I have Ubuntu 7.10 installed with whole disk encryption. The only change I was making was the size of my hard drive. I wasn’t sure how I’d mount an encrypted partition managed via LVM. But I was willing to learn. I also wanted to basically pick up where I had left off. I wanted all the same apps installed on the new drive as the old one. I didn’t think dd would do the trick as I’d be limited to the size of the smaller drive, thus defeating the purpose. So…two Google searches later I found what I need to get going.

  1. Dump a list of all the installed programs from the old system:

    dpkg -l | awk '{print $2}' > installed_packages.txt
    
  2. Remove old hard drive

  3. Install new hard drive
  4. Install Ubuntu 7.10 Using Alternate CD with option to install whole disk LVM encryption
  5. Boot into new system
  6. Ctrl+Alt+F1 drop to terminal
  7. Switch to root and stop the graphic desplay

    sudo su -;/etc/init.d/gdm stop
    
  8. Move the newly created home directory

    mv /home/rjmolesa /home/rjmolesa.old
    
  9. Attach the old hard drive with USB enclosure

  10. Enter LUKS password
  11. Locate the LVM group that the old encrypted hard drive is in:

    vgscan
    
  12. Create a mount point and mount the old partition

    mkdir /mnt/oldhdenc;mount /dev/[LVM GROUP]/root /mnt/oldhdenc -o ro,user
    
  13. Get my home dir copied over:

    rsync /mnt/oldhdenc/home/rjmolesa /home/
    
  14. Install all the packages I had on the old system:

    apt-get install `cat installed_packages.txt`
    

I think that’s about it.

References:

Technorati Tags: Upgrading Replacing LUKS encrypted hard drive Ubuntu 7.10