磁盘分区后必须要格式化后才能使用,如Windows下的NTFS TAT32格式
====================================================================
[root@lxglinux ~]# cat /etc/filesystems【查看文件格式的配置文件】
ext4在【centos6中广泛使用】
ext3
ext2
nodev proc
nodev devpts
iso9660【光盘】
vfat【fat32】
hfs
hfsplus
======================================================================
[root@lxglinux ~]# fdisk /dev/sdb【格式化sdb】
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb9055410.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m【可以调出命令提示】
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition【增加新分区】
o create a new empty DOS partition table
p print the partition table【在屏幕上输出分区信息】
q quit without saving changes【退出】
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit【退出和保存】
x extra functionality (experts only)
Command (m for help): n【增加新分区】
Command action
e extended
p primary partition (1-4)
p【增加主分区】
Partition number (1-4): 1【分区号码】
First cylinder (1-1305, default 1): +2G【分配大小】
Last cylinder, +cylinders or +size{K,M,G} (261-1305, default 1305): ^C
[root@lxglinux ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x6003c314.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p【在屏幕上输出分区信息】
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6003c314
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux【可以看到增加了一个主分区】
Command (m for help): n【再增加】
Command action
e extended
p primary partition (1-4)
e【增加扩展分区】
Partition number (1-4): 2
First cylinder (263-1305, default 263): 2【2不在范围内】
Value out of range.
First cylinder (263-1305, default 263): 263
Last cylinder, +cylinders or +size{K,M,G} (263-1305, default 1305): +5G
Command (m for help): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6003c314
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
/dev/sdb2 263 916 5253255 5 Extended【可以看到增加了一个扩展分区】
Command (m for help): l【此命令可以列出第五列数字代表什么意思,Id,83,5】
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l【此时可以增加逻辑分区】
First cylinder (263-916, default 263):
Using default value 263
Last cylinder, +cylinders or +size{K,M,G} (263-916, default 916): +2g
Unsupported suffix: 'g'.
Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
2^N: K (KibiByte), M (MebiByte), G (GibiByte)
Last cylinder, +cylinders or +size{K,M,G} (263-916, default 916): +2G
Command (m for help): p【打印出,输出分区信息】
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6003c314
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux【主分区】
/dev/sdb2 263 916 5253255 5 Extended【扩展分区】
/dev/sdb5 263 524 2104483+ 83 Linux【逻辑分区,从扩展分区分出来】
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
注意各个分区的start 和 end 数字可以判断是主分区和扩展分区,
主分区是从1开始,sdb1是主分区
sdb2编号范围是263---916扩展分区
sdb3编号范围是263---524可以看出是从扩展分区分出来的逻辑分区
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Command (m for help): w【完成,保存并退出】
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
=======================================================================
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@上面分区完毕,接下来是格式化@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
两个命令 mkfs.
mk2fs
[root@lxglinux ~]# mkfs.【Tab补全,看支持哪些格式】
mkfs.cramfs mkfs.ext3 mkfs.ext4dev mkfs.vfat
mkfs.ext2 mkfs.ext4 mkfs.msdos
[root@lxglinux ~]# mkfs.
==========================================================================
[root@lxglinux ~]# mkfs.ext4 /dev/sdb5 【把sdb5格式化成ext4的格式】
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)【块的大小为4k】
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 526120 blocks 【iNode数和块数】
26306 blocks (5.00%) reserved for the super user【百分之5的块被保留,当磁盘空间占满此部分留
第一个数据块=0 给superuser进行一些操作】
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@lxglinux ~]#
===========================================================================
也可以用mke2fs命令来格式化,此命令选项多可修改参数多,功能相较mkfs也较强,
如下实例格式化sdb1
[root@lxglinux ~]# mke2fs -t ext4 -b 2048 -m 3 -L lxg /dev/sdb1【将sdb1格式化成ext4的格式
mke2fs 1.41.12 (17-May-2010) 块大小为2048k,块保留3%,标签/盘名为lxg】
文件系统标签=lxg
操作系统:Linux
块大小=2048 (log=1)
分块大小=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131560 inodes, 1052240 blocks
31567 blocks (3.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=538968064
65 block groups
16384 blocks per group, 16384 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@lxglinux ~]#
========================================================================================