Delete Unused Rackspace Cloud Servers

To avoid any unnecessarily high Rackspace bills, make sure you delete any unused cloud servers or products.

Here I have three servers. One is in production, another is occasionally used for testing and development. I am half-way through setting the last one up but it is not yet in production.

You might think that you can just power-off the server to stop being billed for it….but you’d be wrong! If you simply shut down the server, you will still be billed per hour for it’s use.

If like me, you have any servers that are not currently in use, either by you or your customers, it makes sense to take an image of the device and then delete it. You can always spin up a new server from the image you create.

Take an Image

To take an image, click the cog icon next to the server. That will create a drop-down menu. Within there, you will see “Create Image” – select that.

Taking an image
Taking an image

You will then be asked to give the saved image a name. If you hover over the small pound sign symbol, you will also see the associated costs.

Give the image a name.
Give the image a name.

Delete Server

Before I delete a server I might come to rely on later, I like to first make sure the image was created successfully. To do that, navigate to the “Saved Images” section/tab.

Saving images.
Saving images.

Once imaged, simply select the servers you wish to delete and click on the “Delete” button.

Deleting servers
Deleting servers

Rebuild Server from an Image

When you next require the deleted server, we can spin up a new server from the image we took.

One downside to this is that the newly created server will have a different public IP address than it did previously. If this is an issue for you, I would recommend creating a load-balancer to sit in front of the device. It is possible to have a load-balancer with one node behind it. Load-balancers IP addresses do not change.

To spin up a new server from an existing image, simply navigate to the “Saved Images” section of the server tab. Click on the cog next to the image you wish to use and select “Create Server with Image...“.

Then simply give the server a name, select a flavour and/or alter any other details. Then click on “Create Server“.

You will be given a new password for the server. Make a note of this and “Dismiss Password” when ready.

Root Admin Password
Root Admin Password

You can monitor the progress from the cloud servers tab.

Cloud Server Rebuilding
Cloud Server Rebuilding

Job done!

Fix a Broken Gentoo Installation

Here is how I gain access to my broken environment…

mount /dev/mapper/vg--ssd-lv--root /mnt/gentoo/

mount -v /dev/mapper/vg--ssd-lv--boot /mnt/gentoo/boot/
mount -v /dev/mapper/vg--hdd-lv--home /mnt/gentoo/home/
mount -v /dev/mapper/vg--hdd-lv--var /mnt/gentoo/var/
mount -v /dev/mapper/vg--hdd-lv--usrportage /mnt/gentoo/usr/portage/
mount -v /dev/mapper/vg--hdd-lv--vhdd /mnt/gentoo/vhdd/
mount -t proc none /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev


ls /mnt/gentoo/ /mnt/gentoo/boot/ /mnt/gentoo/home/ /mnt/gentoo/var/ /mnt/gentoo/usr/portage/ /mnt/gentoo/vhdd/ /mnt/gentoo/proc /mnt/gentoo/sys /mnt/gentoo/dev

swapon -p 1 /dev/sdc1 && \
swapon -p 1 /dev/sdd1 && \
swapon -v -s


chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"

Fix what your gonna fix, un-mount and reboot. Fingers crossed!

exit
cd
umount -lv /mnt/gentoo/dev{/shm,/pts,}
umount -lv /mnt/gentoo{/boot,/proc,}
reboot

Gentoo: List of Issues After an Installation

Pretty much every time I install Gentoo I hit a new minor issue that requires my attention. Sometimes its caused by a new version of a particular package, sometimes I’ve simply forgot to configure something correctly. Either way, here is an on-going list of issues that I’ve faced after a new installation.

Networking Interfaces Renamed

The networking interfaces were renamed from eth0 to enp10s0 and enp09s0. While this did not make any difference as to whether or not they work, it is annoying!

storm ~ # ifconfig
enp10s0: flags=4163  mtu 1500
        inet 192.168.111.4  netmask 255.255.255.0  broadcast 192.168.111.255
        inet6 fe80::223:8cff:fe7b:5f0g  prefixlen 64  scopeid 0x20
        ether 00:23:8c:7b:5f:0g  txqueuelen 1000  (Ethernet)
        RX packets 2161  bytes 226082 (220.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 96  bytes 16270 (15.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp9s0: flags=4099  mtu 1500
        ether 00:21:7c:7b:60:ff  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Fix

To fix, just run the following command (as root) and then reboot.

storm ~ #  touch /etc/udev/rules.d/80-net-name-slot.rules 

RAID Devices Renamed

The RAID devices work renamed from /dev/md0, /dev/md1 and /dev/md2 to /dev/md126, /dev/md127 and /dev/md128. Again they work, but quite annoying!

Fix

If you are affected by this issue (and it bothers you), you may need to alter your /etc/mdadm.conf file to include a map between the UUID and the device name. In which case you first need to make a note of the UUID, which you can find with mdadm --detail /dev/md126 and then add an entry similar to the below.

Obviously you need to make sure the right UUID matches the right device name!

nano /etc/mdadm.conf


ARRAY /dev/md0 uuid=bffb1668:11863a10:bf3af795:0aa37b76
ARRAY /dev/md1 uuid=147ec32e:2721ff1a:3769d3d6:285e5546
ARRAY /dev/md2 uuid=0a3417f5:885e6352:c56063cf:7cc765e3

You may also need to edit the /etc/genkernel.conf file.

nano /etc/genkernel.conf

And add the following if needed.


LVM="yes"
MDADM="yes"
MDADM_CONFIG="/etc/mdadm.conf"

You still need to run the following. Pay close attention to the output to make sure it is picking up and using the /etc/mdadm.conf file.

genkernel --lvm --mdadm initramfs
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

Hopefully that worked! If you get strange output from watch cat /proc/mdstat, make sure you give it long enough time to sync.

Resources

Required Kernel Options

General Kernel Options

Enable GPT support.

-*- Enable the block layer  --->
      Partition Types  --->
      [*]   EFI GUID Partition support
      [*]   Windows Logical Disk Manager (Dynamic Disk) support

I also select dynamic disks just in case I need to use disks that were partitioned using XP, Vista, etc.

Processor type and features  --->
   [*] Symmetric multi-processing support
   [*] Machine Check / overheating reporting 
   [*]   Intel MCE Features
   [*]   AMD MCE Features
  Processor family (Generic-x86-64)  --->
    ( ) Opteron/Athlon64/Hammer/K8
    ( ) Intel P4 / older Netburst based Xeon
    (X) Core 2/newer Xeon
    ( ) Intel Atom
    ( ) Generic-x86-64
Executable file formats / Emulations  --->
    [*] IA32 Emulation
Device Drivers --->
  Generic Driver Options --->
    [*] Maintain a devtmpfs filesystem to mount at /dev
    [ ]   Automount devtmpfs at /dev, after the kernel mounted the rootfs
File systems --->
  <*> Second extended fs support
  [*]   Ext2 extended attributes 
  [*]     Ext2 POSIX Access Control Lists
  [*]     Ext2 Security Labels
  [ ]   Ext2 execute in place support (NEW)
  <*> Ext3 journalling file system support
  [*]   Default to 'data=ordered' in ext3 (NEW)
  [*]   Ext3 extended attributes (NEW)
  [*]     Ext3 POSIX Access Control List
  [*]     Ext3 Security Labels
  <*> The Extended 4 (ext4) filesystem
  [*]   Ext4 POSIX Access Control Lists
  [*]   Ext4 Security Labels
  [ ]   EXT4 debugging support (NEW)
  [ ] JBD (ext3) debugging support (NEW)
  [ ] JBD2 (ext4) debugging support (NEW)
  < > Reiserfs support (NEW)
  < > JFS filesystem support (NEW)
  < > XFS filesystem support (NEW)
  < > GFS2 file system support (NEW)
  < > Btrfs filesystem support (NEW)
  < > NILFS2 file system support (NEW)
  [*] Dnotify support (NEW)
  [*] Inotify support for userspace (NEW)
  [*] Filesystem wide access notification
  [ ]   fanotify permissions checking (NEW)
  [*] Quota support
  [*] Report quota messages through netlink interface
  [ ] Print quota warnings to console (OBSOLETE)
  [ ] Additional quota sanity checks (NEW)
  < > Old quota format support (NEW)
  <*> Quota format vfsv0 and vfsv1 support
  <*> Kernel automounter version 4 support (also supports v3)
  <*> FUSE (Filesystem in Userspace) support
  <*>   Character device in Userspace support
      Caches  --->
      CD-ROM/DVD Filesystems  --->
        <*> ISO 9660 CDROM file system support
        [*]   Microsoft Joliet CDROM extensions
        [*]   Transparent decompression extension
        <*> UDF file system support (NEW)
      DOS/FAT/NT Filesystems  --->
        <*> MSDOS fs support
        <*> VFAT (Windows-95) fs support
        (437) Default codepage for FAT (NEW)
        (iso8859-1) Default iocharset for FAT (NEW)
        <*> NTFS file system support
        [ ]   NTFS debugging support (NEW)
        [*]   NTFS write support
      Pseudo filesystems  --->
        -*- /proc file system support
        [*]    /proc/kcore support
        [*]    /proc/vmcore support
        -*- Tmpfs virtual memory file system support (former shm fs)
        [*]    Tmpfs POSIX Access Control Lists
        -*-    Tmpfs extended attributes
        [*] HugeTLB file system support
        <*> Userspace-driven configuration filesystem
  [*] Miscellaneous filesystems (NEW)  --->
  [*] Network File Systems (NEW)  --->
  -*- Native language support  --->

USB support.

Device Drivers --->
  [*] USB support  --->
    <*>   Support for Host-side USB
    [*]   USB verbose debug messages
    [*]   USB announce new devices
Device Drivers --->
  <*> Multimedia support  --->

For RAID and LVM2 support.

http://www.gentoo.org/doc/en/gentoo-x86+raid+lvm2-quickinstall.xml

https://wiki.gentoo.org/wiki/LVM

Device Drivers  --->
   [*] Multiple devices driver support (RAID and LVM)  --->
       <*>   RAID support
       [*]     Autodetect RAID arrays during kernel boot (NEW)
       <*>     Linear (append) mode
       <*>     RAID-0 (striping) mode
       <*>     RAID-1 (mirroring) mode
       <*>     RAID-10 (mirrored striping) mode
       <*>     RAID-4/RAID-5/RAID-6 mode
       < >     Multipath I/O support (NEW)
       < >     Faulty test module for MD (NEW)
       <*>   Block device as cache
       [ ]     Bcache debugging (NEW)
       [ ]     Extended runtime checks (NEW)
       [ ]     Debug closures (NEW)
       <*>   Device mapper support
       [ ]     Device mapper debugging support (NEW)
       <*>     Crypt target support
       <*>     Snapshot target
       < >     Thin provisioning target (NEW)
       <*>     Cache target (EXPERIMENTAL)
       <*>       MQ Cache Policy (EXPERIMENTAL) (NEW)
       <*>       Cleaner Cache Policy (EXPERIMENTAL) (NEW)
       <*>     Mirror target
       < >     RAID 1/4/5/6/10 target (NEW)
       < >   Mirror userspace logging (NEW)
       <*>   Zero target
       <*>   Multipath target
       <*>     I/O Path Selector based on the number of in-flight I/Os
       <*>     I/O Path Selector based on the service time
       < >   I/O delaying target (NEW)
       [*]   DM uevents
       < >   Flakey target (NEW)
       < >   Verity target support (NEW)
Device Drivers  --->
  [*] Network device support --->
      [*] Ethernet driver support --->
         <*>   Realtek 8169 gigabit Ethernet support

Required by X

With the Nouveau Driver in Mind

Device Drivers  --->
    Input device support --->
        <*> Event interface
Device Drivers  --->
    <*> Connector - unified userspace <-> kernelspace linker  --->
    Graphics support  --->
        <*>   Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
        <*>   Nouveau (nVidia) cards
        (5)      Maximum debug level (NEW)
        (3)      Default debug level (NEW)
        [*]      Support for backlight control (NEW)
        -*- Support for frame buffer devices  --->
            ## Disable all drivers, including NVidia, etc.
            [ ]   Enable firmware EDID
            [ ]   Enable Video Mode Handling Helpers
            [ ]   Enable Tile Blitting Support
            < >   VESA VGA graphics support
            [ ]   EFI-based Framebuffer Support
            Console display driver support --->
            -*- Framebuffer Console support

With the NVidia Driver in Mind

Loadable module support --->
    [*] Enable loadable module support
Processor type and features  --->
    -*- MTRR (Memory Type Range Register) support
    [*]    MTRR cleanup support
    (1)       MTRR cleanup enable value (0-1) (NEW)
    (1)       MTRR cleanup spare reg num (0-7) (NEW)
Device Drivers --->
    Graphics Support --->
        -*- /dev/agpgart (AGP Support) --->

Additional Kernel Options

Device Drivers  --->
    [*] Network device support --->
         <*>  Bonding driver support
[*] Virtualization --->
    <*>   Kernel-based Virtual Machine (KVM) support
    <*>   Host kernel accelerator for virtio net (EXPERIMENTAL)
Device Drivers  --->
   <*> Multimedia support --->

Resources

MTRR Linux Kernel
http://coopertronix.com/index.php/gnetoo-linux/gentoo-linux/mtrr-kernel

Gentoo Discussion Forums
https://forums.gentoo.org/viewtopic-t-911866-start-0.html

Recompile the Gentoo Linux Kernel

Here I needed to add a few features to my current Kernel.

The first thing I did was take a backup of both the Kernel image, the initramfs image, and the make configuration file (/usr/src/Linux/.config). Then, if everything spectacularly fails, I just need to boot into the live CD and restore the files.

Backup Existing Boot Images

It’s probably wise to backup your .config file if nothing else. I mount an NFS share and then copy the images there.

Make your Changes

While still in the /usr/src/linux directory, type make menuconfig.

storm linux # make menuconfig

I made the following changes.

    General setup  --->
[*] Enable loadable module support  --->
-*- Enable the block layer  --->
    Processor type and features  --->
    Power management and ACPI options  --->
    Bus options (PCI etc.)  --->
    Executable file formats / Emulations  --->
-*- Networking support  --->
    Device Drivers  --->
    Firmware Drivers  --->
    File systems  --->
    Kernel hacking  --->
    Security options  --->
-*- Cryptographic API  --->
[*] Virtualization  --->
    Library routines  --->
---
    Load an Alternate Configuration File
    Save an Alternate Configuration File

I added better support for my i7 processor.

Processor type and features  --->
    Processor family (Generic-x86-64)  --->
        (X) Core 2/newer Xeon 
    [*] MTRR (Memory Type Range Register) support

Then I made the following changes. Note, I had to remove everything under Support for framebuffer devices.

Device Drivers  --->
    [*] Network device support --->
         Bonding driver support
    <*> Connector - unified userspace <-> kernelspace linker  --->
    Graphics support  --->
        <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
        -*- Support for frame buffer devices  --->
            [ ]   Enable firmware EDID
            < >   VESA VGA graphics support
            < >   EFI-based Framebuffer Support
    Input device support --->
        <*> Event interface

Exit and save.

Maybe backup the new .config file too.

Compile the Kernel

If needed, run the below commands to generate dependency information and remove old binaries.

Make sure you’re still within the /usr/src/linux/ directory.

make dep; make clean

And then compile the kernel.

make && make modules_install

Once finished, copy the compiled image to the /boot directory. Don’t forget to mount it first if needed.

mount /boot
cp -v arch/x86_64/boot/bzImage /boot/kernel-3.8.13-gentoo

Rebuilt initramfs Image and Grub Configuration

genkernel --lvm --mdadm initramfs
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

Resources

Gentoo.org – 7. Configuring the Kernel
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7

Gentoo.org – Compiling the Linux kernel
http://www.gentoo.org/doc/en/articles/linux-kernel-compiling.xml

Gentoo.org – Baselayout and OpenRC Migration Guide
http://www.gentoo.org/doc/en/openrc-migration.xml

Gentoo: Upgrade the Linux Kernel

I have not updated my kernel for a while. As you can see, I will be updating from version 3.8.13-gentoo to version 3.10.7-gentoo-r1.

storm ~ # ls -la /usr/src
total 20
drwxr-xr-x  5 root root 4096 Oct  1 22:32 .
drwxr-xr-x 14 root root 4096 Aug 19 03:40 ..
-rw-r--r--  1 root root    0 Aug  1 04:16 .keep
lrwxrwxrwx  1 root root   19 Aug  6 05:40 linux -> linux-3.8.13-gentoo
drwxr-xr-x 24 root root 4096 Aug 22 22:22 linux-3.10.7-gentoo
drwxr-xr-x 24 root root 4096 Oct  1 22:33 linux-3.10.7-gentoo-r1
drwxr-xr-x 24 root root 4096 Aug 31 22:21 linux-3.8.13-gentoo
storm ~ # 

As I am skipping a couple of kernels, I will not attempt to use the old .config file with the new kernel.

Update the Kernel Symbolic Link

You can update the symbolic link a number of ways, see the official documentation for more information.

Using eselect

I prefer to use eselect as its quicker and easier. If you don’t already have it you will need to install it first.

emerge eselect

Once installed, list the available kernels with.

storm ~ # eselect kernel list
Available kernel symlink targets:
  [1]   linux-3.8.13-gentoo *
  [2]   linux-3.10.7-gentoo
  [3]   linux-3.10.7-gentoo-r1
storm ~ # 

Select the new kernel.

eselect kernel set 3

Then check with either.

storm ~ # eselect kernel list
Available kernel symlink targets:
  [1]   linux-3.8.13-gentoo
  [2]   linux-3.10.7-gentoo
  [3]   linux-3.10.7-gentoo-r1 *
storm ~ # 

Or.

storm ~ # ls -la /usr/src/linux
lrwxrwxrwx 1 root root 22 Oct 11 15:24 /usr/src/linux -> linux-3.10.7-gentoo-r1

Manually Update Symbolic Link

You can also just do it manually with.

cd /usr/src
ln -sfn linux-3.10.7-gentoo-r1 linux

The s option is to create the soft link, the f to force, and the n to treat link no differently than a normal directory.

Configure the New Kernel

Run menuconfig and make the relevant selection.

cd /usr/src/linux
make menuconfig

Link to required kernel options page

Compile and Install the New Kernel

cd /usr/src/linux
make && make modules_install
mount /boot
cp -v arch/x86_64/boot/bzImage /boot/kernel-3.10.7-gentoo-r1

Rebuilt initramfs Image and Grub Configuration

mount /boot
genkernel --lvm --mdadm initramfs
grub2-mkconfig -o /boot/grub/grub.cfg
reboot

And cross your fingers!

Resources

Gentoo.org: Gentoo Linux Kernel Upgrade Guide
http://www.gentoo.org/doc/en/kernel-upgrade.xml

Wiki.gentoo.org: Kernel/Upgrade
http://wiki.gentoo.org/wiki/Kernel/Upgrade

Negativesum.net: Gentoo Kernel Upgrade Guide
http://negativesum.net/tech/linux/gentoo/kernel