Pages

Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts

Friday, September 22, 2017

Fedora 26 + Virtualbox 5.1 + kenel 4.12

Upgrading your virtual machine (VM) environment can sometimes lead to unexpected issues. A common problem users might encounter after upgrading VirtualBox is the VM failing to start. In this post, we'll walk through a specific error and provide a step-by-step guide to resolve it, ensuring your virtual environment gets back up and running smoothly.

Understanding the Error

Upon attempting to start a VM after an upgrade, you might encounter an error in your logs similar to this:

/tmp/vbox.0/r0drv/linux/memuserkernel-r0drv-linux.o: warning: objtool: .fixup: unexpected end of section if [ "-pg" = "-pg" ]; then if [ /tmp/vbox.0/r0drv/linux/memuserkernel-r0drv-linux.o != "scripts/mod/empty.o" ]; then ./scripts/recordmcount "/tmp/vbox.0/r0drv/linux/memuserkernel-r0drv-linux.o"; fi; fi; make[1]: *** [Makefile:1519: _module_/tmp/vbox.0] Error 2 make: *** [Makefile:304: vboxdrv] Error 2

This error typically indicates a problem with the VirtualBox kernel modules not compiling or loading correctly due to incompatibilities or issues within the system.

Step-by-Step Solution

Fear not, as this issue can often be resolved by applying a patch to the VirtualBox source. Here's how you can fix it:

1. Change to the VirtualBox Source Directory:

Navigate to the directory where VirtualBox sources are stored:

cd /usr/share/virtualbox/src

2. Obtain the Necessary Patch:

Download the patch designed to fix the issue:

sudo wget http://paste.siduction.org/20170629003423

3. Apply the Patch:

Apply the downloaded patch to the VirtualBox source:

sudo patch -Np0 < 20170629003423

4. Reconfigure VirtualBox:

After applying the patch, you need to reconfigure VirtualBox to make sure it recognizes the changes:

/sbin/vboxconfig

Post-Solution Tips:

Have Fun! Now that you've resolved the issue, your VMs should start as expected. Dive back into your virtual environment and continue your work or play.

Stay Updated: Keep your system and VirtualBox updated to avoid similar issues in the future. Developers regularly release patches and updates to address known bugs and compatibility issues.

Seek Community Help: If you encounter further issues or the problem persists, don't hesitate to seek help from the VirtualBox community forums or check out other user experiences for additional insights.

Conclusion

Encountering errors after a system or software upgrade can be frustrating, but with the right approach and resources, most issues can be resolved. By understanding the error, carefully following the provided steps, and engaging with the community, you can overcome challenges and enjoy a seamless virtualization experience with VirtualBox. Keep exploring, learning, and sharing your knowledge with others!

Monday, July 25, 2016

Import OVA to Amazon Aws

VM Import/Export enables you to easily import virtual machine images from your existing environment to Amazon EC2 instances and export them back to your on-premises environment. This offering allows you to leverage your existing investments in the virtual machines that you have built to meet your IT security, configuration management, and compliance requirements by bringing those virtual machines into Amazon EC2 as ready-to-use instances. You can also export imported instances back to your on-premises virtualization infrastructure, allowing you to deploy workloads across your IT infrastructure.


Step 1.  : installing the Aws CLI

Step 2. We can get the Access Key ID and Secret Key from Aws IAM service under the specific User.
aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]: us-west-2
Default output format [None]: ENTER

Step 3
Now create two files: trust-policy.json & role-policy.json, in the second file you’ll need to replace “$bucketname” with your bucket name.

trust-policy.json:
===============
{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Sid":"",
         "Effect":"Allow",
         "Principal":{
            "Service":"vmie.amazonaws.com"
         },
         "Action":"sts:AssumeRole",
         "Condition":{
            "StringEquals":{
               "sts:ExternalId":"vmimport"
            }
         }
      }
   ]
}
===============

role-policy.json:
=================
{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListBucket",
            "s3:GetBucketLocation"
         ],
         "Resource":[
            "arn:aws:s3:::$bucketname"
         ]
      },
      {
         "Effect":"Allow",
         "Action":[
            "s3:GetObject"
         ],
         "Resource":[
            "arn:aws:s3:::$bucketname/*"
         ]
      },
      {
         "Effect":"Allow",
         "Action":[
            "ec2:ModifySnapshotAttribute",
            "ec2:CopySnapshot",
            "ec2:RegisterImage",
            "ec2:Describe*"
         ],
         "Resource":"*"
      }
   ]
}
===================

Now, use the aws cli tools to apply the policies:
$ aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
$ aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json

Step 4 : Check VM prerequisite before exporting as OVA
========================
In regard of VM, before exporting it from Vsphere and importing to AWS cloud, please make sure that all prerequisites for Import have been fullfiled.
Compare your VM with this checklist:
-all unnecessary services are disabled,
-no unnecessary applications are placed in Windows Startup,
-there are no pending reboots (reboot flag set by Windows Update or by any other software),
-VM volumes are defragmented and the size of each disk is resized to necessary (bigger disk=longer conversion time),
-you use single network interface setup to use DHCP (this should be done prior to import),
-no ISO is attached to this VM,
-make sure that Microsoft .NET Framework 3.5 Service Pack 1 or later are installed (required to support Ec2Config),
-your VM's root volume use MBR partition table,
-your anti-virus and anti-spyware software and firewalls are disabled,
-only one partition is bootable,
-rdp access is enabled,
-the administrator account and all other user accounts use secure passwords. All accounts must have passwords or the importation might fail.
-Uninstall the VMware Tools from your VMware VM,
-the language of your OS is EN-US,
-these hotfixes are installed (according to OS version):
Install Latest Ec2Config
https://aws.amazon.com/developertools/5562082477397515
=================

Step 5 : Uploading the OVA to S3 and Creating the AMI
You can upload your VMs in OVA format to your Amazon S3 bucket using the upload tool of your choice. After you upload your VM to Amazon S3, you can use the AWS CLI to import your OVA image. These tools accept either a URL (public Amazon S3 file, a signed GET URL for private Amazon S3 files) or the Amazon S3 bucket and path to the disk file.

Use aws ec2 import-image to create a new import image task.
The syntax of the command is as follows:

$ aws ec2 import-image --description "Windows 2008 OVA" --disk-containers file://containers.json
The file containers.json is a JSON document that contains information about the image. The S3Key is the name of the image file you want to upload to the S3Bucket.

[{
    "Description": "First CLI task",
    "Format": "ova",
    "UserBucket": {
        "S3Bucket": "my-import-bucket",
        "S3Key": "my-windows-2008-vm.ova"
    }
}]

Step 6 : Checking the Status


Use the “aws ec2 describe-import-image-tasks” command to return the status of the task. The syntax of the command is as follows:

Regarding the License licensing, within the  api-call "aws ec2 import-image" we can define a "--license-type" value.
Based on this option your VM will use your license (BYOL) or will activate itself in AWS KMS[4]. Option should be set to "AWS" or "BYOL".

Tuesday, February 3, 2015

Configuring http proxy in the linux Server


Open the .bash_profile file for editing.

(example: vi ~/.bash_profile)
Add the following lines to the end of the file:
http_proxy=http://proxy_server_address:port
export no_proxy=localhost,127.0.0.1,192.168.0.34
export http_proxy
http_proxy should be the ip address or hostname, plus the port of your proxy server
no_proxy should be any exclusions you want to make – addresses that you don’t want to send via the proxy.
NOTE: This must be done for each individual user, including root.
If you don’t want to log out of your shell session, you can reload the bash profile with the following:
source .bash_profile

Configuring YUM to use proxy
To configure “yum” to use the HTTP / HTTPS proxy you will need to edit the /etc/yum.conf configuration file. Open /etc/yum.conf in your favorite editor and add the following line.
proxy=http://proxy_server_address:port

Save and close the file, then clear the cache used by yum with the following command:
yum clean all

Friday, October 24, 2014

Removing Blank Lines from the File.

In sed 
Type the following sed command to delete all empty files:

Display with out Blank Lines
sed '/^$/d' input.txt

Remove all the Blank Lines from file
sed -i '/^$/d' input.txt
cat input.txt

In awk 

Type the following awk command to delete all empty files:

Display with out Blank Lines
awk NF input.txt

Remove all the Blank Lines from file
awk 'NF  input.txt > output.txt
cat output.txt


In perl
Type the following perl one liner to delete all empty files and save orignal file as input.txt.backup:
Remove all the Blank Lines from file
perl -i.backup -n -e "print if /\S/" input.txt


In vi editor
:g/^$/d
:g will execute a command on lines which match a regex. The regex is 'blank line' and the command is
:d (delete)


In tr
tr -s '\n' < abc.txt

In grep
grep -v "^$" abc.txt



Wednesday, October 8, 2014

Resuming Download in Linux

wget -c Resume Unfinished Downloads

This small command can save your time and money while downloading big files so I found it useful to share with you .I was downloading a file with wget command and it was 98% downloaded and my computer turned off unexpectedly. It was a very huge file and downloading it from the beginning was a painful job. So I came  across a wget command that can be used for resuming unfinished downloads.

I found this command after reading wget manual, you can add wget -c or wget --continue to resume unfinished download.

wget -c url

Monday, September 1, 2014

Download files through Command Prompt in Windows

HTTP
PowerShell

$source = "http://yoursite.com/file.xml"
$destination = "c:\application\data\newdata.xml"
Invoke-WebRequest $source -OutFile $destination

The Invoke-WebRequest cmdlet
Invoke-WebRequest is a cmdlet that lets you upload or download data from a remote server. This cmdlet allows for user agents, proxies, and credentials.

FTP
PowerShell

$source = "ftp://yoursite.com/file.xml"
$destination = "c:\application\data\newdata.xml"

Invoke-WebRequest $source -OutFile $destination -Credential ftpUser

The code example above is almost identical to the HTTP sample, with the main difference being that the $source variable has “ftp” at the beginning instead of “http”. You may also notice that we have used the -Credential parameter since FTP connections generally require a username and password.

Wednesday, May 21, 2014

Installing Amazon Command Line using PIP

Installing the repo needed for pip

cd /tmp
wget http://mirror-fpt-telecom.fpt.net/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

Installing C-compiler for Pip

yum install gcc

Installing amazon cli

pip install awscli

Configure Amazon Cli

aws configrue

you need aws access key ,secret key, default region and output format.