Difference between revisions of "DevKit8600 FAQ"

From eLinux.org
Jump to: navigation, search
(Created page with "一、如何对已有的根文件系统进行修改? 假设已有一个名为ramdisk.gz的文件系统压缩文件,可以通过以下步骤实现对该文件系统的修...")
 
Line 1: Line 1:
一、如何对已有的根文件系统进行修改?
 
  
假设已有一个名为ramdisk.gz的文件系统压缩文件,可以通过以下步骤实现对该文件系统的修改:
+
== How to create ramdisk under Linux ==
 +
Q1: How to alter an existing Root File System?
  
1. 将文件系统的压缩文件解压成映像文件;
+
Let’s assume there is a compressed file system named ramdisk.gz. We could realize alteration on it by the following steps:
 +
 
 +
1. Uncompress the file into an image file;
  
 
#cd ramdisk.gz
 
#cd ramdisk.gz
Line 9: Line 11:
 
#gunzip ramdisk.gz
 
#gunzip ramdisk.gz
  
2. 挂载解压后的映像文件来实现修改;
+
2. Mount the uncompressed image file to realize alteration;
  
 
#mkdir /mnt/loop
 
#mkdir /mnt/loop
Line 17: Line 19:
 
#cd /mnt/loop
 
#cd /mnt/loop
  
这时可以根据需要增加、删减或是修改文件系统的内容。
+
Now the contents of the file system can be added, removed, or modified as required.
  
3. 卸装镜像文件;
+
3. Unmount the image file;
  
 
#cd ramdisk
 
#cd ramdisk
Line 25: Line 27:
 
#umount /mnt/loop
 
#umount /mnt/loop
  
4. 将修改后的文件系统制作成压缩文件;
+
4. Create a compressed file by using the altered file system;
  
#gzip –v9 ramdisk  
+
#gzip –v9 ramdisk
  
二、如何建立新的根文件系统?
+
Q2: How to create a new Root File System?
  
(方法一)
+
(Approach one)
  
1. 建立loop设备的临时挂载点;
+
1. Create a temporary mounting point for loop devices;
  
 
#mkdir /mnt/loop
 
#mkdir /mnt/loop
  
2. 建立一个大小为15M的临时文件;
+
2. Create a 15M temporary file;
  
 
#dd if=/dev/zero of=/tmp/loop_tmp bs=1k count=15360
 
#dd if=/dev/zero of=/tmp/loop_tmp bs=1k count=15360
  
临时文件的大小可根据自己的需要对参数count进行调整即可;
+
The size of the temporary file could be changed by adjusting the value of the parameter count;
  
3. 将设备文件与临时文件联系起来;
+
3. Associate device file with the temporary file;
  
 
#losetup /dev/loop0 /tmp/loop_tmp  
 
#losetup /dev/loop0 /tmp/loop_tmp  
  
如果出现“ioctl:LOOP_SET_FD:设备或资源忙”,说明/dev/loop0设备还和一文件联系,可用losetup /dev/loop0查看地,并可用-d 删除;
+
If a message ‘ioctl:LOOP_SET_FD: device is busy’ appears, it indicates that the device /dev/loop0 is still associated with another file. Command losetup /dev/loop0 can be used to view the device, and remove it with parameter -d;
  
4. /dev/loop0格式化为ext2文件系统;
+
4. Format /dev/loop0 as ext2 file system;
  
 
#mke2fs –m 0 /dev/loop0
 
#mke2fs –m 0 /dev/loop0
  
5. 把虚拟盘挂在节点/mnt/loop上;
+
5. Mount the virtual disk on the mounting point /mnt/loop;
  
 
#mount –t ext2 /dev/loop0 /mnt/loop;
 
#mount –t ext2 /dev/loop0 /mnt/loop;
  
6. 用cp –af命令将所需要的文件拷贝到虚拟盘上;
+
6. Copy all the required files to the virtual disk by the command cp -af;
  
7. 通过cd命令切换到除/mnt/loop目录以外的其他目录,然后卸载文件系统;
+
7. Move from current directory /mnt/loop to another directory by the command cd, and then unmount the file system;
  
#cd /xx (xx表示除/mnt/loop以外的其他目录)
+
#cd /xx (xx means any directories except /mnt/loop)
  
 
#umount /mnt/loop  
 
#umount /mnt/loop  
  
得到的/tmp/loop_tmp就是文件系统映象
+
The file at /tmp/loop_tmp is the image of file system.
  
8. 压缩映象文件生成文件系统;
+
8. Compress the image file to create a file system;
  
 
#gzip –v9 /tmp/loop_tmp >/tftpboot/ramdisk.gz  
 
#gzip –v9 /tmp/loop_tmp >/tftpboot/ramdisk.gz  
  
#gzip –v9 /tmp/loop_tmp  
+
or
 +
#gzip –v9 /tmp/loop_tmp  
  
(方法二)
+
(Approach two)
  
1. 建立loop设备的临时挂载点;
+
1. Create a temporary mounting point for loop devices;
  
 
#mkdir /mnt/loop
 
#mkdir /mnt/loop
  
2. 建立一个大小为15M的临时文件;
+
2. Create a 15M temporary file;
  
 
#dd if=/dev/zero of=/tmp/loop_tmp bs=1k count=15360
 
#dd if=/dev/zero of=/tmp/loop_tmp bs=1k count=15360
  
3. 将loop_tmp格式化为ext2文件系统;
+
3. Format loop_tmp as ext2 file system;
  
 
mke2fs –F –v –m 0 /tmp/loop_tmp  
 
mke2fs –F –v –m 0 /tmp/loop_tmp  
  
4. 挂载格式化后的临时文件;
+
4. Mount the formatted temporary file;
  
 
#munt –o loop /tmp/loop_tmp /mnt/loop  
 
#munt –o loop /tmp/loop_tmp /mnt/loop  
  
5. 用cp –af命令将所需要的文件拷贝到临时文件中从而生成映像文件;
+
5. Copy all the required files to the temporary file by the command cp –af to create an image file;
  
6. 卸载生成的映象文件;
+
6. Unmount the created image file;
  
#umount /mnt/loop
+
#umount /mnt/loop  
  
7. 压缩映象文件生成文件系统;
+
7. Compress the image file to create a file system;
  
 
#gzip –v9 /tmp/loop_tmp
 
#gzip –v9 /tmp/loop_tmp

Revision as of 02:09, 6 November 2012

How to create ramdisk under Linux

Q1: How to alter an existing Root File System?

Let’s assume there is a compressed file system named ramdisk.gz. We could realize alteration on it by the following steps:

1. Uncompress the file into an image file;

  1. cd ramdisk.gz
  1. gunzip ramdisk.gz

2. Mount the uncompressed image file to realize alteration;

  1. mkdir /mnt/loop
  1. mount –o loop ramdisk /mnt/loop
  1. cd /mnt/loop

Now the contents of the file system can be added, removed, or modified as required.

3. Unmount the image file;

  1. cd ramdisk
  1. umount /mnt/loop

4. Create a compressed file by using the altered file system;

  1. gzip –v9 ramdisk

Q2: How to create a new Root File System?

(Approach one)

1. Create a temporary mounting point for loop devices;

  1. mkdir /mnt/loop

2. Create a 15M temporary file;

  1. dd if=/dev/zero of=/tmp/loop_tmp bs=1k count=15360

The size of the temporary file could be changed by adjusting the value of the parameter count;

3. Associate device file with the temporary file;

  1. losetup /dev/loop0 /tmp/loop_tmp

If a message ‘ioctl:LOOP_SET_FD: device is busy’ appears, it indicates that the device /dev/loop0 is still associated with another file. Command losetup /dev/loop0 can be used to view the device, and remove it with parameter -d;

4. Format /dev/loop0 as ext2 file system;

  1. mke2fs –m 0 /dev/loop0

5. Mount the virtual disk on the mounting point /mnt/loop;

  1. mount –t ext2 /dev/loop0 /mnt/loop;

6. Copy all the required files to the virtual disk by the command cp -af;

7. Move from current directory /mnt/loop to another directory by the command cd, and then unmount the file system;

  1. cd /xx (xx means any directories except /mnt/loop)
  1. umount /mnt/loop

The file at /tmp/loop_tmp is the image of file system.

8. Compress the image file to create a file system;

  1. gzip –v9 /tmp/loop_tmp >/tftpboot/ramdisk.gz

or

  1. gzip –v9 /tmp/loop_tmp

(Approach two)

1. Create a temporary mounting point for loop devices;

  1. mkdir /mnt/loop

2. Create a 15M temporary file;

  1. dd if=/dev/zero of=/tmp/loop_tmp bs=1k count=15360

3. Format loop_tmp as ext2 file system;

mke2fs –F –v –m 0 /tmp/loop_tmp

4. Mount the formatted temporary file;

  1. munt –o loop /tmp/loop_tmp /mnt/loop

5. Copy all the required files to the temporary file by the command cp –af to create an image file;

6. Unmount the created image file;

  1. umount /mnt/loop

7. Compress the image file to create a file system;

  1. gzip –v9 /tmp/loop_tmp