Ramdisk creation in Linux

Source: Internet
Author: User
Article Title: Ramdisk creation in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

  1. modify an existing File System

Set the file system compressed file to ramdisk.gz.

1. Extract

# Cd ramdisk.gz directory

# Gunzip ramdisk.gz

After decompression, obtain the file system image file ramdisk, which overwrites the original compressed file.

2. Mount image files

The image file must be mounted to view the directories and details in the file system.

# Mkdir/mnt/loop

/*/Mnt/loop is the directory to which the file system is mounted.

# Mount? O loop ramdisk/mnt/loop

Operate the file system in the Mount directory/mnt/loop

# Cd/mnt/loop

# Do_whatever_you_want_to_do/* add, delete, or modify file system content as needed

4. Unload the File System

Jump out of the/mnt/loop directory; otherwise, the installation cannot be uninstalled, prompting busy

# Directory of cd ramdisk

# Umount/mnt/loop

5. compressed file system

# Gzip? V9 ramdisk

/* Generate the ramdisk.gz compressed file

  2. Build your own root file system

1. Create a temporary mount point for the loop device

# Mkdir/mnt/loop

2. Create a temporary file with a size of 15 MB

# Dd if =/dev/zero of =/tmp/loop_tmp bs = 1 k count = 15360

Note that you can create a proper file system based on your needs and change the count size.

Run the dd command to create a 15360KB file system image stored in/tmp/loop/tmp and initialize it with. dev/zero. This method is used to initialize the file system. Later, when we use the gzip command to compress the entire image, we will obtain the maximum compression ratio for unused parts of the file system.

3. associate a device file with a temporary file

# Losetup/dev/loop0/tmp/loop_tmp

Associate the device file/dev/loop0 with the temporary image file/tmp/loop_tmp./dev/loop0 is a block device.

If "ioctl: LOOP_SET_FD: the device or resource is busy" is displayed, the/dev/loop0 device also contacts a file and can be viewed by losetup/dev/loop0 and deleted by-d.

4. Format/dev/loop0 as the ext2 File System

# Mke2fs? M 0/dev/loop0

-M 0 indicates that you do not have to reserve any blocks for the "superuser" on the file system.

[1] [2] Next page

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.