Linux,centos6.5 磁盤如何分區和格式化

磁盤分區後必須要格式化後才能使用,如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 ~]#

========================================================================================


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章