Debian Latest Release Installation Via Netboot

From PrgmrWiki

ATTENTION: THIS DOCUMENT IS UNDER DEVELOPMENT. PLEASE, DO NOT FOLLOW THESE INSTRUCTIONS YET. THIS IS UNFINISHED WORK WHICH MUST BE FORMATTED AND REVIEWED BY PRGMR STAFF.

Introduction

This document is intended to provide you with basic guidelines to get a fresh install of latest Debian stable release up and running on your host. Make sure ALL valuable data has been properly backed-up offline pior to actually performing ANY of these commands on your host as this can an WILL DESTROY all data on your virtual disk.

Pre-Installation Decision

The current default bootloader used by PRGMR is GRUB 0.97 (A.K.A. GRUB Legacy), which supports filesystems of BSD FFS, DOS FAT16 and FAT32, Minix fs, Linux ext2fs, ReiserFS, JFS, XFS, and VSTa fs types. GRUB 0.97 supports Linux ext3fs too, since it's just Linux ext2fs with journaling support. Latest Debian (currently 7.x) current default filesystem type is Linux ext4fs, which is not supported by GRUB 0.97. If you want to use automatic partitioning (guided partitioning) of the disk during the installation without separation of the partitions, which is the simplest possible layout, you must review the partitioning layout and change the format of the new (root) partition to ext3fs (recommended) or ext2fs. This also applies for guided partitioning with separated filesystems where the /boot directory does not have its own filesystem. If you want to make use of ext4fs or have any sort of custom layout (LVM, Encrypted, etc.), make sure you have a separated /boot partition of ext3/ext2 type, so GRUB 0.97 will be able to access it.

The basic instructions for both layouts are the same, but at a given time, there will be a fork for the rest of these guidelines, so pay a lot of attention to the instructions and information provided. Don't just copy and paste everything you see in here. Make sure you fully follow and understand what you're doing, BEFORE doing it.

The Basics

Preparing Your Virtual Disk To Boot via Netinstall

ATTENTION! THE FOLLOWING STEPS WILL DESTROY ALL THE DATA ON YOUR DISK! MAKE SURE YOU HAVE PROPER BACKUP OF VALUABLE DATA OUT OF YOUR HOST BEFORE YOU CONTINUE!

Boot CentOS rescue.
Log in as root.

Creating A New Partition Table

# fdisk /dev/xvda

You'll see

The number of cylinders for this disk is set to 3133.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help):

Type

o

and press enter to create a new empty DOS partition table.

You'll see

Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 3133.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):

We, now, have an empty partition table.

Creating A New Partition For The Netboot Files

Create a new partition, which will hold the netboot files.

Type

n

and press enter to add a new partition.

You'll see

Command action
   e   extended
   p   primary partition (1-4)

Type

p

and press enter to add the new partition as a primary partition.

You'll see

Partition number (1-4):

Type

1

and press enter to define the new partiton as the first one on the virtual disk.

You'll see

First cylinder (1-3133, default 1):

Press enter or type

1

and press enter, to define the start of the new partition at cylinder 1.

You'll see

Last cylinder or +size or +sizeM or +sizeK (1-3133, default 3133):

IMPORTANT TIP: If you're going for a custom partition layout during the installation or intend to use a filesystem different from ext2/ext3 for the partition where the /boot directory will reside/be mounted on, you can have the /boot partition size defined in the next step, so you don't have to create/format it later during the installation. If you're using ext3 for the rest of the installation, give it, at least, about 100MB, as this will just be used for booting and can be removed later, during the installation, in the partitioning step.

Type

+512M

and press enter, to give the new partition a size of 512MB, which shall be more than enough to hold the netboot files.

You'll see

Command (m for help):

Type

w

and press enter to write table to disk and exit.

You'll see

The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#

We must now format the new partition to accomodate the netboot files.

Type

# mkfs.ext3 -L BOOT /dev/xvda1

and press enter.

You'll see

mke2fs 1.39 (29-May-2006)
Filesystem label=BOOT
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
126976 inodes, 506016 blocks
25300 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
62 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
#

The Netboot Files

To provide the best generic instructions, we will create a directory to hold the netboot files, so those who will/won't keep their /boot partition untouched during the installation will have the same instructions. If you're leaving your /boot partition untouched, this will make sure the netboot files don't get mixed with the system files after the installation. If you're going to remove or recreate the /boot partition, this won't matter in the end, as the whole partition will be gone after the installation.

Mounting The New Partition

Mount the new partition to download the netboot files into it.

Type

# mount -n /dev/xvda1 /mnt

and press enter.

Check to see if it is mounted, by typing

# mount | grep /dev/xvda1

and pressing enter.

You'll see

/dev/xvda1 on /mnt type ext3 (rw,data=ordered)

Create the directory to hold the netboot files, by typing

# mkdir /mnt/netboot

and pressing enter.

Go into that directory, by typing

# cd /mnt/netboot

Type

# pwd

and you should see

/mnt/netboot

Getting The Netboot Files

You can get the files via one single command line loop or manually download each of the files, as follows.

Download Loop

In order to get all the files for the netboot, type the following, in a single line

# for f in debian.cfg initrd.gz vmlinuz; do wget http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/xen/$f; done

IMPORTANT TIP: Currently, latest stable release of Debian is Wheezy. Should that not be the latest release, you must replace the word wheezy in the command line with the codename for the latest stable release of Debian.

Once you get back to the prompt, proceed to the step Listing The Downloaded Files.

Manual Download

If you'd rather manually download each file, go to http://www.debian.org/. Under the section Getting Debian, click on Network Install.

File:Example.jpg

When the page loads, under Network boot, on the bottom right corner of the page, select the architecture of the installation you're going to perform. For this document, we will use amd64 architecture.

File:Example.jpg

When the next page loads, under Directory, click on netboot.

File:Example.jpg

When the next page loads, under Directory, click on xen.

File:Example.jpg

Finally, when the next page loads, under Filename, you'll see the Netboot files you need to download.

File:Example.jpg

For each file, right-click on its name, copy the URL and paste in the end of the following command line, followed by enter.

# wget replace_this_text_by_pasting_the_url_of_the_file_here

Once you've done it for each of the files, proceed to the step Listing The Downloaded Files.

Listing The Downloaded Files

Provided that there were no errors during the download of the files, type

# ls -l

and press enter.

You should see

total 31237
drwxr-xr-x 2 root root     1024 Jun 20 17:42 .
drwxr-xr-x 4 root root     1024 Jun 20 17:42 ..
-rw-r--r-- 1 root root     6237 Apr 24 07:53 debian.cfg
-rw-r--r-- 1 root root 29010994 Apr 24 07:49 initrd.gz
-rw-r--r-- 1 root root  2837920 Apr 24 07:53 vmlinuz

otherwise, check the previous steps carefully and make sure everything has been followed correctly.

Umount The Partition Properly

Umount the partition properly by typing the following

# cd
# umount -n /dev/xvda1

each, followed by enter.

Then, shutdown the host, by typing

# shutdown -h now

and pressing enter.

Booting Into The Netinstall

Create/start your VPS.

Once you see the GRUB menu list, press

c

If you missed it and your system booted into 'user bootloader configuration', you'll see

  Booting 'user bootloader configuration'

root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
configfile /boot/grub/menu.lst

Error 15: File not found

Press any key to continue...

It's OK. Just press any key to go back, then, press

c

You'll see

    GNU GRUB  version 0.97  (1048576K lower / 0K upper memory)

       [ Minimal BASH-like line editing is supported.   For
         the   first   word,  TAB  lists  possible  command
         completions.  Anywhere else TAB lists the possible
         completions of a device/filename.  ESC at any time
         exits. ]

grubdom>

You're now on the GRUB command line interface. Set the root for the operations of current session of GRUB command line interface, by typing the following command:

grubdom> root (hd0,0)

and press enter.

You should see

 Filesystem type is ext2fs, partition type 0x83

Now, we must tell GRUB where it will find the kernel to boot, by typing

grubdom> kernel /netboot/vmlinuz

and pressing enter.

There should be no replies, except for and empty line.

Now, we must tell GRUB where to find the initrd image, by typing

grubdom> initrd /netboot/initrd.gz

and pressing enter.

After a couple of seconds, it should return to the GRUB command line prompt. If it takes more than 10 seconds, or you receive any error messages, you should check and see if you have followed the instructions correctly.

Now, we must tell GRUB to boot with the specified parameters, by typing

boot

and pressing enter.

If everything is OK, the installation will start.
Proceed with normal installation, keeping in mind the partitions layouts and formats previously discussed.
Once the installation is finished, come back to finish the necessary tweaks for your system to boot properly without intervention whenever you need to reboot your VPS.

The Pre-First Boot (Fixing GRUB)

At the first boot, when you see the GRUB menu, select the

CentOS Rescue

If you missed it, and see

  Booting 'user bootloader configuration'

root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
configfile /boot/grub/menu.lst

Error 15: File not found

Press any key to continue...

just press any key to return to the GRUB menu, select the CentOS rescue option and press enter.

Log in as root.

List your partitions with

# fdisk -l /dev/xvda

You should see something like this:

Disk /dev/xvda: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          63      506016   83  Linux
/dev/xvda2              64        3133    24657921    5  Extended
/dev/xvda5              64        3003    23607296   83  Linux
/dev/xvda6            3003        3133     1049600   82  Linux swap / Solaris

As previously, /dev/xvda1 is our /boot partition. And the rest of the partitions are: /dev/xvda2, which is our extended partition containing /dev/xvda5, which is our root (/) filesystem and /dev/xvda6, which is our SWAP partition.

Mount your /boot partition (Replace the /dev/xvda1 with the proper partition path, if you have chosen to follow a different partition schema. If you have chosen to have a single filesystem, formatted as ext3fs, mount the root filesystem instead), by typing

# mount -n /dev/xvda1 /mnt

Go into the /mnt directory, typing

# cd /mnt

If you have chosen the single partition schema, go into the /mnt/boot directory, typing

# cd /mnt/boot

Now, if you have a separate /boot partition, type

# ln -s . boot

in order to create a loopback symbolic link, so that it fits the PRGMR bootloader configuration.

List the current directory (NOTE that the option for the ls command is 'minus ONE').

# ls -1 | grep -iE \(^initrd\.img\|^vmlinuz\)

which should return something like

initrd.img-3.2.0-4-amd64
vmlinuz-3.2.0-4-amd64

Write those down.

Return to the home directory so that you're out of the mount point, by typing

# cd

Umount the partition

# umount -n /mnt

and then reboot

# shutdown -r now

The First Boot

Once the GRUB menu appears, type

c

to access the GRUB command line.

Again, if you missed it, just press any key and, when back at the GRUB menu, press

c

You should see

    GNU GRUB  version 0.97  (1048576K lower / 0K upper memory)

       [ Minimal BASH-like line editing is supported.   For
         the   first   word,  TAB  lists  possible  command
         completions.  Anywhere else TAB lists the possible
         completions of a device/filename.  ESC at any time
         exits. ]

grubdom>

Set the root for the operations of current session of GRUB command line interface, by typing the following command:

root (hd0,0)

You should see

 Filesystem type is ext2fs, partition type 0x83

Now, let's tell GRUB where to find the kernel. But, this time, a little bit differently from the last one. We must also inform the new path to the current kernel and the root filesystem partition for our brand-new installation. Remember replacing /boot/vmlinuz-3.2.0-4-amd64 with the path and name of the kernel you wrote down in previous steps and /dev/xvda5 with the partition for your root (/) layout.

grubdom> kernel /boot/vmlinuz-3.2.0-4-amd64 root=/dev/xvda5

It should return to the GRUB prompt without any errors. Otherwise, revise the last steps and check where you went wrong.

Next, we must inform the path to the initrd image. Again, replace /boot/initrd.img-3.2.0-4-amd64 with the path and name of your initrd image file.

grubdom> initrd /boot/initrd.img-3.2.0-4-amd64

It should also return to the GRUB prompt withouth any errors. Like the previous command, if you received any messages or it is taking too much time (more than 10 seconds, generally), you should check your previous steps and see what is missing.

Finally, tell GRUB to boot the system with the informed parameters.

boot

and press enter.

Once the system is fully loaded, log in with your root account.

Update your system (only needed if you haven't followed the whole procedure at once, to make sure your system packages are up-to-date) by typing

# apt-get update && apt-get dist-upgrade

and pressing enter.

Install GRUB 0.97 (A.K.A grub-legacy), by typing

# apt-get -y install grub-legacy

and pressing enter.

This will remove the grub-pc and grub2-common packages from the system.

In order to update the GRUB menu, type

# update-grub

and press enter.

You should see something like

Searching for GRUB installation directory ... found: /boot/grub
[  659.247910] device-mapper: uevent: version 1.0.3
[  659.247997] device-mapper: ioctl: 4.22.0-ioctl (2011-10-19) initialised: dm-devel@redhat.com
Searching for default file ... Generating /boot/grub/default file and setting the default boot entry to 0
Searching for GRUB installation directory ... found: /boot/grub
Testing for an existing GRUB menu.lst file ... 


Generating /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /vmlinuz-3.2.0-4-amd64
Updating /boot/grub/menu.lst ... done

Now, cleaning up the dross

# apt-get -y autoremove --purge && apt-get autoclean

which should return something like

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  grub-pc-bin*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,871 kB disk space will be freed.
(Reading database ... 24549 files and directories currently installed.)
Removing grub-pc-bin ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done

Shutting Down and Testing

Finally, shutdown your VPS,

# shutdown -h now

then Create/Start it and let it start unnattended to check if it is all running sharp and shinny.