Total Pageviews

Showing posts with label qemu. Show all posts
Showing posts with label qemu. Show all posts

Friday, 22 December 2023

在电脑上运行鸿蒙(OpenHarmony)系统:PolyOS


华为 OpenHarmony 一款开源分布式操作系统,打造万物智联的世界,实现设备、云服务和应用等各个环节的无缝协同。支持多种设备类型,例如包括有:手机、平板、穿戴设备、智能家居设备、车载娱乐系统以及 IoT 等。

之前已经有自学开源鸿蒙的开发者 Diemit 成功将 OpenHarmony 系统移植到小米 6 手机和树莓派 4 上,并不断晒出适配进展,感兴趣的可以先去 B 站关注@Diemit。

如果你手头没有相关的设备可以刷入 OpenHarmony 系统,现在可以通过这个「PolyOS」开源操作系统在电脑上体验 OpenHarmony 或者研究学习。

PolyOS介绍

据官方介绍主要为 RISC-V 硬件厂商和开发者提供 OpenHarmony 参考移植实现,目前以 qemu-riscv64 虚拟化平台为硬件基础:

你可以在 Windows、Linux、macOS 平台运行 OpenHarmony 系统,官方也提供了详细的安装教程,这里以Windows 平台为例:

✅ 硬件要求

    CPU:4 核心、8 线程;
    内存:8 Gib 内存;
    系统:Windows 10/11

✅ 下载和安装

1.先下载 OpenHarmony 镜像并解压出来

2.下载安装由 PolyOS 社区重新分发的 QEMU 版本。程序默认将被安装至 C:\Porgram Files\PolyOS QEMU 文件夹。

✅ 配置 QEMU 环境

你可以选择将 C:\Porgram Files\PolyOS QEMU 加入到您的环境变量中。打开终端,逐行复制粘贴下面的内容。

$env:Path = "C:\Porgram Files\PolyOS QEMU" + $env:Path
[Environment]::SetEnvironmentVariable("Path", $env:Path, "Machine")

✅ 运行 OpenHarmony

你可以选择直接使用一个初始化脚本来启动,该脚本附带在镜像文件中。用终端方运行 qemu_riscv64_run_windows.ps1 文件就会启动系统了。

    *如果脚本在执行过程中报错,有可能是因为您的系统禁止运行脚本。用管理员的身份运行 PowerShell,然后输入 set-executionpolicy remotesigned 执行策略更改,再重新执行脚本。

进入桌面整个体验很卡顿,估计是没有适配 GPU 驱动的原因,并且导致电脑的 CPU 占用也非常高。OpenHarmony 自带的应用方面只有几个,例如:计算器、备忘录、时钟、通讯录、相册、短信等。

自带每个应用功能也是很简陋,主要因为 OpenHarmony 是一个开放的生态系统,任何开发者都可以在这个基础上进行功能定制开发。

功能设置方面也是比较常规,蓝牙、移动数据、显示与亮度、声音、生物识别和密码、用户账号等等。

系统版本方面采用了 OpenHarmony 3.2 Beta 2,目前华为已经发布了 4.0 版本,后续「PolyOS」应该也会跟进版本吧。

总结

这个「PolyOS」处在早期阶段的社区驱动项目,主要给开发者提供测试环境,从而加快开发周期,降低开发成本。所以对普通用户来说没什么用,也就体验一下罢了,感兴趣的可以下载试试看。
下载地址
    官方网站:
    https://polyos.iscas.ac.cn
    官方下载:
    https://polyos.iscas.ac.cn/get-polyos
    文档教程:
    https://polyos.iscas.ac.cn/docs


Sunday, 31 January 2016

qemu

Once
QEMU has been installed, and kqemu compiled and configured, it should
be ready to run a guest OS from a virtual disc image. A disc image is a
file that represents the data on a hard disc. From the perspective of
the guest OS, it actually is a hard disc, and the guest OS can actually
create its own filesystem on the virtual disc.

You can download a few guest OS images from the QEMU website, including a simple 8MB image of a Linux distro. To run it, download and unzip the image in a folder and run the QEMU command.

qemu linux-0.2.img

Replace linux-0.2.img
with the name of your guest OS image file. If it has a GUI and you want
to use your mouse with it, double-click on the window and QEMU will
grab your mouse. To make QEMU release your mouse again, hold down the
Control and Alt keys simultaneously, then let go - your mouse will be
released back to X.

Image types
QEMU supports several image types. The "native" and most flexible type is qcow2, which supports copy on write, encryption, compression, and VM snapshots.
If you need to copy files to and from the image directly from the host, however, you need to use the raw image type.
QEMU currently supports these image types or formats:
raw
Creating an image
To set up your own guest OS image, you first need to create a blank disc image. QEMU has the qemu-img
command for creating and manipulating disc images, and supports a
variety of formats. If you don't tell it what format to use, it will use
raw files. The "native" format for QEMU is qcow2, and this format
offers some flexibility. Here we'll create a 3GB qcow2 image to install
Windows XP on:
qemu-img create -f qcow2 winxp.img 3GB
The
easiest way to install a guest OS is to create an ISO image of a boot
CD/DVD and tell QEMU to boot off it. Many free operating systems can be
downloaded from the Internet as bootable ISO images, and you can use
them directly without having to burn them to disc.
Here
we'll boot off an ISO image of a properly licensed Windows XP boot
disc. We'll also give it 256MB of RAM, but we won't use the kqemu kernel
module just yet because it causes problems during Windows XP
installation.
qemu -m 256 -hda winxp.img -cdrom winxpsp2.iso -boot d
To boot from a real CD or DVD, tell QEMU where to find it. On Linux systems, you can usually use a logical device name like /dev/cdrom or /dev/dvd, or the physical name of the device, e.g. /dev/sr0
qemu -m 256 -hda winxp.img -cdrom /dev/cdrom -boot d
QEMU
will boot from the ISO image or CD/DVD and run the install program. If
you have two screens, move the QEMU screen off to the spare one where
you can keep an eye on the installer, but get on with something else -
it will take a while!
Once
the guest OS has installed successfully, you can shutdown the guest OS
(e.g. in Windows XP, click on Start and then Shutdown). Once it has
shutdown, start QEMU up with the kqemu kernel module to give it a little
more speed.
qemu -m 256 -hda winxp.img -cdrom winxpsp2.iso -kernel-kqemu
If you are running an x86-64 Linux (i.e. 64-bit), you will need to run the x86-64 version of QEMU to be able to utilise kqemu:
qemu-system-x86_64 -m 256 -hda winxp.img -cdrom winxpsp2.iso -kernel-kqemu
Using multiple images
QEMU
can utilise up to four image files to present multiple virtual drives
to the guest system. This can be quite useful, as in the following
examples:
pagefile or swapfile virtual disc that can be shared between QEMU guests
Bear in mind that only one instance of QEMU may access an image at a time - shared doesn't mean shared simultaneously!
To utilise additional images in QEMU, specify them on the command line with options -hda, -hdb, -hdc, -hdd.
qemu -m 256 -hda winxp.img -hdb pagefile.img -hdc testdata.img -hdd tempfiles.img -kernel-kqemu
NB:
QEMU doesn't support both -hdc and -cdrom at the same time, as they
both represent the first device on the second IDE channel.
Copy on write
The "cow" part of qcow2 is an acronym for copy on write,
a neat little trick that allows you to set up an image once and use it
many times without changing it. This is ideal for developing and testing
software, which generally requires a known stable environment to start
off with. You can create your known stable environment in one image, and
then create several disposable copy-on-write images to work in.
To start a new disposable environment based on a known good image, invoke the qemu-img
command with the option -b and tell it what image to base its copy on.
When you run QEMU using the disposable environment, all writes to the
virtual disc will go to this disposable image, not the base copy.
qemu-img create -f qcow2 -b winxp.img test01.img 3GB
qemu -m 256 -hda test01.img -kernel-kqemu &
NB:
don't forget to copy any important data out of the disposable
environment before deleting it. When developing and testing software in
copy-on-write virtual environments, it is a good idea to use version control software likeSubversion or CVS
on a server external to your virtual environment. Not only is it easy
to keep copies of your work outside your virtual environment, it is also
very easy to set up a new virtual environment from version control.
Mounting an image on the host
Sometimes
it is helpful to be able to mount a drive image under the host system.
For example, if the guest doesn't have network support, the only way to
transfer files into and out of the guest will be by the storage devices
it can address.
Linux and other Unix-like hosts can mount images created with the raw format type using a loopback device. From a root login (or using sudo), mount a loopback with an offset of 32,256.
mount -o loop,offset=32256 /path/to/image.img /mnt/mountpoint
For example, to copy some files across to a FreeDOS hard drive image:
mkdir -p /mnt/freedos
mount -o loop,offset=32256 freedos-c.img /mnt/freedos
cp oldgames /mnt/freedos
umount /mnt/freedos
NB: never mount a QEMU image while QEMU is using it, or you are likely to corrupt the filesystem on the image.
Note:
if you have an image without partitions you should omit the
,offset=32256 part. This is for instance the case if you want to mount
linux-0.2.img (which can be found at the qemu web site at the time of
writing)
Getting information
The qemu-img program can tell you about the format, virtual size, physical size, and snapshots inside an image.
$ qemu-img info test.vmdk
(VMDK) image open: flags=0x2 filename=test.vmdk
image: test.vmdk
file format: vmdk
virtual size: 20M (20971520 bytes)
disk size: 17M
Converting image formats
The qemu-img
program can be used to convert images from one format to another, or
add compression or encryption to an image. Specify the source and target
files for the image, and select from the following options:
-f – optional, specify the format of the input file (QEMU can usually detect it)qemu-img convert -O qcow2 test.vmdk test.qcow2
Exchanging images with VirtualBox
To convert a QEMU image for use with VirtualBox, first convert it to raw
format, then use VirtualBox's conversion utility to convert and compact
it in its native format. Note that the compact command requires the
full path to the VirtualBox image, not just the filename.
qemu-img convert -O raw test.qcow2 test.raw
(1) VBoxManage convertdd test.raw test.vdi
VBoxManage modifyvdi /full/path/to/test.vdi compact
or try :
VBoxManage convertfromraw -format VDI test.raw test.vdi
VBoxManage
doesn't have the capability to convert an image back to raw format.
However, an older tool was available for download off the VirtualBox
website, vditool, can apparently convert from .vdi to raw format. UPDATE - Feb 2009 - current installations of VirtualBox should already include vditool. Kvditool is a GUI for managing vditool.
(2) or try :
VBoxManage internalcommands converttoraw file.vdi file.raw