3步实现制作并挂载自己的Linux硬盘分区

1. 建立一个大型档案

# dd if=/dev/zero of=/home/loopdev bs=1M count=512

if : input file /dev/zero是会一直输出0的装置

of : output file

bs是每个block大小

count是总共有多少个bs


屏幕输出:

512+0 records in //读入512笔资料
512+0 records out //输出512笔数据
536870912 bytes (537 MB) copied, 6.45734 s, 83.1 MB/s


2.格式化

# mkfs -t ext4 /home/loopdev

使用ext4文件系统格式

屏幕输出:

mke2fs 1.41.12 (17-May-2010)
/home/loopdev is not a block special device.
Proceed anyway? (y,n) y //由于不是正常的装置,所以会提示,选择y,按Enter继续

屏幕输出:

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768 inodes, 131072 blocks
6553 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=134217728
4 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304


Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done


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


3.挂载

# mount -o loop /home/loopdev /root/myloopdev/

将该档案挂载到/root/myloopdev/下


查看下磁盘空间情况

# df

屏幕输出:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda1            20641404   6202512  13390368  32% /
tmpfs                   960472         0    960472   0% /dev/shm
/home/loopdev           516040     16780    473048   4% /root/myloopdev

成功!

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。