创建文件系统

 
平台 : ubuntu8.04

1.初始化文件
#dd if=/dev/zero of=file.img bs=1k count=10000
10000+0 records in
10000+0 records out
10240000 bytes (10 MB) copied, 0.0571518 s, 179 MB/s


if指输入,of输出,bs一次写的块大小,count写多少次
10000+0证明文件大小刚好能整除bs,否则会出现+1什么的,将不足1k的单独处理

这里指用10000*1k的0填充file.img文件

2.losetup,使用循环设备关联文件

# losetup /dev/loop2 file.img

在这之前最好查询not busy的loop,否则即使没挂好也没错误提示.
# losetup -f
#man losetup 获取更多信息  -s也挺好

3.创建文件系统

# mke2fs -c /dev/loop2 10000
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
2512 inodes, 10000 blocks
500 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=10485760
2 block groups
8192 blocks per group, 8192 fragments per group
1256 inodes per group
Superblock backups stored on blocks:
    8193

Checking for bad blocks (read-only test): done                                
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


4.挂载

# umount /mnt/
# mkdir /mnt/point1
# mount -t ext2 /dev/loop2 /mnt/point1/
t# ls /mnt/point1/
lost+found


恩,不错。可以对他进行操作了.可以再在此文件系统上按照相同步骤再造文件系统,递归一下。

http://www.ibm.com/developerworks/cn/linux/l-linux-filesystem/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值