Measure the test taker's knowledge about the virtual root file system.

Source: Internet
Author: User

# Load the driver,See note 1
Modprobe DM-mirror

# Creating a device,See Note 2
Mknod/dev/Zero C 1 5
Mknod/dev/loop0 B 7 0
Mknod/dev/loop1 B 7 1
Mknod/dev/loop2 B 7 2
Mkdir/dev/cow
Mknode/dev/cow/ctl B 241 255
Mknode/dev/cow/0 B 241 0

# Mount the squash root file system. After mounting, you can find the rootfs file under/realroot/mnt,See note 3
Mount/realroot/mnt/squashrootfs/realroot/mnt/-o loop

# Set rootfs as a loop device,See note 4
Losetup/dev/loop1/realroot/mnt/rootfs

# Create cowfile. Out and mount it as a loop device. All future write operations will be written to cowfile. Out.
Dd If =/dev/Zero of =/realroot/mnt/cowfile. out BS = 2 k COUNT = 137500
Losetup/dev/loop2/realroot/mnt/cowfile. Out

# Combine/realroot/mnt/rootfs and/realroot/mnt/cowfile. Out to create a logical root file device,
# The device file is/dev/mapper/root_fs ,,See note 5
Echo "0 $ (blockdev -- getsize/dev/loop1) Snapshot/dev/loop1/dev/loop2 P 64" |
DMSetup create root_fs

# Mount the logical root file device/dev/mapper/root_fs created above to view a readable and writable root file system.
Mount/dev/mapper/root_fs/realroot/mnt/Image

# Switch to the final root file system that can be read and written
CD/realroot/mnt/Image
Chroot./sbin/init-I

 

The main command used by squash to compress the file system structure:

  • Mknod:Create squash compressed file system

  • Losetup:Set and control the loop device

  • Chroot:Change root directory

  • DMSetup:Low-level logical volume Management

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.