Skip to content

Instantly share code, notes, and snippets.

@liweinan
Last active November 12, 2020 06:58
Show Gist options
  • Save liweinan/4527974 to your computer and use it in GitHub Desktop.
Save liweinan/4527974 to your computer and use it in GitHub Desktop.
[weli@virt-jboss-01 ~]$ sudo virsh list
 Id    Name                           State
----------------------------------------------------
 1     VM_weli                        running
 4     stliu                          running
 6     jimma                          running
 8     lgao                           running

[weli@virt-jboss-01 ~]$ sudo virsh console VM_weli
Connected to domain VM_weli
Escape character is ^]

You have mail in /var/spool/mail/root
[root@dhcp-66-78-87 ~]#

[weli@virt-jboss-01 images]$ ls -la
total 58729136
drwxrwxrwx.  4 root root        4096 Dec 19 14:35 .
drwxr-xr-x. 10 root root        4096 Oct 12 21:40 ..
drwxrwxrwx.  3 root root        4096 Sep 27 15:58 boot
-rw-r--r--.  1 qemu qemu 53687091200 Jan 14 13:34 jimma.raw
drwxrwxrwx.  2 root root       16384 Aug 15 17:34 lost+found
-rw-r--r--.  1 ema  ema  10737418240 Aug 16 13:51 rhel6u1.img
-rw-r--r--.  1 qemu qemu 42949672960 Jan 14 13:33 stliu.raw
-rw-r--r--.  1 qemu qemu 42949672960 Jan 14 13:34 VM_weli.raw

[weli@virt-jboss-01 images]$ sudo qemu-img create -f raw lgao.raw 40G
Formatting 'lgao.raw', fmt=raw size=42949672960
[weli@virt-jboss-01 images]$

[weli@virt-jboss-01 images]$ sudo virt-install -nlgao -r4096 --vcpus=2 \
--disk /var/lib/libvirt/images/lgao.raw -b br1 -l \
> http://download.englab.nay.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ \
> -x "console=tty0 console=ttyS0,115200" -d
Mon, 14 Jan 2013 13:45:56 DEBUG    Launched with command line:
/usr/bin/virt-install -nlgao -r4096 --vcpus=2 --disk /var/lib/libvirt/images/lgao.raw -b 
br1 -l http://download.englab.nay.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ 
-x console=tty0 console=ttyS0,115200 -d
Mon, 14 Jan 2013 13:45:56 DEBUG    Requesting libvirt URI default
Mon, 14 Jan 2013 13:45:56 DEBUG    Received libvirt URI qemu:///system
Mon, 14 Jan 2013 13:45:56 DEBUG    Requesting virt method 'default', hv type 'default'.
Mon, 14 Jan 2013 13:45:56 DEBUG    Received virt method 'hvm'
Mon, 14 Jan 2013 13:45:56 DEBUG    Hypervisor name is 'kvm'
Mon, 14 Jan 2013 13:45:57 DEBUG    DISPLAY is not set: defaulting to nographics.
...

Welcome to Red Hat Enterprise Linux for x86_64

					┌────────┤ Choose a Language ├────────┐
					│                                     │
					│ What language would you like to use │
					│ during the installation process?    │
					│                                     │
					│      Catalan                ↑       │
					│      Chinese(Simplified)    ▒       │
					│      Chinese(Traditional)   ▮       │
					│      Croatian               ▒       │
					│      Czech                  ▒       │
					│      Danish                 ▒       │
					│      Dutch                  ▒       │
					│      English                ↓       │
					│                                     │
					│               ┌────┐                │
					│               │ OK │                │
					│               └────┘                │
					│                                     │
					│                                     │
					└─────────────────────────────────────┘

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

Welcome to Red Hat Enterprise Linux for x86_64


				┌─────────────┤ Configure TCP/IP ├─────────────┐
				│                                              │
				│ [*] Enable IPv4 support                      │
				│        (*) Dynamic IP configuration (DHCP)   │
				│        ( ) Manual configuration              │
				│                                              │
				│ [*] Enable IPv6 support                      │
				│        (*) Automatic neighbor discovery      │
				│        ( ) Dynamic IP configuration (DHCPv6) │
				│        ( ) Manual configuration              │
				│                                              │
				│        ┌────┐               ┌──────┐         │
				│        │ OK │               │ Back │         │
				│        └────┘               └──────┘         │
				│                                              │
				│                                              │
				└──────────────────────────────────────────────┘



  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

For IP settings, I leave it as default.


			  ┌──────────┤ Would you like to use VNC? ├──────────┐
			  │                                                  │
			  │ Text mode provides a limited set of installation │
			  │ options.  It does not allow you to specify your  │
			  │ own partitioning layout or package selections.   │
			  │ Would you like to use VNC mode instead?          │
			  │                                                  │
			  │     ┌───────────┐         ┌───────────────┐      │
			  │     │ Start VNC │         │ Use text mode │      │
			  │     └───────────┘         └───────────────┘      │
			  │                                                  │
			  │                                                  │
			  └──────────────────────────────────────────────────┘





  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

Use text mode is okay


Welcome to Red Hat Enterprise Linux for x86_64





			   ┌─────────┤ Red Hat Enterprise Linux ├──────────┐
			   │                                               │
			   │ Welcome to Red Hat Enterprise Linux!          │
			   │                                               │
			   │                                               │
			   │                    ┌────┐                     │
			   │                    │ OK │                     │
			   │                    └────┘                     │
			   │                                               │
			   │                                               │
			   └───────────────────────────────────────────────┘






  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

Press OK


Welcome to Red Hat Enterprise Linux for x86_64
 ┌────────────────────────────────┤ Warning ├─────────────────────────────────┐
 │                                                                            │
 │         Error processing drive:                                 ↑          │
 │                                                                 ▮          │
 │         pci-0000:00:04.0-virtio-pci-virtio1                     ▒          │
 │         40960MB                                                 ▒          │
 │         Virtio Block Device                                     ▒          │
 │                                                                 ▒          │
 │         This device may need to be reinitialized.               ▒          │
 │                                                                 ▒          │
 │         REINITIALIZING WILL CAUSE ALL DATA TO BE LOST!          ▒          │
 │                                                                 ▒          │
 │         This action may also be applied to all other disks      ▒          │
 │         needing reinitialization.                               ↓          │
 │                                                                            │
 │  ┌────────┐   ┌────────────┐   ┌───────────────┐   ┌───────────────────┐   │
 │  │ Ignore │   │ Ignore all │   │ Re-initialize │   │ Re-initialize all │   │
 │  └────────┘   └────────────┘   └───────────────┘   └───────────────────┘   │
 │                                                                            │
 │                                                                            │
 └────────────────────────────────────────────────────────────────────────────┘

  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

Choose Re-initialize all


Welcome to Red Hat Enterprise Linux for x86_64

                ┌───────┤ Time Zone Selection ├───────┐
                │                                     │
                │ In which time zone are you located? │
                │                                     │
                │ [*] System clock uses UTC           │
                │                                     │
                │  America/Montevideo              ↑  │
                │  America/Montreal                ▮  │
                │  America/Montserrat              ▒  │
                │  America/Nassau                  ▒  │
                │  America/New York                ↓  │
                │                                     │
                │      ┌────┐          ┌──────┐       │
                │      │ OK │          │ Back │       │
                │      └────┘          └──────┘       │
                │                                     │
                │                                     │
                └─────────────────────────────────────┘

/ between elements | selects | next screen

^^^ Choose your TZ and press OK


Welcome to Red Hat Enterprise Linux for x86_64



				┌──────────────┤ Root Password ├───────────────┐
				│                                              │
				│    Pick a root password. You must type it    │
				│    twice to ensure you know it and do not    │
				│    make a typing mistake.                    │
				│                                              │
				│ Password:           ******__________________ │
				│ Password (confirm): ******__________________ │
				│                                              │
				│        ┌────┐               ┌──────┐         │
				│        │ OK │               │ Back │         │
				│        └────┘               └──────┘         │
				│                                              │
				│                                              │
				└──────────────────────────────────────────────┘




  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

Input password and press OK


Welcome to Red Hat Enterprise Linux for x86_64

	   ┌─────────────────────┤ Partitioning Type ├─────────────────────┐
	   │                                                               │
	   │ Installation requires partitioning of your hard drive.  The   │
	   │ default layout is suitable for most users.  Select what space │
	   │ to use and which drives to use as the install target.         │
	   │                                                               │
	   │                 Use entire drive                              │
	   │                 Replace existing Linux system                 │
	   │                 Use free space                                │
	   │                                                               │
	   │   Which drive(s) do you want to use for this installation?    │
	   │        [*]    vda    40960 MB (Virtio Block Device) ↑         │
	   │                                                     ▮         │
	   │                                                               │
	   │                      ┌────┐   ┌──────┐                        │
	   │                      │ OK │   │ Back │                        │
	   │                      └────┘   └──────┘                        │
	   │                                                               │
	   │                                                               │
	   └───────────────────────────────────────────────────────────────┘

<Space>,<+>,<-> selection   |   <F2> Add drive   |   <F12> next screen

Chosse 'Use entire drive' and press OK.


Welcome to Red Hat Enterprise Linux for x86_64





	 ┌─────────────┤ Writing storage configuration to disk ├──────────────┐
	 │                                                                    │
	 │ The partitioning options you have selected will now be written to  │
	 │ disk.  Any data on deleted or reformatted partitions will be lost. │
	 │                                                                    │
	 │        ┌─────────┐               ┌───────────────────────┐         │
	 │        │ Go back │               │ Write changes to disk │         │
	 │        └─────────┘               └───────────────────────┘         │
	 │                                                                    │
	 │                                                                    │
	 └────────────────────────────────────────────────────────────────────┘






  <Tab>/<Alt-Tab> between elements   |  <Space> selects   |  <F12> next screen

Write changes to disk


Wait a while and the packages are downloaded and installed.


Welcome to Red Hat Enterprise Linux for x86_64



	 ┌───────────────────────────┤ Complete ├────────────────────────────┐
	 │                                                                   │
	 │ Congratulations, your Red Hat Enterprise Linux installation is    │
	 │ complete.                                                         │
	 │                                                                   │
	 │ Please reboot to use the installed system.  Note that updates may │
	 │ be available to ensure the proper functioning of your system and  │
	 │ installation of these updates is recommended after the reboot.    │
	 │                                                                   │
	 │                            ┌────────┐                             │
	 │                            │ Reboot │                             │
	 │                            └────────┘                             │
	 │                                                                   │
	 │                                                                   │
	 └───────────────────────────────────────────────────────────────────┘




								<Enter> to exit

Click Reboot


Red Hat Enterprise Linux Server release 6.3 (Santiago)
Kernel 2.6.32-279.el6.x86_64 on an x86_64

dhcp-66-78-40.eng.nay.redhat.com login:

After reboot you will see login screen, enter 'root' and its password to login.


[root@dhcp-66-78-40 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:A8:D8:01
		  inet addr:XX.XX.XX.XX  Bcast:XX.XX.XX.XX  Mask:255.255.254.0

Check your IP address above.


The server just have a minimal set of softwares install, and we need to install openssh for it to accept ssh login. As we've installed RHEL6 on it, we need to register it to RHN or satelite server.

Run 'rhn_register' :

Copyright © 2006--2010 Red Hat, Inc. All rights reserved.

  ┌───────────────────┤ Registering for software updates ├───────────────────┐
  │                                                                          │
  │ This assistant will guide you through connecting your system to Red    ↑ │
  │ Hat Network (RHN) to receive software updates, including security      ▮ │
  │ updates, to keep your system supported and compliant.  You will need   ▒ │
  │ the following at this time:                                            ▒ │
  │                                                                        ▒ │
  │  * A network connection                                                ▒ │
  │  * Your Red Hat Login & password                                       ▒ │
  │  * The location of a Red Hat Network Satellite or Proxy (optional)     ▒ │
  │                                                                        ▒ │
  │                                                                        ↓ │
  │                                                                          │
  │   ┌──────────────────────────────────┐      ┌──────┐      ┌────────┐     │
  │   │ Why Should I Connect to RHN? ... │      │ Next │      │ Cancel │     │
  │   └──────────────────────────────────┘      └──────┘      └────────┘     │
  │                                                                          │
  │                                                                          │
  └──────────────────────────────────────────────────────────────────────────┘


  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Click 'Next'


Copyright © 2006--2010 Red Hat, Inc. All rights reserved.



   ┌───────────────────┤ Enter you account information ├────────────────────┐
   │                                                                        │
   │ Please enter your login information for Red Hat Network                │
   │ (http://rhn.redhat.com/):                                              │
   │                                                                        │
   │                  Red Hat Login: ____________________                   │
   │                       Password: ____________________                   │
   │ Tip: Forgot your login or password? Visit:                             │
   │ https://rhn.redhat.com/rhn/sales/LoginInfo.do                          │
   │                                                                        │
   │        ┌──────┐               ┌──────┐              ┌────────┐         │
   │        │ Next │               │ Back │              │ Cancel │         │
   │        └──────┘               └──────┘              └────────┘         │
   │                                                                        │
   │                                                                        │
   └────────────────────────────────────────────────────────────────────────┘



  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Login with your RHN account and press 'Next'

If you don't have a RHN account, as you are Red Hat employee, you can apply one according to this document: https://home.corp.redhat.com/comment/128


Copyright © 2006--2010 Red Hat, Inc. All rights reserved.

   ┌──────────────────┤ Select operating system release ├───────────────────┐
   │                                                                        │
   │ Operating System version:                                              │
   │                                                                        │
   │ ( ) Limited Updates Only                                               │
   │                                                                        │
   │  Minor Release:                                                        │
   │  RHEL EUS Server (v. 6.3.z for 64-bit x86_64)*                       ↑ │
   │                                                                      ▮ │
   │                                                                        │
   │  Tip: Minor releases with a '*' are currently supported by Red Hat.    │
   │                                                                        │
   │ (*) All available updates                                              │
   │                                                                        │
   │        ┌──────┐               ┌──────┐              ┌────────┐         │
   │        │ Next │               │ Back │              │ Cancel │         │
   │        └──────┘               └──────┘              └────────┘         │
   │                                                                        │
   │                                                                        │
   └────────────────────────────────────────────────────────────────────────┘

  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Choose 'All available updates' and press Next


┌──────────────────┤ Create your system profile - Hardware ├──────────────────┐
│                                                                             │
│ A Profile Name is a descriptive name that you choose to identify            │
│ this System Profile on the Red Hat Network web pages. Optionally,           │
│ include a computer serial or identification number.                         │
│ Profile name: dhcp-66-78-40.eng.nay.redhat.com________                      │
│                                                                             │
│ [*] Include the following information about hardware and network:           │
│ Press <space> to deselect the option.                                       │
│                                                                             │
│ Version: 6Server  CPU model: QEMU Virtual CPU version (cpu64-rhel6)         │
│ Hostname: dhcp-66-78-40.eng.nay.redhat.com                                  │
│ CPU speed: 1999 MHz  IP Address: 10.66.78.40  Memory: 3831 megabytes        │
│                                                                             │
│ Additional hardware information including PCI devices, disk sizes           │
│ and mount points will be included in the profile.                           │
│                                                                             │
│         ┌──────┐                ┌──────┐                ┌────────┐          │
│         │ Next │                │ Back │                │ Cancel │          │
│         └──────┘                └──────┘                └────────┘          │
│                                                                             │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Leave system profile as default and press 'Next'


Copyright © 2006--2010 Red Hat, Inc. All rights reserved.
   ┌───────────────┤ Create your system profile - Packages ├────────────────┐
   │                                                                        │
   │ RPM information is important to determine what updated software        │
   │ packages are relevant to this system.                                  │
   │                                                                        │
   │ [*] Include RPM packages installed on this system in my System Profile │
   │                                                                        │
   │ You may deselect individua l packages by unchecking them below.        │
   │          [*] MAKEDEV-3.24-6.el6                             ↑          │
   │          [*] PyXML-0.8.4-19.el6                             ▮          │
   │          [*] acl-2.2.49-6.el6                               ▒          │
   │          [*] aic94xx-firmware-30-2.el6                      ▒          │
   │          [*] atmel-firmware-1.3-7.el6                       ▒          │
   │          [*] attr-2.4.44-7.el6                              ↓          │
   │                                                                        │
   │        ┌──────┐               ┌──────┐              ┌────────┐         │
   │        │ Next │               │ Back │              │ Cancel │         │
   │        └──────┘               └──────┘              └────────┘         │
   │                                                                        │
   │                                                                        │
   └────────────────────────────────────────────────────────────────────────┘

  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Leave all as default and press 'Next'


Copyright © 2006--2010 Red Hat, Inc. All rights reserved.




  ┌─────────────┤ Send Profile Information to Red Hat Network ├─────────────┐
  │                                                                         │
  │ We are finished collecting information for the System Profile.          │
  │                                                                         │
  │ Press "Next" to send this System Profile to Red Hat Network.  Click     │
  │ "Cancel" and no information will be sent.  You can run the registration │
  │ program later by typing `rhn_register` at the command line.             │
  │                                                                         │
  │        ┌──────┐               ┌──────┐               ┌────────┐         │
  │        │ Next │               │ Back │               │ Cancel │         │
  │        └──────┘               └──────┘               └────────┘         │
  │                                                                         │
  │                                                                         │
  └─────────────────────────────────────────────────────────────────────────┘




  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Press 'Next'


Copyright © 2006--2010 Red Hat, Inc. All rights reserved.








				  ┌──┤ Sending Profile to Red Hat Network ├──┐
				  │                                          │
				  │                    50%                   │
				  │                                          │
				  └──────────────────────────────────────────┘









  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Wait for the register process to be finished, it needs a while.


Copyright © 2006--2010 Red Hat, Inc. All rights reserved.

  ┌──────────────────┤ Review system subscription details ├──────────────────┐
  │                                                                          │
  │                                                                          │
  │ Note: yum-rhn-plugin has been enabled.                                 ↑ │
  │                                                                        ▮ │
  │ Please review the subscription details below:                          ▒ │
  │                                                                        ▒ │
  │ Software channel subscriptions:                                        ▒ │
  │ This system will receive updates from the following Red Hat Network    ▒ │
  │ software channels:                                                     ▒ │
  │ rhel-x86_64-server-6                                                   ▒ │
  │                                                                        ▒ │
  │ Warning: If an installed product on this system is not listed above,   ↓ │
  │                                                                          │
  │                                 ┌────┐                                   │
  │                                 │ OK │                                   │
  │                                 └────┘                                   │
  │                                                                          │
  │                                                                          │
  └──────────────────────────────────────────────────────────────────────────┘

  <Tab>/<Alt-Tab> between elements  |  <Space> selects  |  <F12> next screen

Press 'OK', and finish the process.


Now we can install 'openssh' by 'yum':

---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package          Arch    Version                   Repository             Size
================================================================================
Installing:
 openssh-clients  x86_64  5.3p1-81.el6_3            rhel-x86_64-server-6  358 k
Updating:
 openssh          x86_64  5.3p1-81.el6_3            rhel-x86_64-server-6  236 k
 openssh-server   x86_64  5.3p1-81.el6_3            rhel-x86_64-server-6  300 k
Installing for dependencies:
 libedit          x86_64  2.11-4.20080712cvs.1.el6  rhel-x86_64-server-6   74 k

Transaction Summary
================================================================================
Install       2 Package(s)
Upgrade       2 Package(s)

Total download size: 969 k
Is this ok [y/N]:

After the install process completed, let's start the ssh service:

[root@dhcp-66-78-40 ~]# service sshd start

Now we can login to this VM by ssh command:

mini:~ weinanli$ ssh root@10.66.78.40
The authenticity of host '10.66.78.40 (10.66.78.40)' can't be established.
RSA key fingerprint is 94:46:81:9a:dc:e1:4d:a9:e9:12:2c:92:6f:ff:bf:8a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.66.78.40' (RSA) to the list of known hosts.
root@10.66.78.40's password:
Last login: Mon Jan 14 14:02:40 2013
[root@dhcp-66-78-40 ~]#

Now we should create an ordinary user account and disable root ssh login to ensure the system safety.

btw, don't disable SELinux, learn how to use it :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment