[Cialug] migrating from ubuntu server to debian

Matthew Nuzum newz at bearfruit.org
Thu Apr 15 10:24:59 CDT 2010


Hi, I've posted this at
http://www.bearfruit.org/2010/04/14/migrate-a-live-server-from-ubuntu-to-debian-remotely/

Paul, if you'd like me to link to your blog or some other site let me
know and I"ll update it. Thanks a lot for your help.

On Thu, Mar 25, 2010 at 1:38 PM, Matthew Nuzum <newz at bearfruit.org> wrote:
> On Thu, Mar 25, 2010 at 6:48 AM, Paul Gray <gray at cs.uni.edu> wrote:
>> One other recollection over night -- you may need to generate an /etc/hosts file
>> with at least localhost defined.
>>
>
> Yep, good catch.
>
> OK, I've now done it successfully in virtualbox twice (I'm loving
> snapshots) and these are the steps I used. Once I've completed it on
> live I'll blog about it. Actually, I'm also about to upgrade the
> software on my blog which is why I'm not blogging about it now.
> (waiting till after the change)
>
> Before you start you need to know:
>
> ubuntu-xen-host is the name of my lvm container and in that are root
> (volume for ubuntu), swap and I'm creating a new one called debian.
>
> There is a partition for lvm and a separate, non-lvm partition for
> /boot at hda5.
>
> The kernel for Debian in this case is 2.6.26-2. It may be different
> when you follow these instructions.
>
> This configuration doesn't prevent root from logging into ssh. YOU'LL
> WANT TO CHANGE THIS PRONTO. Look in the sshd-config.
>
> It's a good idea to do a little research before and during so that you
> know what your UUIDs for your filesystems are. Note that the UUID in
> grub's menu.list will point to the /boot filesystem, not to your root
> filesystem.
>
> There's really not a lot of risk here until the very end when you're
> booted into the new os and you isntall grub. At any point before that
> you can reboot and choose the old operating system from the boot menu
> and be back to how you once were. Installing grub is technically
> optional.
>
> I assume you know how to use vim. You can use a different editor, note
> that in the "chroot" section where all the packages are installed
> you'd replace vim with your fav.
>
> I strongly urge against doing a copy and paste of these commands for
> two reasons:
>  1. You should know what you're doing before trying this
>  2. My stupid editor had auto-correct on and I didn't realize it and
> "corrected" some of the commands. I think I got them fixed but I might
> have missed one or two.
>
> Thanks a lot Paul for your tips!
>
> ## end of disclaimer, instructions follow
>
> sudo apt-get install debootstrap
> sudo lvdisplay
> sudo lvcreate -L 8G -n debian ubuntu-xen-host
> sudo mkfs -t ext3 -m 1 -v /dev/ubuntu-xen-host/debian
> sudo mkdir /mnt/debian
> sudo mount -t ext3 /dev/ubuntu-xen-host/debian /mnt/debian/
> sudo debootstrap lenny /mnt/debian/ http://debian.cns.uni.edu/debian #
> takes a while to download packages
> sudo mount --bind /dev /mnt/debian/dev
> sudo mount --bind /boot /mnt/debian/boot
> sudo chroot /mnt/debian/
>
> ## in the chroot now
>
> mount -t proc none /proc
> mount -t devpts none /dev/pts
> apt-get install ssh locales initramfs-tools vim
> linux-image-2.6.26-2-686 lvm2 madam # takes a while to download
> packages
> # you will get a warning about unsigned packages - enter "Yes"
> # you will see many errors about locale and $LANG, ignore for now
> # choose "No" to "create a symbolic link to the current kernel image
> # choose "No" to "abort initrd kernel image installation?"
> # watch the output to make sure that an init ramfs is created - you need this
> # it takes a moment so you'll probably see a message, "Generating
> /boot/initrd.img…"
>
> dpkg-reconfigure locales
>
> # choose at least en_US.UTF-8 (unless you prefer another language)
> # set the default to your chosen language, i.e. en_US.UTF-8
>
> passwd # set the root password
> adduser matthew # substitute your user name
>
> ## exit chroot
>
> sudo cp /etc/network/interfaces /mnt/debian/etc/network/interfaces
> sudo cp /etc/hosts /mnt/debian/etc/hosts
> sudo cp /etc/fstab /mnt/debian/etc/fstab
> ls /dev/disk/by-uuid/ > /tmp/uuid.list
> sudo vim /mnt/debian/etc/fstab /tmp/uuid.list
>
> ## in vim change the uuid for the / partition to be the UUID of the
> newly created "debian" partition
>
> sudo vim /boot/grub/menu.list
> ## in vim add the new kernel to the boot menu as the first option
> changing the root=… part to match the new filesystem you created
> ## uuid should remain these same as it should be pointing at your
> /boot partition
> ## also change the kernel path - for example, /vmlinuz-2.6.26-2-686
> ## and the initrd path to match
> ## also you may want to comment out the line that says "hiddenmenu"
>
> sudo reboot
> ## choose the new operating system from the menu
>
> # login as either root or your personal user and su - to root
> apt-get install grub
> grub-install --no-floppy --recheck /dev/hda
>
> ## it's now OK to remove the original partition if you like
> ## make sure to back up any data
> lvremove /dev/ubuntu-xen-host/root
>
>
> --
> Matthew Nuzum
> newz2000 on freenode, skype, linkedin, identi.ca and twitter
>



-- 
Matthew Nuzum
newz2000 on freenode, skype, linkedin, identi.ca and twitter


More information about the Cialug mailing list