Xen Virtual Machine Disk File Mounting in xen virtualization series (11)

Source: Internet
Author: User

List of articles on xen virtualization practice series

Installation of xen virtualization environment in xen virtualization series (I)
Xen Virtual Machine installation in xen virtualization series (II)
Xen virtualization series (III): xen Virtual Machine Replication
Xen virtualization practice series (4): xen Virtual Machine Disk Space Expansion Method
Xen virtualization practice series (V): How to expand disk space for xen virtual machines
Xen virtualization practice series (6): xen Virtual Machine password cracking

Xen Virtual Machine VNC access configuration

Xen virtualization series (8) self-starting xen VM Configuration
Xen virtualization series (9): xen Virtual Machine Time Configuration
Xen virtualization practice series (10) Dual Nic configuration for xen virtual machines

Xen Virtual Machine Disk File Mounting in xen virtualization series (11)

Xen virtualization practice series (12): online migration of high availability of xen virtual machines

Xen virtualization practice series (13)-centralized management of xen virtual machines-convirt

 

We all know that xen virtual machines use the most Virtual Disk Files to act as virtual machine disks. In this article, xen virtual machine files are mounted to read and modify files to meet maintenance requirements.

There are usually the following scenarios, this article from: http://koumm.blog.51cto.com

(1) a disk of an important xen virtual machine is obtained on a server without an xen virtualization environment and needs to be copied to a very important file, you can use this document to obtain important files.

(2) there is another case is the previous release of a password cracking article: http://koumm.blog.51cto.com/703525/1285969 later mentioned another way is to use this method for password cracking.

1. view existing virtual machines and Disk Files

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492G522-0.png "height =" 257 "/>

2. view the Virtual Machine Disk File Location

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492H008-1.png "height =" 259 "/>

3. view the disk partition information

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492I208-2.png "height =" 274 "/>

You can run the fdisk command to view the partitions of the Virtual Machine disk files. In this article, the virtual machine is divided into one/boot partition, and the remaining space is used to create an LVM volume, then swap and/root partition are created in the LVM volume. Here we can see that a common partition is the/boot partition, and an LVM volume is the lvm logic, so we can understand the partition situation.

4. Map Virtual Disk Files

A kpartx command is required to mount a virtual disk file. The kpartx command can also view the partition structure of the virtual disk file, which is consistent with the fdisk command.

The kpartx command maps the virtual disk file with the loop device file on the local system, and then maps the loop device file for partitioning, mounting, and data processing.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492I910-3.png "height =" 146 "/>

(1) simulate viewing ing, non-real ing

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492G104-4.png "height =" 102 "/>

(2) Start ing

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492K217-5.png "height =" 88 "/>

The device file is located at/dev/mapper/loop0p1,/dev/mapper/loop0p2.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492I514-6.png "height =" 163 "/>

The first/dev/mapper/loop0p1 is a common linux partition, And/dev/mapper/loop0p2 is an LVM logical volume, which must be processed in different ways. The following process is performed based on the scenario.

5. Mount common Disk Files

According to the previous analysis, the first/dev/mapper/loop0p1 is a common linux partition, that is, the/boot partition, which contains the grub STARTUP configuration file. You can change the password by modifying the parameters in the/boot/grub. conf file and using the Virtual Machine in single-user mode.

(1) Mount Device Files

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492KA5-7.png "height =" 157 "/>

(2) The mounting is successful. You can view the content successfully.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492G2a-8.png "height =" 314 "/>

(3) modify the grub/grub. conf file, modify the following content, and use the single-user mode when the system starts.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492Ga1-9.png "height =" 340 "/>

(4) Cancel mount deletion ing

# Umount/mnt

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492HS7-10.png "height =" 84 "/>

(5) boot Test

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492G247-11.png "height =" 106 "/>

Log on to the VM on the console, and click "single user" to change the password.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492K092-12.png "height =" 465 "/>

Restore the grub. conf file

Sh-3.2 # vi/boot/grub. conf

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492M0Z-13.png "height =" 86 "/>

Cancel configuration by single user and restart.

Mount the common partition file, read the file, and modify the file sample successfully.

6. Mount the LVM Disk File

According to the previous analysis, the first/dev/mapper/loop0p1 is a common linux partition, that is, the/boot partition, and the second is a logical volume that includes LVM, in this case, lvm is used for processing.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492I094-14.png "height =" 86 "/>

(1) Scanning physical volumes

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492JE3-15.png "height =" 195 "/>

You can see that the vg volume group is successfully executed.

(2) activate the scanned vg volume group and use it after activation.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492GA0-16.png "height =" 120 "/>

(3) After activation, the lvm logical volume is located under/dev/mapper/, as shown in the following figure. Vg-swap is a swap, and vg-root is a root partition.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492G557-17.png "height =" 227 "/>

(4) mount the root partition to/mnt.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492H348-18.png "height =" 210 "/>

# Cd/mnt

The NIC configuration file is read successfully.

650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" image "border =" 0 "alt =" image "src =" http://www.bkjia.com/uploads/allimg/131227/16492I4X-19.png "height =" 162 "/>

The entire content is mounted to the disk file of the xen virtual machine. In the actual production and testing environment, you can complete some tasks in the above way.

Note: linux technology is profound and profound. Mounting Virtual Disk File partitions is only the above method. There are also methods. We will not introduce them here. Over...

This article is from the "koumm linux technology blog" blog, please be sure to keep this source http://koumm.blog.51cto.com/703525/1286477

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.