December 14, 2010
UPDATE, Tilaa now have Native Gentoo Support starting from August, so no need to follow this method as updated in the comments.
Last week, i ordered a VPS from
Tilaa.nl for testing, they use KVM Virtualization, IPv6 support and prices are good, also traceroute to middle east seems to be better than other locations, so that pushed me to test.., but suddenly they didn't support Gentoo, after contacting the support, they seems will support Gentoo Next couple of months, anyway i like to use Gentoo, so i wrote the following steps to get Gentoo Installed and Running at your VPS @
Tilaa.nl ...
First, we need to resize the current disk to install gentoo in a new partition, i used to compile gentoo kernel with support for virtio modules to get network, after that, i add resize2fs, fdisk commands to initramfs with the modules need to get the disk and network, in this way, i just need to boot to this kernel and resize the current big root partition which i can't shrink while using it!, you can download them from the following links:
http://sqawasmi.com/files-mix/kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6
http://sqawasmi.com/files-mix/initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz
NOTE: This steps works for me, There is no guarantee that this steps will work with you, you may Lose all of your VPS Data, use this steps on your responsibility..
NOTE: IF you are not familiar with shrinking ext3, then i suggest to stop reading!, the following tutorial may help: http://www.howtoforge.com/linux_resizing_ext3_partitions
* after downloading them to your VPS, follow the following steps..
* cp kernel/initramfs to current distro /boot/
cp kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6 /boot/
cp initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz /boot/
* then edit /boot/grub/menu.lst to add the following
title Gentoo Install
root (hd0,0)
kernel /boot/kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6 ro root=LABEL=/notexist console=tty0 console=ttyS0,115200 notsc divider=10
initrd /boot/initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz
* From tilaa Dashboard, browse to your VPS and open the VPS serial console, after that do a reboot for the VPS from CLI:
[root@m1 ~]# reboot
Broadcast message from root (pts/0) (Tue Dec 14 19:12:39 2010):
The system is going down for reboot NOW!
[root@m1 ~]# Connection to 46.19.32.39 closed by remote host.
Connection to 46.19.32.39 closed.
* Now, at the console window, choose Gentoo Install (or the name you wrote in grub as title for Gentoo Boot), after the kernel boot, you should get the following message:
!! Could not find the root block device in LABEL=/notexist.
Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...
root block device(LABEL=/notexist) ::
* so just type shell and hit enter to use shell, here we will start the resizing (i resized root partition to 3G, leaving the rest for Gentoo):
!! Block device sh is not a valid root device...
!! Could not find the root block device in .
Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...
root block device() :: shell
To leave and try again just press <Ctrl>+D
BusyBox v1.7.4 (2010-12-09 17:35:51 EET) built-in shell (ash)
Enter 'help' for a list of built-in commands.
/bin/ash: can't access tty; job control turned off
#
#
# fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000563f9
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20971488+ 83 Linux
Disk /dev/vdb: 1073 MB, 1073741824 bytes
139 heads, 8 sectors/track, 1885 cylinders
Units = cylinders of 1112 * 512 = 569344 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00093111
Device Boot Start End Blocks Id System
/dev/vdb1 1 1886 1048575+ 82 Linux swap / Solaris
# resize2fs /dev/vda1 3G
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/vda1' first.
# e2fsck -f /dev/vda1
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/: 31369/5207040 files (1.0% non-contiguous), 406948/5242872 blocks
# resize2fs /dev/vda1 3G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vda1 to 786432 (4k) blocks.
The filesystem on /dev/vda1 is now 786432 blocks long.
**** Note what i colored by red: 786432 (4k) blocks -- you will use this to do the correct fdisk or you will lose your system!, the output in your case should be different from mine, so copy the number of blocks that you got because you will use them in calculating the new size later, if you didn't do that, then i suspect that you will lost the system..
* Now shutdown your VPS from tilaa website and start it again to boot into your old Distro.. (it may take a little of time to shutdown/start)
* Ok, if you are lucky (seems i was) you will get your old distro, login to it through ssh, now you need to do the main part, fdisk:
[root@m1 ~]# fdisk -l
Disk /dev/vda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20971488+ 83 Linux
Disk /dev/vdb: 1073 MB, 1073741824 bytes
139 heads, 8 sectors/track, 1885 cylinders
Units = cylinders of 1112 * 512 = 569344 bytes
Device Boot Start End Blocks Id System
/dev/vdb1 1 1886 1048575+ 82 Linux swap / Solaris
[root@m1 ~]# fdisk /dev/vda
The number of cylinders for this disk is set to 2610.
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): p
Disk /dev/vda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20971488+ 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +3303014K
* as you can see i entered +3303014K as last Size, i calculated this from 786432 (4k) blocks (the output of previous resizefs command) as the following:
(786432 * 4096 * 1.05) /1024 = 3303014.4000000004
* SO USE THIS To calculate the expected Size (Change 786432 to the number of blocks you got from your resizefs command)
* After that continue creating the new partition..
Command (m for help): p
Disk /dev/vda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 1 412 3309358+ 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (413-2610, default 413):
Using default value 413
Last cylinder or +size or +sizeM or +sizeK (413-2610, default 2610):
Using default value 2610
Command (m for help): p
Disk /dev/vda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 1 412 3309358+ 83 Linux
/dev/vda2 413 2610 17655435 83 Linux
Command (m for help): a
Partition number (1-4): 1
Command (m for help): p
Disk /dev/vda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 412 3309358+ 83 Linux
/dev/vda2 413 2610 17655435 83 Linux
Command (m for help): Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@m1 ~]# sync
* when you finish, reboot to get the new partition synced:
root@m1 ~]# reboot
Broadcast message from root (pts/0) (Tue Dec 14 19:37:32 2010):
The system is going down for reboot NOW!
[root@m1 ~]# Connection to 46.19.32.39 closed by remote host.
* Ok, now after the reboot, login to your VPS through ssh and check the disks:
shaker ~ $ ssh root@46.19.32.39
Last login: Tue Dec 14 19:35:38 2010 from 79.134.143.45
[root@m1 ~]# fdisk -l
Disk /dev/vda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 412 3309358+ 83 Linux
/dev/vda2 413 2610 17655435 83 Linux
Disk /dev/vdb: 1073 MB, 1073741824 bytes
139 heads, 8 sectors/track, 1885 cylinders
Units = cylinders of 1112 * 512 = 569344 bytes
Device Boot Start End Blocks Id System
/dev/vdb1 1 1886 1048575+ 82 Linux swap / Solaris
* So, now you have vda1 and vda2 !, now you can do mkfs.ext3 /dev/vda2 and continue installing your Gentoo from Stage3, as documented, everything should be easy:
[root@m1 ~]# mkfs.ext3 /dev/vda2
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2207520 inodes, 4413858 blocks
220692 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
135 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
* I always follow the instructions documented in
http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=5
* anyway, the following are the steps in general:
# mkdir /mnt/gentoo && mount -t ext3 /dev/vda2 /mnt/gentoo && cd /mnt/gentoo/ && wget http://mirror.leaseweb.com/gentoo/releases/amd64/current-stage3/stage3-amd64-20101211.tar.bz2 && wget http://mirror.leaseweb.com/gentoo/snapshots/portage-latest.tar.bz2
[root@m1 gentoo]# cd /mnt/gentoo/ && time tar xjf stage3-amd64-20101211.tar.bz2 && time tar xjf portage-latest.tar.bz2 -C user/
[root@m1 gentoo]# echo 'GENTOO_MIRRORS="http://mirror.leaseweb.com/gentoo/"' >> etc/make.conf
[root@m1 gentoo]# cp /etc/resolv.conf etc/
[root@m1 gentoo]# mount -t proc none /mnt/gentoo/proc
[root@m1 gentoo]# mount -o bind /dev /mnt/gentoo/dev
[root@m1 gentoo]# chroot /mnt/gentoo/ /bin/bash
m1 / # PS1='\[\033[01;31m\]\h - chroot\[\033[01;34m\] \W \$\[\033[00m\] '
m1 - chroot / # emerge --sync
* I use distcc, that will reduce the time used to compile packages by distributing compilation over other servers, at my VPS i allowed all 10.0.0.0/8 network to use my server as distcc to help them finish the compilation (btw, as of this writing, you should use gcc-4.4.X becuase that what i use at my distcc server), if you wanna use my VPS, then do the following or you can skip this if you don't need my VPS support..:
m1 - chroot / # USE='-*' emerge --nodeps sys-devel/distcc
m1 - chroot / # distcc-config --set-hosts "10.0.0.252"
* Finally, i install vim and openssh and configure the network so it be accessible after reboot (i continue the installation of Gentoo from Gentoo itself!):
m1 - chroot / # emerge vim openssh
* Run openssh at boot:
m1 - chroot / # rc-update add sshd default
* Uncomment s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100 in /etc/inittab to get Console access.
* Add Your IP and Gateway to /etc/conf.d/net ,, i have the following, change IPs to yours:
modules=( "ifconfig" )
config_eth0=(
"46.19.32.39 netmask 255.255.255.0"
)
routes_eth0=(
"default via 46.19.32.1" # IPv4 Default route
"default via 2001:1af8:3100:b000::1" # IPv6 Default route
)
* Add a root password..
* Add a correct /etc/fstab file, simply i used to copy it from my current Distro (CentOS) and changing LABEL=/ to /dev/vda2 , the following is mine:
[root@m1 ~]# cp /etc/fstab /mnt/gentoo/etc/fstab
cp: overwrite `/mnt/gentoo/etc/fstab'? y
[root@m1 ~]# perl -p -i -e 's|LABEL=/|/dev/vda2|' /mnt/gentoo/etc/fstab
[root@m1 ~]# cat /mnt/gentoo/etc/fstab
/dev/vda2 / ext3 defaults 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
UUID=358a1f7f-27bf-43f9-aefd-b3203669539b swap swap defaults 0 0
*** Finally don't forget to edit Grub and have your Gentoo listed, i have the following:
title Gentoo
root (hd0,0)
kernel /boot/kernel-kvm-tilaa-shaker-x86_64-2.6.34-hardened-r6 ro root=/dev/vda2 console=tty0 console=ttyS0,115200 notsc divider=10
initrd /boot/initramfs-kvm-tilaa-shaker-RESIZE-DISK3.gz
* Open the Console & Reboot..
* after logging to the server through ssh, activate eth1 by your private IP, i used the following command:
ifconfig eth1 10.0.0.252 netmask 255.0.0.0
* Continue Installation for gentoo just as the manual & Have Fun!
Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.
Posted in Linux others..
December 15th, 2010 at 12:56 pm
Hi Shaker, nice article!
I was wondering what’s the reason for the ‘notsc’ and ‘divider=10’ boot options you’re using? Newer kernels shouldn’t need those.
September 8th, 2011 at 2:08 am
Tilaa has native Gentoo support since August, see also http://blog.tilaa.nl/2011/08/tilaa-is-supporting-gentoo.html
September 9th, 2011 at 3:37 am
Great work, thanks for the update!