Saturday, June 9, 2012

Ubuntu 12.04 migrate form 32-bit to 64-bit

So I see many posts asking if there is a way to upgrade from 32-bit to 64-bit and it can be done without the upgrade mentality which will also give you a forced cleanup of cruft-o-packages. I'm doing this because I wanted to play with KVM and some other 64-bit OS so I need a 64-bit kernel, go figure.... like I don't enough outstanding honey-do's.

Disclaimer: I have been doing SA related work for many years and while this is not a HOWTO but more of my tale of how I accomplished this to give less savvy home admin types yet another reference.

Pre-reqs:
 - Verify the install CD when you boot!!! The ubuntu-12.04-alternate-amd64.iso had a file with a bad MD5 ( https://bugs.launchpad.net/bugs/1010757 ) and bailed on the install so I had to start over with the ubuntu-12.04-beta2-alternate-amd64.iso.
 - Make sure you have two backups! ( one should be on another machine/disk ).
 - Don't freak out if you think something went wrong just stay calm.
 - Pay attention when in the disk partition section that you don't format anything but /boot, swap and /.

Packages I run include web, mythtv-backend, kde, xfce4, mail server w/ spam, amavis, clamav cleaners getting all the nastys coming in the ethers.  I like to play with different window managers because the devs screw it up and lose followers with complete "it's gotta be better" re-writes hint: GNOME devs and Unity.  Look, if you just have a toggle UP: show me all the tweaks and toggle DOWN: hide all the tweaks; that would make more users happy.  Heck, I might even give E17 another look.

My disk layout:
RAID-1 pair
/dev/md0           101018      60169     35633  63% /boot
/dev/md1  ( my swap partition )
/dev/md2         29230360    8181368  19583872  30% /
/dev/md3         67290936   30562360  33310352  48% /home
/dev/md4        382552620  195536600 167583400  54% /data

RAID-5 four 1TB ( mythtv recordings, backups, ripped DVD's, etc )
/dev/md5       2927499732 2455517884 471981848  84% /backup


Section 1 ( info gathering and backup ) :
  - apt-get update; apt-get -y dist-upgrade
  - fdisk -l > before_fdisk_ouput
  - cat /proc/mdstat > before_mdstat_output
  - dpkg -l > before_package_list
  - Backup the system TWICE.

Here are my backup commands ( make sure destination directories exist ):

backitup for backup to the RAID-5
rsync -avx --delete /boot/ /backup/mirror/webby_boot/
rsync -avx --delete / /backup/mirror/webby_root/
rsync -avx --delete /dev/ /backup/mirror/webby_root/dev/
rsync -avx --exclude=".gvfs" --delete-after /home/ /backup/home/

backitup_toquad for backup to my other machine
rsync -avx --numeric-ids --delete /boot/ root@quad:/home/webby_backup/webby_boot/
rsync -avx --numeric-ids --delete / root@quad:/home/webby_backup/webby_root/
rsync -avx --numeric-ids --delete /dev/ root@quad:/home/webby_backup/webby_root/dev/
rsync -avx --numeric-ids --exclude=".gvfs" --delete-after /home/ root@quad:/home/webby_backup/home/

Section 2 (  Install 64-bit version ):
  - Boot the install CD and verify disk for defects!!
  - Install and do the manual disk partitioning and only format /boot, swap and / partitions.

Section 3 ( Install/Remove some packages and make a few backups of new /etc files ):
 Install ssh server and get back old keys and setup
  - apt-get install openssh-server openssh-blacklist openssh-blacklist-extra
  - cp -a /etc/ssh /etc/ssh.sav
  - rsync -axv /$BACKUP/etc/ssh/ /etc/ssh/
  - /etc/init.d/ssh restart
  Now you can log in remotely if you want i.e. if you have keys setup ;)

  Optional -  I have scripts and info I need here
  - rsync -axv /$BACKUP/root/ /root/

  Optional - this is more of a server machine so I whack Network Manager
  - apt-get remove network-manager

 Copy hosts, fstab, passwd, group, interfaces
  - cp fstab fstab.64-bit
  You might want to merge the other filesystems into the new fstab if you did not set those up during install.  I just added /home, /data and /backup to the new /etc/fstab.

  - mount -av
  Make sure at least the /backup mounts so you can copy necessary file back.

  - cp -a passwd passwd.64-bit
  - cp -a group group.64-bit
  - cp -a shadow shadow.64-bit


  - cp /$BACKUP/etc/hosts /etc/
  - cp /$BACKUP/etc/network/interfaces  /etc/network/
  - cd /$BACKUP/etc ; cp passwd group shadow shadow- passwd- group- /etc/
  NOTE: user and group id's are not consistent even between like distros so we must fix
  since we copied our versions back.

  - chown -R lightdm:lightdm /var/lib/lightdm
  - chown -R avahi-autoipd:avahi-autoipd /var/lib/avahi-autoipd
  - chown -R couchdb:couchdb /var/lib/couchdb
  - chown -R avahi:avahi /var/run/avahi-daemon
  
Moved this step up as my sound card and logins were getting consolkit dbus error messages when logging in.  This is because the user and group id's for system accounts are not consistent i.a. the user creation scripts will just pick unused account and group numbers.
  - apt-get --reinstall install pulseaudio pulseaudio-module-gconf pulseaudio-utils dbus dbus-x11 gstreamer0.10-pulseaudio pulseaudio-module-gconf pulseaudio-module-x11 pulseaudio-utils python-dbus python-dbus-dev

Section 4 ( reboot, copy back files and re-install packages ):


  - reboot
  Login and make sure everything fires up AOK.


  - cd /$BACKUP/etc ; rsync -axv Mutt* amavis apache2 fail2ban* my* nx* postfix razor spamassassin /etc/
  - cd /$BACKUP/var/lib ; rsync -axv amavis spamassassin nxserver /var/lib/
  - cd /$BACKUP/usr/local/bin; cp librarian-notify-send MythDataGrabber mythicalLibrarian myth-status procmail-check.pl spamfilter /usr/local/bin/
  - cd /$BACKUP/var ;  rsync -axv www /var/
  - cd /$BACKUP/etc ; rsync -axv apache2/ /etc/apache2/
  - cd /$BACKUP/etc/default ; cp google-musicmanager spamassassin mythweb /etc/default/
  - cd /$BACKUP/etc/apt/sources.list.d/ ; cp freenx-team-ppa-lucid.list chromium-daily-ppa-lucid.list google-musicmanager.list /etc/apt/sources.list.d/
  - cd /$BACKUP/etc/apt/ ; cp trusted* /etc/apt/

  NOW compare your dpkg  -l output with the file before_package_list created above. look for packages need to be re-installed.


  - dpkg -l > now_package_list
  - diff -b -y now_package_list before_package_list


Here are a few runs I did:

  - apt-get install vim amavisd-new apache2 php5 spamassassin postfix mythtv-backend mythweb flashplugin-installer clamav clamav-daemon lha arj unrar zoo nomarch lzop cabextract p7zip ttf-mscorefonts-installer mythtv-frontend mythtv-database xmltv-util procmail mysql-server razor bsd-mailx libclamunrar6



  - dpkg -l > now_package_list
  - diff -b -y now_package_list before_package_list

  - apt-get install openjdk-6-jdk icedtea-6-plugin icedtea-plugin fonts-ipafont-mincho ttf-telugu-fonts ttf-oriya-fonts ttf-kannada-fonts ttf-bengali-fonts fonts-ipafont-gothic
  - apt-get install lame rsstail openshot lzop lynx logwatch picard mp3info iptraf irssi git ethtool curl cvs arj agrep irssi-scripts git-cvs git-svn
  - apt-get install imagemagick enscript ffmpeg x264 mencoder ddclient mythplugins mythnetvision mythweather

  - dpkg -l > now_package_list
  - diff -b -y now_package_list before_package_list

Yeah..... everything should be a right a rain :)

2 comments:

  1. silly question: having a list of packages without updating sources.list doesn't really work. how do you managed to "upgrade" the sources.list file?

    ReplyDelete
  2. You don't necessarily upgrade the sources.list you overwrite when install a new one the 64-bit install from the CD/DVD, you can add additional sources in afterwards. The reason to capture the packages is you have a list of what was installed so you can re-install them. Make a backup and a copy of that backup if this machine is important.

    ReplyDelete