We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

How-To: Remote Ubuntu installation (debootstrap)


RikT
08-08-2012, 14:25
it would be nice if ovh could make it possible for us to do our own netinstalls in vkvm much easier for everyone then

shanto
04-07-2012, 13:53
I have no specific complaint against the default OVH kernel, however, overall the stock Ubuntu 12.04 LTS image offered by OVH (as of today) doesn't look perfect to me. No offense to OVH developers; I know more or less about the limitations in Debian/Ubuntu provisioning infrastructure.

Having that said, I went ahead and tried the debootstrap method first. However, this method failed (once) to boot the new system for me, or when it succeeded, it produced a very minimal system, missing many of the useful packages and sensible defaults which come with a complete/customized server installation. Again, no offense to the OP - this is exactly what debootstrap is good for (chroots, buildroots etc) and thats the best we can get from it. It's not as convenient, flexible and complete as the official installer.

I moved on and tried vKVM along the way with no luck. Finally, I realized that only a remote-install (aka d-i over network-console) is the best we can get from here. And, these steps seems to work:

NOTE: Pay special attention to your boot partition/directory and IP/netmask. Minimal knowledge about GRUB/partitions is required for this to work. It's not a 100% magic recipe.

  1. Install and setup GRUB2 (aka grub-pc in Ubuntu/Debian) on your primary HDD (/dev/sda). You already have it if you have a running OVH Debian/Ubuntu setup. If not, from Netboot/rescue-pro (a Debian), type in:
    PHP Code:
    #If your /dev/sda is not partitioned/broken, run cfdisk and create a bootable partition with at least 50 MB (or as large as your entire HDD) space to hold GRUB plus the netboot/mini.iso.
    cfdisk
    # Mount your bootable partition at /mnt
    mount /dev/sda1 /mnt
    # Install GRUB loader on your primary HDD
    grub-install --boot-directory=/mnt/boot /dev/sda 
  2. Download the appropriate mini.iso (netboot) for your choice of release/arch. I.e.
    PHP Code:
    wget -/mnt/boot/mini.iso "http://mirror.ovh.net/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/mini.iso" # Replace /mnt/boot/mini.iso with /boot/mini.iso if you have booted/rooted from your HDD. 
  3. Add a menuentry to your grub.cfg/custom.cfg:
    NOTE: Use grub-mkconfig/update-grub to generate a new grub.cfg if necessary, depending on on whether you are doing this from a running system or on a fresh bootable partition.
    PHP Code:
    menuentry "D-I Mini" {
        
    insmod linux
        insmod loopback
        insmod iso9660
        set iso
    =/boot/mini.iso
        loopback loop 
    (hd0,1)$iso
        set root
    =(loop)
        
    linux /linux iso-scan/filename=$iso noprompt noeject toram debian-installer/locale=en_US keyboard-configuration/layoutcode=us netcfg/disable_autoconfig=true netcfg/get_nameservers=8.8.8.8 netcfg/get_ipaddress=YOUR.OHV.HOST.IP netcfg/get_netmask=255.255.255.0 netcfg/get_gateway=YOUR.OHV.NET.254 netcfg/confirm_static=true netcfg/get_hostname=installer netcfg/get_domain=local anna/choose_modules=network-console network-console/password=r00tme network-console/password-again=r00tme preseed/early_command="anna-install network-console" mirror/country=manual mirror/http/hostname=mirror.ovh.net mirror/http/directory=/ubuntu mirror/http/proxyDEBCONF_PRIORITY=critical
        initrd 
    /initrd.gz

    These preseed parameters appended to kernel is the key (double check your IP/GW). Our goal is to make d-i land directly onto the network-console without asking ANY question from the console.
  4. Make sure you have timeout=X in your grub.cfg so that it boots automatically into the selected menuitem. Also make sure that grub is set to boot from saved entry.
  5. Set default menuentry for next reboot:
    PHP Code:
    grub-reboot --boot-directory=/mnt/boot X # Where X=# of your new menuentry, or
    grub-reboot --boot-directory=/mnt/boot "D-I Mini" # By NAME 
  6. Finally, reboot and wait (for not more than 5 minutes) for the installer to come online. Connect to the installer, and carry on the installation from there:
    PHP Code:
    reboot
    ...disconnect...
    ping YOUR.OHV.HOST.IP
    ...response...
    ssh installer@YOUR.OHV.HOST.IP # Password: as set above (r00tme) 
    If it fails to come online, reboot again into Netboot/rescue-pro and check your IP/GW and GRUB settings. Also, don't forget to make use of vKVM to see where it fails. Fix the problem and reboot/retry from your HDD again. It may take one or two more tries but the final result is rewarding!
  7. Continue the installation over SSH. Press escape at any stage to return to the main installer menu - change debconf priority to low/medium to customize the installation in more detail.
    NOTE: You are free to do whatever you need to do including RAID, LVM, encryption or anything covered by the official installer. Don't forget to reinstall/setup GRUB from the installer. And again, double check your IP/GW before finish/rebooting from the installer.


Good luck! I hope this procedure helps you save the time I wasted.

Request to OVH: Please consider offering similar boot images from your Netboot/PXE system. This would make our life lot easier.

darkip
03-05-2012, 03:35
Sorry to revive an old thread but I thought I'd pass on the solution to a problem I was having with this guide:

Even after running
Code:
cp /proc/mounts /etc/mtab
I was still getting
Code:
Could not find device for /boot: Not found or not a block device.
The solution I found to this was to run
Code:
cp -a /usr/lib/grub/x86_64-pc/* /boot/grub
which copies the missing stage* files into /boot/grub so that
Code:
grub-install /dev/sda
succeeds

freshwire
21-05-2010, 13:55
Quote Originally Posted by rostayob
I am installing ubuntu via debootstrap, so unless the deb repositories have ovh kernels in it I am not using it...
Correct. The method I showed is not using OVH kernels.

What is the error that you were getting?

rostayob
07-05-2010, 10:54
Quote Originally Posted by YouWhat
You do use OVH kernel, all the linux installs have a OVH customised kernel in them.
I am installing ubuntu via debootstrap, so unless the deb repositories have ovh kernels in it I am not using it...

YouWhat
07-05-2010, 02:39
Quote Originally Posted by rostayob
I never used OVH kernel, so I don't think that's the problem...
You do use OVH kernel, all the linux installs have a OVH customised kernel in them.

rostayob
06-05-2010, 23:28
Quote Originally Posted by YouWhat
you need to replace the kernel 1st

instructions are here http://forum.ovh.co.uk/showthread.php?t=4031

just doesnt work with raid systems, only with single drives at present as I am unsure how to sort the raid config out on linux systems, and for time being I have lost the use of the server I was trying to figure it out on.
I never used OVH kernel, so I don't think that's the problem...

YouWhat
06-05-2010, 22:30
you need to replace the kernel 1st

instructions are here http://forum.ovh.co.uk/showthread.php?t=4031

just doesnt work with raid systems, only with single drives at present as I am unsure how to sort the raid config out on linux systems, and for time being I have lost the use of the server I was trying to figure it out on.

rostayob
06-05-2010, 22:09
I've been trying to install ubuntu 10.04 for the past 4 days, with no success.
the problems I am having are described here: http://forum.ovh.co.uk/showthread.php?t=4035
does someone have suggestions?

gregoryfenton
06-04-2010, 21:38
Code:
cp -R /usr /usr2
change this to
Code:
mkdir /usr2 && cp -R /usr/ /usr2 && rm /usr && mv /usr2/usr / && rmdir /usr2
More to come as I follow this guide

At one point I had this
Code:
root@rescue:/boot/grub# grub-install /dev/sda
df: Warning: cannot read table of mounted file systems: No such file or directory
df: Warning: cannot read table of mounted file systems: No such file or directory
Could not find device for /boot: Not found or not a block device.
To rectify it I did this:
Code:
root@rescue:/boot/grub# cp /proc/mounts /etc/mtab
root@rescue:/boot/grub# grub-install /dev/sda
After this I had a working lucid 64 bit server with /proc/modules \o/

freshwire
08-03-2010, 15:31
Quote Originally Posted by freshwire
ps. Yes I am monkey56657 with a new name!
Hello me!

freshwire
08-03-2010, 15:29
Quote Originally Posted by derchris
Thanks monkey.
Was going to get an Ubuntu guide together at some point, but with no System to test.
Well I had to reinstall because I got a corrupt FS so thought I would do it this way... The guide is from memory though so if anyone finds some mistake let me know.

As for lilo... it should be possible.. but I don't recommend it.

ps. Yes I am monkey56657 with a new name!

derchris
08-03-2010, 13:09
Thanks monkey.
Was going to get an Ubuntu guide together at some point, but with no System to test.

IainK
08-03-2010, 02:52
Nice guide man. Very well presented and all the code looks good. Will have to give this a try next time I deploy a Ubuntu box

@makno: There's not really any good reason to use lilo over grub. It's very outdated.

makno
08-03-2010, 00:17
thanks for this guide will definately same me a lot of time for my soon to come next install, just one question what if i prefer to use lilo instead of grub? any idea how to do that?

freshwire
06-03-2010, 19:02
Here is a quick guide on how to install Ubuntu from scratch via the rescue-pro netboot. This guide is based on the one for debian so kindly written by derchris.

Switch to rescue-pro netbook via OVH manager, reboot and connect with the provided SSH login information then proceed to follow these steps:

1. Format the harddrive and create partitions

PHP Code:
cfdisk /dev/sda 
Replace /dev/sda with the hard disk of choice

2. Create the file systems.

PHP Code:
mkswap /dev/sda1
mkfs
.ext3 /dev/sda2 
Remember to replace sda1/sda2 with the appropriate device/partition number. You can also use mkfs.ext2, mkfs.ext4 or any other that you want to use.

3. Prepare environment and mount FS

PHP Code:
mkdir /ubuntu
mount 
/dev/sda2 /ubuntu 
Remember to change /dev/sda2 to the device/partition you want to install to.

4. Setup debootstrap for use with ubuntu

We first need to have our own copy of /usr as the mounted copy of /usr is currently read-only.

PHP Code:
cp -/usr /usr2
rm 
/usrmv /usr2 /usr 
Get the latest debootstrap from Ubuntu. Those with the name like debootstrap_X.X.X_all.deb would be your best bet.

As of writing the latest is debootstrap_1.0.20_all.deb

PHP Code:
mkdir workareacd workareawapath=$(pwd)
wget "http://archive.ubuntu.com/..../debootstrap_X.X.X_all.deb"
ar -x debootstrap_X.X.X_all.deb
cd 
/
zcat $wapath/data.tar.gz tar xv 
This stage seems overly messy. Ideas welcomed.

5. Install Ubuntu

PHP Code:
debootstrap --arch {ARCH} {DIST} /ubuntu http://mir1.ovh.net/ftp.ubuntu.com/ubuntu/ 
Remember to replace {ARCH} with the architecture of your choice.
Remember to replace {DIST} with the name of the version you wish to choose.


Arch Options: i386 (32bit), amd64 (64bit), hppa, ia64, powerpc, sparc
Dist Options: karmic, jaunty, intrepid, hardy, lucid

6. Configure Ubuntu

PHP Code:
echo "127.0.0.1 localhost" > /ubuntu/etc/hosts
echo "{IP} {hostname}" >> /ubuntu/etc/hosts
echo "{hostname}" > /ubuntu/etc/hostname 
You obviously change {IP} to the IP address of your server and {hostname} to the hostname of your server.

7. Create network config in /ubuntu/etc/network/interfaces

Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  network x.x.x.0
  broadcast x.x.x.255
  gateway x.x.x.254
Remember to replace with the IP addresses etc. as required.

8. Create /ubuntu/etc/fstab

PHP Code:
/dev/sda2   /         ext3     defaults    0 1
/dev/sda1   swap      swap     defaults    0 0
proc        
/proc     proc     defaults    0 0
sysfs       
/sys      sysfs    defaults    0 0 
Remember to replace the device/partitions with those you used as well as select the same file system as you chose earlier (ext2, ext3, ext4)

9. Chroot into new ubuntu and finalize configuration

PHP Code:
mount --bind /dev /ubuntu/dev
mount 
--bind /proc /ubuntu/proc
chroot 
/ubuntu
apt
-get update 
10. Install kernel, grub, ssh

PHP Code:
apt-get install linux-image-server openssh-server grub 
11. Configure grub

PHP Code:
mkdir /boot/grub
grub
-install /dev/sda
update
-grub 
Remember to change /dev/sda to the primary disk.

12. Set root password

PHP Code:
passwd
exit 
13. Fingers Crossed

Change to hdd boot in the Manager before you reboot the server.

PHP Code:
reboot 
If everything was ok, the server should come back online, and then you can ssh into it with user 'root' and the password you set.