Category Archives: CentOS

Install XenServer tools in your VM

Install XenServer tools

Next step is to install those tools. Also I’ll give you some tips.

For any VM, go in the console view on your VM, and insert the appropriate ISO:

  • xs-tools.iso for XenServer 6 and older
  • guest-tools.iso for XenServer 7 and high

Then, each system is a bit different.

For Linux VMs

Debian, Ubuntu (deb based)

For a Debian VM, it’s pretty simple, as root:

  • mount /dev/cdrom /mnt
  • bash /mnt/Linux/
  • umount /dev/cdrom

In a real example:

root@myVM:~# mount /dev/cdrom /mnt       
mount: block device /dev/xvdd is write-protected, mounting read-only
root@myVM:~# bash /mnt/Linux/ 
Detected `Debian GNU/Linux 7.9 (wheezy)' (debian version 7).

The following changes will be made to this Virtual Machine:
  * update arp_notify sysctl.
  * packages to be installed/upgraded:
    - xe-guest-utilities_7.0.0-24_all.deb

Continue? [y/n] Y

(Reading database ... 37679 files and directories currently installed.)
Preparing to replace xe-guest-utilities 6.2.0-1133 (using .../xe-guest-utilities_7.0.0-24_all.deb) ...
Stopping xe daemon:  OK
Unpacking replacement xe-guest-utilities ...
Setting up xe-guest-utilities (7.0.0-24) ...
Installing new version of config file /etc/init.d/xe-linux-distribution ...
$Detecting Linux distribution version: OK
$Starting xe daemon:  OK

You should now reboot this Virtual Machine.

That’s all! You can eject the ISO now.

As soon the .deb is installed, tools will report their info: no need to reboot!

CentOS, RHEL (rpm based)

Same principle, almost same procedure than on a Deb based distro:

# mount /dev/cdrom /mnt/
mount: block device /dev/xvdd is write-protected, mounting read-only
[root@localhost ~]# bash /mnt/Linux/ 
Detected `CentOS release 6.6 (Final)' (centos version 6).

The following changes will be made to this Virtual Machine:
  * update arp_notify sysctl.
  * packages to be installed/upgraded:
    - xe-guest-utilities-7.0.0-24.x86_64.rpm
    - xe-guest-utilities-xenstore-7.0.0-24.x86_64.rpm

Continue? [y/n] y

Preparing...                ########################################### [100%]
   1:xe-guest-utilities-xens########################################### [ 50%]
   2:xe-guest-utilities     ########################################### [100%]

You should now reboot this Virtual Machine.
[root@localhost ~]# 

Nope, rebooting is not mandatory.

Adding Additional Disk Drives to CentOS

Adding a new drive to CentOS or RedHat systems.

Making use of a second drive for extra space? Here’s a quick run-down:

1) Make sure you know which disk is being formatted. First, second, and third drives will be /dev/sda, /dev/sdb, and /dev/sdc respectively. Check this with fdisk -l

[03:50:04] [root@virt ~]# fdisk -l

Disk /dev/sda: 34.3 GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        4177    33447330   8e  Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

2) You can see that /dev/sdb (our second hard drive) does not have any partitions. We will need to create a partition(s) on the drive and then make a file system on it, then mount it. Let’s write partitions to the drive using fdisk /dev/sdb:

[03:53:01] [root@virt ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
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.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help):

3) As you can see from the help menu (by using the command “m”) we want to add a new partition. Using the defaults will use the entire disk. After it’s created, you will want to use the command “w” to “write table to disk and exit”.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-1044, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): 
Using default value 1044

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[03:54:58] [root@virt ~]#

4) Now you will notice that the output of fdisk -l /dev/sdb shows a partition as /dev/sdb1:

[03:57:08] [root@virt ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1044     8385898+  83  Linux

5) Now we need to create a file system on it. I’ve always used ext3 for general use/purposes. You’ll want to use the command mkfs -t ext3 /dev/sdb1 as shown here:

[03:58:38] [root@virt ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

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

6) Great, now we have a single partitioned secondary drive using ext3 file system. Now you want to create a directory to mount it in; lets just use “/drive2”. You’ll need to use the command mount -t [filesystem] [source] [mount directory] to mount it.

[03:59:50] [root@virt ~]# mount -t ext3 /dev/sdb1 /drive2/

7) Now you’ll notice, via df, that the drive is mounted:

[03:59:57] [root@virt ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       28G  1.4G   25G   6% /
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                1014M     0 1014M   0% /dev/shm
/dev/sdb1             7.9G  147M  7.4G   2% /drive2

8) Last step – you want to make sure the drive automatically mounts itself when the server boots/reboots. You’ll need to add the following line to your /etc/fstab file:

/dev/sdb1  /drive2  ext3  defaults 0 0


All done!



SolusVM Mass Starting/Stopping Virtual Servers

If you need to mass start your virtual servers, run the following code in SSH on the host:



CFGS=/home/xen/vm*/;for cfg in $CFGS;do xm create $cfg*.cfg;done


xm shutdown -aw



CFGS=`vzlist -S -Ho ctid`;for cfg in $CFGS;do vzctl start $cfg;done


CFGS=`vzlist -S -Ho ctid`;for cfg in $CFGS;do vzctl stop $cfg;done


CFGS=/home/kvm/kvm*/;for cfg in $CFGS;do virsh create $cfg*.xml;done

Using Screen

Screen is like a window manager for your console. It will allow you to keep multiple terminal sessions running and easily switch between them. It also protects you from disconnection, because the screen session doesn’t end when you get disconnected.

You’ll need to make sure that screen is installed on the server you are connecting to. If that server is Ubuntu or Debian, just use this command:

sudo apt-get install screen

Now you can start a new screen session by just typing screen at the command line. You’ll be shown some information about screen. Hit enter, and you’ll be at a normal prompt.

To disconnect (but leave the session running)

Hit Ctrl + A and then Ctrl + D in immediate succession. You will see the message [detached]

To reconnect to an already running session

screen -r

To reconnect to an existing session, or create a new one if none exists

screen -D -r

To create a new window inside of a running screen session

Hit Ctrl + A and then C in immediate succession. You will see a new prompt.

To switch from one screen window to another

Hit Ctrl + A and then Ctrl + A in immediate succession.

To list open screen windows

Hit Ctrl + A and then W in immediate succession

There’s lots of other commands, but those are the ones I use the most.



Command Line Ping Sweep

Sometimes it can be handy to ‘see’ what is around you on a network, for instance when you’re using DHCP on a network and you want to find which addresses are already taken. Or you want to see whether specific machines are up and running… Of course there are various tools you can install or use, but there are times that you just can’t reach for the right tool(s)… You don’t want to do a ping sweep for nothing.
Of course there is a way of ping sweeping from the command line By simply using the ‘FOR’, ‘PIPE’ and ‘GREP’ commands in a clever way.

for i in {1..254}; do ping -c 1 -W 1 192.168.1.$i | grep ‘from’; done

Naturally you can stop the ping sweep by entering Ctrl+z

Installing Maldet on CentOS

Maldet is an excellent way to help keep your server secure including if you have a control panel installed such as WHM, cPanel, or DirectAdmin. Maldet is designed to scan your files in the /home/ directory (or any directory of your choosing) and comparing the contents with signatures of common malware that usually finds it’s way into the server via poorly written programs (i.e. WordPress). Although it cannot give you 100% protection, it will help in the long run and is an important tool to have. As always, we recommend a ful server lockdown and not to rely on one such program or procedure to help keep your server as secure as possible. Security is an ever evolving subject and thus, you must use every tool at your disposal, for those without the time to devote to security.

With the following commands, you can install maldet effortlessly and stop worrying about the security of your server! Maldet will be setup to auto update and scan the files, just copy and paste this command into the terminal via SSH:

cd /usr/local/src/
tar -xzf maldetect-current.tar.gz

cd maldetect-*
sh ./
maldet –update-ver
maldet –update

Network Unavailable with CentOS 7 or Fedora 20

There is a bug in SolusVM that the network settings for CentOS 7 and Fedora 20 do not get provisioned properly when you initially order your VPS. This is due to the change in the way these operating systems use their network config files. Even though there is nothing we can do to fix this automated error, fortunately, you can fix the problem yourself with ease!

First, login to your virtual machine as root using VNC through your SolusVM control panel (since networking is not working, this is the only way).

Next, change your working directory to /etc/sysconfig/network-scripts/, you may do this by running the following command:

cd /etc/sysconfig/network-scripts

Next, you will need to rename your ifcfg-eth0 file to the new format used by CentOS 7 or Fedora 20 to the new one, ifcfg-ens3. That command for this change is as follows:

mv ifcfg-eth0 ifcfg-ens3

Next, you will need to edit the file and replace any occurrence of eth0 with ens3. You may do this with the following command:

sed -i — ‘s/ifcfg-eth0/ifcfg-ens3/g’ ifcfg-ens3

Alternatively: You can edit the file using vim and replace the ifcfg-eth0 occurrence by hand.

We also need to add the DNS servers. Do to this, edit the file /etc/sysconfig/network-scripts/ifcfg-ens3 and enter the following:


You also need to edit your resolv.conf file located at /etc/resolv.conf and add the following:


These addresses are the Google DNS resolvers so they are extremely fast no matter where you are in the world due to anycasting.

Next, restart networking with:

service network restart

You should now have Internet access! If you have any questions or problems regarding this fix, please feel free to contact the support department as the difficulty of this change may be difficult for beginners. We hope SolusVM has a fix for this soon!

CentOS 7 error: unpacking of archive failed on file /usr/lib/udev/rules.d/60-net.rules: cpio: rename

If you have ever done a yum update only to discover initscripts wouldn’t install or update, chances are you were scratching your head as to why. We have noticed this is a common problem on our CentOS 7 templates but is very easy to fix. An example of the error message you most likely received as a result of the protection attribute being enabled is as follows:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
initscripts-9.49.30-1.el7.x86_64.rpm | 429 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : initscripts-9.49.30-1.el7.x86_64 1/2
Error unpacking rpm package initscripts-9.49.30-1.el7.x86_64
error: unpacking of archive failed on file /usr/lib/udev/rules.d/60-net.rules: cpio: rename
Verifying : initscripts-9.49.30-1.el7.x86_64 1/2
initscripts-9.49.24-1.el7.x86_64 was supposed to be removed but is not!
Verifying : initscripts-9.49.24-1.el7.x86_64 2/2

initscripts.x86_64 0:9.49.24-1.el7 initscripts.x86_64 0:9.49.30-1.el7



Luckily, the solution is quit simple, we just need to remove the protection attribute using chattr. Run the following as root to remove the attribute on 60-net.rules preventing us from updating initscripts:

chattr -i /usr/lib/udev/rules.d/60-net.rules

That’s it, try running yum update once more and the program will be updated without issue now.

Mount: special device /dev/xvdd does not exist When Installing XenServer Tools on Linux

According to the Citrix documentation, the command to mount the XenServer tools ISO image on a Linux OS is this:

mount /dev/xvdd /mnt

But this does not work on CentOS or Ubuntu virtual machines, because these use a different naming convention for CD-ROM devices.

Mount XenServer Tools in CentOS

sudo mount /dev/cdrom1 /mnt

Mount XenServer Tools in CentOS 7

sudo mount /dev/sr0 /mnt

Mount XenServer Tools in Ubuntu

sudo mount /dev/cdrom /mnt

Installing Zend Optimizer with IonCube Loader

Zend Optimizer and Ioncube, can safely be installed on an InterWorx server. Ref:

To install Zend Optimizer.

cd /usr/src/
tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

Now locate php.ini and extension directory. To locate php.ini, run following command:

php -i |grep php.ini

You will get a similar output.

Configuration File (php.ini) Path /etc/php-cgi.ini

Now locate extension_dir using following command:

grep extension_dir /etc/php-cgi.ini

Copy Zend extension to php extension dir using following command:

cp /usr/src/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ /usr/lib/php5/

Then add following line to /etc/php.d/ioncube.ini

zend_extension = /usr/lib/php5/

Then restart web server.

Please note that if you add above line to /etc/php-cgi.ini, you will get following error:

-bash-3.00# php -v
PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini file in Unknown on line 0

Hope this helps