小型linux制作参考文档
1,构建镜像文件(100M)
mkdir work
dd if=/dev/zero of=/work/linux_root.img bs=1k count=100000 100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 0.803413 s, 127 MB/s
2,将文件挂载为设备
losetup /dev/loop0 /work/linux_root.img
3,格式化设备(Ext2)
mkfs.ext2 /dev/loop0 (或者 mkfs.ext3)
mke2fs 1.41.1 (01-Sep-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
5016 inodes, 20000 blocks
1000 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=20709376
3 block groups
8192 blocks per group, 8192 fragments per group
1672 inodes per group
Superblock backups stored on blocks:
8193
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
4,将文件从设备中卸载
losetup -d /dev/loop0
5,挂载镜像文件为目录
mount -o loop /work/linux_root.img /mnt/ramdisk/
6,df 命令查看文件使用情况
df -h
Filesystem Size Used Avail Use% Mounted on
.............