码迷,mamicode.com
首页 > 系统相关 > 详细

linux 磁盘分区 fdisk

时间:2016-06-27 00:12:07      阅读:791      评论:0      收藏:0      [点我收藏+]

标签:linux   it   运维   

linux磁盘分区:fdisk(小于2T的分区工具)


[root@zyl ~]# fdisk -l            #####查看磁盘空间 


Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x00061f64


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         307     2252800   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             307        1959    13270016   83  Linux


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x00000000


[root@zyl ~]# fdisk --help                #####查看帮助

fdisk: invalid option -- ‘-‘


Usage:

 fdisk [options] <disk>    change partition table

 fdisk [options] -l <disk> list partition table(s)

 fdisk -s <partition>      give partition size(s) in blocks


Options:

 -b <size>                 sector size (512, 1024, 2048 or 4096)

 -c                        switch off DOS-compatible mode

 -h                        print help

 -u <size>                 give sizes in sectors instead of cylinders

 -v                        print version

 -C <number>               specify the number of cylinders

 -H <number>               specify the number of heads

 -S <number>               specify the number of sectors per track


[root@zyl ~]# fdisk -l /dev/sdb       #####查看/dev/sdb磁盘空间


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x00000000


[root@zyl ~]# fdisk /dev/sdb #####查看/dev/sdb磁盘空间

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x4f8513b3.

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                      ##### 输入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-130, default 1):           #####默认为1

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x4f8513b3


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          14      112423+  83  Linux


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)

e

Partition number (1-4): 1

Partition 1 is already defined.  Delete it before re-adding it.#分区1已经定义。删除它之前重新添加它


Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

e                                                  #####新建扩展分区

Partition number (1-4): 2

First cylinder (15-130, default 15): 15

Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): 

Using default value 130


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x4f8513b3


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          14      112423+  83  Linux

/dev/sdb2              15         130      931770    5  Extended


Command (m for help): n

Command action

   l   logical (5 or over)                        #####分区类型  逻辑分区 

   p   primary partition (1-4)

p

Partition number (1-4): 2                         #####此仅为测试

Partition 2 is already defined.  Delete it before re-adding it.


Command (m for help): n

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

p

Partition number (1-4): 4                        #####此仅为测试

No free sectors available                        #####发现没有空间。即创建逻辑分区


Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First cylinder (15-130, default 15): 

Using default value 15

Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400M

Unsupported suffix+400M‘.

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} (15-130, default 130): +400M


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x4f8513b3


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          14      112423+  83  Linux

/dev/sdb2              15         130      931770    5  Extended

/dev/sdb5              15          66      417658+  83  Linux


Command (m for help): n

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First cylinder (67-130, default 67): 

Using default value 67

Last cylinder, +cylinders or +size{K,M,G} (67-130, default 130): 

Using default value 130


Command (m for help): p


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x4f8513b3


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          14      112423+  83  Linux

/dev/sdb2              15         130      931770    5  Extended

/dev/sdb5              15          66      417658+  83  Linux

/dev/sdb6              67         130      514048+  83  Linux


[root@zyl ~]# fdisk -l


Disk /dev/sda: 16.1 GB, 16106127360 bytes

255 heads, 63 sectors/track, 1958 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: 0x00061f64


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         307     2252800   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             307        1959    13270016   83  Linux


Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 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: 0x4f8513b3


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          14      112423+  83  Linux

/dev/sdb2              15         130      931770    5  Extended

/dev/sdb5              15          66      417658+  83  Linux

/dev/sdb6              67         130      514048+  83  Linux  

[root@zyl ~]# partprobe                                  #####强制内核重新查找一次分区表

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

[root@zyl /]# ll /dev/sd*

brw-rw----. 1 root disk 8,  0 Jun 25  2016 /dev/sda

brw-rw----. 1 root disk 8,  1 Jun 25 01:58 /dev/sda1

brw-rw----. 1 root disk 8,  2 Jun 25  2016 /dev/sda2

brw-rw----. 1 root disk 8,  3 Jun 25  2016 /dev/sda3

brw-rw----. 1 root disk 8, 16 Jun 25 02:16 /dev/sdb

brw-rw----. 1 root disk 8, 17 Jun 25 02:16 /dev/sdb1

brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2

brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5

brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6


[root@zyl /]# mkfs.ext4 /dev/sdb1                        #####格式化/dev/sdb1  

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

28112 inodes, 112420 blocks

5621 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67371008

14 block groups

8192 blocks per group, 8192 fragments per group

2008 inodes per group

Superblock backups stored on blocks: 

        8193, 24577, 40961, 57345, 73729


Writing inode tables: done                            

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 21 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@zyl /]# 

[root@zyl /]# tune2fs -c -1 /dev/sdb1          #####调整和查看/dev/sdb1文件系统的参数

tune2fs 1.41.12 (17-May-2010)

Setting maximal mount count to -1

[root@zyl /]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        13G  1.6G   11G  14% /

tmpfs           935M     0  935M   0% /dev/shm

/dev/sda1       194M   34M  151M  19% /boot

[root@zyl /]# 

[root@zyl /]# 

[root@zyl /]# ls /dev/sd*

/dev/sda   /dev/sda2  /dev/sdb   /dev/sdb2  /dev/sdb6

/dev/sda1  /dev/sda3  /dev/sdb1  /dev/sdb5

[root@zyl /]# ll /dev/sd*

brw-rw----. 1 root disk 8,  0 Jun 25  2016 /dev/sda

brw-rw----. 1 root disk 8,  1 Jun 25 01:58 /dev/sda1

brw-rw----. 1 root disk 8,  2 Jun 25  2016 /dev/sda2

brw-rw----. 1 root disk 8,  3 Jun 25  2016 /dev/sda3

brw-rw----. 1 root disk 8, 16 Jun 25 02:24 /dev/sdb

brw-rw----. 1 root disk 8, 17 Jun 25 02:28 /dev/sdb1

brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2

brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5

brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6

[root@zyl /]# mount /dev/sd

sda   sda1  sda2  sda3  sdb   sdb1  sdb2  sdb5  sdb6  

[root@zyl /]# mount /dev/sdb1 /mnt

[root@zyl /]# touch /mnt/dddd

[root@zyl /]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        13G  1.6G   11G  14% /

tmpfs           935M     0  935M   0% /dev/shm

/dev/sda1       194M   34M  151M  19% /boot

/dev/sdb1       107M  5.6M   96M   6% /mnt

[root@zyl /]# parted /dev/sdb

GNU Parted 2.1

Using /dev/sdb

Welcome to GNU Parted! Type ‘help‘ to view a list of commands.


本文出自 “10900500” 博客,请务必保留此出处http://10910500.blog.51cto.com/10900500/1793063

linux 磁盘分区 fdisk

标签:linux   it   运维   

原文地址:http://10910500.blog.51cto.com/10900500/1793063

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!