Moblin: KVM usage (2)

Source: Internet
Author: User

When we use KVM as the development environment of moblin, we encounter a problem: the size of the kvm simulation environment, that is, the virtual size is valid and may not meet our needs, at the same time, we have developed a lot of code above and do not want to be included in the preparation of usbimg. Nor can we remove the development code every time to make small-capacity img. Below we record my processing process.

Existing raw files:
-Rw-r -- 1 root 2621440001 06-30 moblin-netbook-ux-beta-last-200906300923-sda.raw


$ Qemu-img info moblin-netbook-ux-beta-last-200906300923-sda.raw view information


Image: moblin-netbook-ux-beta-last-200906300923-sda.raw


File format: raw


Virtual size: 2.4 GB (2621440000 bytes)


Disk size: 2.4 GB

The size of this file determines the size of the Virtual File System expanded with qemu-kvm. It is found that there is about 1 GB of free space in actual opening, and a lot of space is displayed, however, I found that the disk space was insufficient during the kernel build process. I once thought about modifying the script in MIC2 to solve this problem, but when I read these py files, I gave up. The file size is determined by the parameters set in the kickstart file.


1. Create an empty raw file to store user data, including development code.

There are two ways to achieve this. For example, we want an additional 5g space.

Method 1: qemu-img create, which can be described in detail through man qemu-img. Example: qemu-img create wei. raw 5G

Method 2: dd, this great dd, which I have never been particularly clear about, is now self-managed: dd if =/dev/zero of = zero. raw bs = 1024 k count = 5000

1024 k * 5000 = 5G.


Ii. Enable kvm

Load two raw files at the same time, as shown below:
Sudo qemu-kvm-m 512-boot c-hda moblin-netbook-ux-beta-last-200906300923-sda.raw-hdb wei. raw-std-vga

  

The first raw is-hda, and the second is-hdb. We can continue to load it. After it is enabled, hda is/dev/sda, and hdb is/dev/sdb.

In the kvm environment, use/sbin/fdisk-l under the root, you can see that there is an unpartitioned Disk/dev/sdb.

Use/sbin/fdisk/dev/sdb to add a partition for the virtual disk, and then add/dev/sdb1. Use/sbin/mkfs-t ext3/dev/sdb1 to root the partition into ext3. The rest is the mount of a partition. Create mount point: mkdir/home/wei, edit/etc/fstab, add relevant information, and then mount the partition using mount-t ext3/dev/sdb1/home/wei.

Run the/usr/sbin/useradd command to add user wei, set the user directory to/home/wei automatically, and use passwd wei to set the password. This is all set and can be used. We can also exit safely through/sbin/init 0 and re-enter kvm. Check that new users and new partitions can take effect normally. This mounting partition serves as the space for our development.

 

3. Create an IMG

To create an IMG, you only need to convert the raw files in the root directory. You do not need to add the raw files of our development users. This saves a lot of trouble during the commissioning process, and finally generates the formal IMG. We only need to change userdel and modify the/etc/fstab file. If you need to reload it, that is, within 1 minute.

 

Link: moblin: KVM usage (1)

Related Article

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.