1. Create a large file
# dd If=/dev/zero of =/home/loopdevBS=1m Count=512
If:input file /dev/zero is a device that will always output 0
Of:output file
BS is the size of each block
Count is the total number of BS
Screen output:
512+0 Records in //Read 512 data
512+0 Records out //output 512 pen data
536870912 bytes (537 MB) copied, 6.45734 s, 83.1 MB/s
2. Formatting
# mkfs-t Ext4/home/loopdev
Using the Ext4 File system format
Screen output:
MKE2FS 1.41.12 (17-may-2010)
/home/loopdev is not a block special device.
Proceed anyway? (y,n) y //Because it is not a normal device, so prompt, select Y, press ENTER to continue
Screen output:
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'll be automatically checked every mounts or
Whichever comes first. Use Tune2fs-c or-i to override.
3. Mounting
# Mount-o loop/home/loopdev/root/myloopdev/
Attach the file to/root/myloopdev/
view down disk space conditions
# DF
Screen output:
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
Success!
3 steps to make and mount your own Linux hard disk partition