Updating Debian with fresh install on new drive

The following are the steps I take update Debian by making a fresh install on a clean drive.

Create a drive. There's plenty around to explain this step if you're not sure.

Format and mount the drive.

mkfs.ext4 /dev/sdb1 #enter your drive here
mount /dev/sdb1 /mnt

Install deboostrap and bootstrap the system using your arch and preferred distrobution. Mount proc and dev.

debootstrap --arch amd64 testing /mnt http://ftp.us.debian.org/debian
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev

Backup the following configuration files on the new system and copy the old ones. This will preserve the new system in case of a failure. Also if you plan to install all the same packages make a list of those currently installed.

# drive mounts
/etc/fstab #use blkid to get UUID (/dev/sdb1 can change)
# apt source list
/etc/apt/sources.list
# networking - some of these may already be correct
/etc/hosts
/etc/hostname
/etc/network/interfaces
/etc/resolv.conf
# list of current packages (for installation later)
dpkg --get-selections > /home/packages.list

Chroot into the new system and do some final configuration touches.

LANG=C chroot /mnt /bin/bash
# configure time with system prompt
dpkg-reconfigure tzdata
# install and configure locales
aptitude install locales
dpkg-reconfigure locales
# mount all your drives
mount -a

Migrate users, passwords, groups, etc. One way to do this is to follow these instructions migrate-user-from-old-server-to-new-server. If you're the only user on your machine, you can simply add an identical user.

Update apt. Then install a Linux image and grub. Verify the root account has a password.

aptitude update
# search for appropriate kernel
aptitude search linux-image
# install image, including specific version is you wish (linux-image-3.1.0-1-amd64)
aptitude install linux-image
aptitude install grub2
# if grub-install and update-grub do not fire automatically, you should run them now
# make sure the root password has been set
passwd

The last step is to install up-to-date versions of your current packages on the new system, if you wish. You may, of course, simply set out installing any packages you want with aptitude.

# run these two functions to install all of your current packages
dpkg --set-selections 
Category: 
Tags: