Linux uses the actual physical hard disk as the Virtual File System

Source: Internet
Author: User

I recommend a very good Linux operating system for you to learn. Here I will mainly explain the application of the Linux operating system, including the introduction of xLinux operating system knowledge. The file storage system of the virtual Linux operating system. The virtual system should have a storage place, that is, the file system.

What file systems can a virtual system install and run on? Can be installed and run on an actual physical partition, an image file, or network file system such as NFS;

Use the actual physical hard disk as the virtual Linux operating system file system;

The actual physical hard disk partition is used as the file system of the virtual Linux operating system. To create a file system through hard disk partitioning, see: detailed procedures for creating a file system and mounting a file system in Linux prepare physical partitions and create a file system;
Introduction to Linux commands for viewing disk partitions, file systems, usage, and related tools
How to Use fdisk for instance explanation
Rational Planning of your hard disk partition
How to create a file system and mount a file system in Linux

Build a Linux operating system on a physical partition;

Build a Linux operating system. Currently, another Linux operating system is built in one Linux operating system, mainly through the chroot tool and the software package Extraction Tool. The basic things still need a bit. Please refer to: Overview of Linux operating system construction through chroot

At present, in the open-source community, some people have completed some basic systems of commonly used releases. We can use it directly. Oh ..... As long as there is a basic system, we can enter the chroot, and we can use the corresponding release Package Manager to build the Linux operating system.

Linux operating system resources: http://jailtime.org you can directly download your favorite Linux operating system, unzip, then mount the image file, copy the image file content to the physical partition. However, you have to make some minor modifications, such as downloading/etc/fstab files from the system image file. You need to modify the value based on the virtual ing points defined in your guided virtual Linux operating system.

Definition of the file system in the boot file of the virtual Linux operating system;

If your hard disk has a certain amount of space, you can install the virtual Linux operating system in the actual physical partition of the hard disk. Of course, you must first prepare a hard disk partition. Then formatted into a Linux File System, such as ext3 or reiserfs;

Then, you need to build the desired virtual Linux operating system on this partition, and finally write the boot configuration file for the virtual Linux operating system. In the configuration file, you must specify it with phy. For example: disk = ['phy: hda7, sda1, W'] Chinese meaning: disk = ['phy: partition, ing point, W']

What does this line mean? It indicates that the virtual Linux operating system is installed in/dev/hda3. We need to virtualize the hda3 hard disk partition to/dev/sda1 and it is readable and writable; it is worth noting that partitions in use on the virtual platform cannot be used as ing points.

For example, in Slackware, I am a virtual platform in/dev/hda6, that is, a Linux operating system that is actually running. I want to use it to virtualize the Fedora in the/dev/hda7 partition. Therefore, I cannot use/dev/hda6 as the ing point of hda7. That is, the following line is incorrect:

 
 
  1. Disk= ['Phy: hda7, hda6, W'] how to define the ing points is also easier, as long as it complies with the rules of the Linux device; for example, the following can also be used;
  2. Disk= ['Phy: hda7, sda2, W']
  3. Disk= ['Phy: hda7, sda3, W']
  4. Disk= ['Phy: hda7, sdb1, W']
  5. Disk= ['Phy: hda7, sdb2, W']
  6. ......

What is a ing point? That is to say, after being defined by the phy, the real physical partition of the virtual Linux operating system is mapped to another partition on the virtual platform. This may be a bit difficult to understand. For example, in Slackware, the virtual Fedora is located in/dev/hda7. In the configuration file that guides Fedora, we define that the physical partitions used by Fedora are mapped to/dev/sda1;

 
 
  1. disk = ['phy:hda7,sda1,w']   
  2. root = "/dev/sda1 ro" 

When we boot Fedora, the Fedora file system uses the virtualized partition, that is,/dev/sda1. In Fedora, we can see from df-h that Fedora is located in/dev/sda1. Therefore, in the configuration file that directs Fedora, there is also a line to specify where the root of Fedora is, on/dev/sda1; because/dev/hda7 has been virtualized to/dev/sda1. I understand this time;

A file system that uses image files as virtual Linux operating systems;

Using image files as the file system of a virtual Linux operating system is a common method. It is also convenient and easy to operate, that is, the virtual Linux operating system is placed in a file.

Create an image file;

 
 
  1. [Root @ localhost ~] # DdIf=/Dev/zeroOf=Fedora50. ImgBs=2 kSeek=2048 k Count=1 
  2. Read 1 + 0 blocks
  3. Output 1 + 0 blocks
  4. [Root @ localhost ~] # Ls-lh fedora50.img
  5. -Rw-r -- 1 root 4.1G 2006-04-13 0:27 fedora50.img

We can use dd to create an image file. In the preceding example, an image file named fedora50.img is created in a size of 4.1G; you can adjust the size of the preceding command parameters to create the desired image file.

Format the image to a Linux File System;

For Linux file systems, such as ext3 or reiserfs, you can use mkfs. ext3 or mkfs. reiserfs to create a file system. For details, refer:

 
 
  1. [Root @ localhost ~] #/Sbin/mkfs. ext3 fedora50, img
  2. Mke2fs 1.38 (30-Jun-2005)
  3. Fedora50, img is not a block special device.
  4. Proceed anyway? (Y, n) y Note: Enter y here for formatting, and press Enter when prompted.

In this way, fedora50.img is the ext3 file system. You can use mount-o loop to mount and store files on it.

 
 
  1. [Root @ localhost ~] # Mkdir/mnt/fedora50
  2. [Root @ localhost ~] # Mount-o loop fedora50.img/mnt/fedora50
  3. [Root @ localhost ~] # Df-h
  4. Root @ localhost:/opt # df-lh
  5. Filesystem capacity in use available % mount point
  6. /Dev/hda6 12G 8.5G 3.3G 73%/
  7. /Root/fedora50, img 4.0G 129 M 3.7G 4%/mnt/fedora

After the above commands are executed, it indicates that fedora50.img has been mounted to the/mnt/fedora directory. We can store files in/mnt/fedora. In this way, it is written to the fedora50.img image file. After writing, we can uninstall fedora50.img; [root @ localhost ~] # Umount/mnt/fedora
 
Build a Linux operating system on the image file;

Build a Linux operating system on the image file. Currently, another Linux operating system is built in a LinuxLinux operating system, mainly through the chroot tool and the software package Extraction Tool. Some basic things are still needed. Please refer to: Currently, some basic systems of commonly used releases have been completed in the open-source community. We can use it directly.

As long as there is a basic system, we can enter the chroot, and we can use the corresponding release Package Manager to build the Linux operating system. Linux operating system resources: http://jailtime.org virtual Linux operating system boot file on the definition of the file system;

 
 
  1. disk = ['file:/opt/vmos/vmos.img,sda1,w', 'file:/opt/vmos/vmos.swap,sda2,w']  
  2. root = "/dev/sda1 ro" 

We still use the example to explain how to map the image with vmos. img to the/dev/sda1 partition. vmos. img is the root storage location of the virtual Linux operating system. Vmos. swap is the swap partition of the Virtual File System. This swap partition is also a file mapped to/dev/sda2. Then, specify the partition of the virtual Linux operating system through the root = line, which is the virtual partition.

When defining, pay attention to where your files are stored? The preceding example indicates that vmos. img and vmos. swap are stored in the/opt/vmos directory. All right ..

  1. To learn about Linux, we recommend that you start with Fedora.
  2. Linux operating system Redhat series and Debian Series
  3. The fastest way to read every Linux operating system in Linux
  4. The Linux operating system is directly built on the kernel.
  5. Introduction to Linux operating system experimental scenarios

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.