真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Linux命令之fdisk

fdisk

成都創(chuàng)新互聯(lián)專注于江西網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供江西營(yíng)銷型網(wǎng)站建設(shè),江西網(wǎng)站制作、江西網(wǎng)頁(yè)設(shè)計(jì)、江西網(wǎng)站官網(wǎng)定制、微信平臺(tái)小程序開(kāi)發(fā)服務(wù),打造江西網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供江西網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

fdisk [選項(xiàng)]   改變分區(qū)表 

fdisk [選項(xiàng)] –l   列出所有分區(qū)表

fdisk –s   以分區(qū)塊為單位,給出指定分區(qū)的大小

這是一個(gè)創(chuàng)建和維護(hù)分區(qū)的命令,兼容DOS類型的分區(qū)表、BSD或SUN類型的磁盤列表。 注意fdisk不支持2T以上的硬盤分區(qū),此時(shí)需要使用gdisk。

相關(guān)了解:

磁頭數(shù)(Heads)表示硬盤有幾個(gè)磁頭,也就是有幾面盤片,一個(gè)硬盤最多有255個(gè)磁頭

柱面數(shù)(Cylinders)表示硬盤每面盤片上有幾條磁道

扇區(qū)數(shù)(Sectors)表示每條磁道上有幾個(gè)扇區(qū),每條磁道最多有63個(gè)扇區(qū)

(1).選項(xiàng)

1
2
3
4
5
6
-b < size >  指定扇區(qū)大?。?12,1024,2048或4096 B)
-c  關(guān)閉DOS兼容模式
-u < size >  以扇區(qū)編號(hào)取代柱面編號(hào)來(lái)表示每個(gè)分區(qū)的起始地址,一般與-l選項(xiàng)聯(lián)合使用
-C < number >  指定柱面編號(hào)
-H < number >  指定磁頭編號(hào)
-S < number >  指定磁道扇區(qū)編號(hào)

(2).菜單操作說(shuō)明:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
a 設(shè)置可引導(dǎo)標(biāo)記(活動(dòng)分區(qū)/引導(dǎo)分區(qū)之間切換)
b 編輯BSD磁盤標(biāo)簽
c 設(shè)置DOS操作系統(tǒng)兼容標(biāo)記(兼容/不兼容之間切換)
d 刪除一個(gè)分區(qū)
l 顯示已知的分區(qū)類型,其中82為L(zhǎng)inux swap分區(qū),83為L(zhǎng)inux分區(qū)
m 顯示幫助信息
n 增加一個(gè)新的分區(qū)
o 創(chuàng)建一個(gè)新的空白的DOS分區(qū)表
p 顯示磁盤當(dāng)前的分區(qū)表
q 退出fdisk程序,不保存任何修改
s 創(chuàng)建一個(gè)新的空白的Sun磁盤標(biāo)簽
t 改變一個(gè)分區(qū)的系統(tǒng)ID,就是改變分區(qū)類型(比如把Linux Swap分區(qū)改為L(zhǎng)inux分區(qū))
u 改變顯示或輸入單位
v 驗(yàn)證磁盤分區(qū)表
w 將分區(qū)表寫入磁盤并退出(保存并退出)
x 額外功能(專家級(jí))

(3).擴(kuò)展

sda和hda的區(qū)別

1
2
3
4
sd代表的是SCSI,SATA接口硬盤
hd代表IDE接口的硬盤
sda和hda最后面的a都代表的是第一塊硬盤
sda1和hda1則代表的是該硬盤的第一分區(qū)

(4).實(shí)例

1).使用-l選項(xiàng),列出所有分區(qū)表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*盤/dev/sda:107.4G,107374182400字節(jié)(B),255個(gè)磁頭,63個(gè)扇區(qū),13054柱面(磁道)
* 1單位=16065柱面(磁道)*512=8225280字節(jié)(B)
* 扇區(qū)大?。ㄟ壿?物理):512字節(jié)(B)/512字節(jié)(B)
*輸入/輸出大?。ㄗ钚?最佳):512字節(jié)(B)/512字節(jié)(B)
*磁盤標(biāo)識(shí):0x00079700
*/
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x00079700
 
/*設(shè)備     啟動(dòng)標(biāo)識(shí)  開(kāi)始位置 結(jié)束位置  分區(qū)塊的大小  分區(qū)ID  系統(tǒng)(分區(qū)類型) 
* /dev/sda1  *     1     64     512000     83    Linux
* 分區(qū)1不以柱面邊界結(jié)束
* /dev/sda2        64    13055   104344576   8e    Linux LVM
*/
    Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end  on  cylinder boundary.
/dev/sda2              64       13055   104344576   8e  Linux LVM
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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
 
Disk /dev/mapper/vg_centos6-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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
 
Disk /dev/mapper/vg_centos6-lv_swap: 4194 MB, 4194304000 bytes
255 heads, 63 sectors/track, 509 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
 
Disk /dev/mapper/vg_centos6-lv_home: 49.0 GB, 48964304896 bytes
255 heads, 63 sectors/track, 5952 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

2).使用-l和-u選項(xiàng),用扇區(qū)編號(hào)取代柱面編號(hào)顯示所有分區(qū)表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00079700
 
    Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2         1026048   209715199   104344576   8e  Linux LVM
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Disk /dev/mapper/vg_centos6-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Disk /dev/mapper/vg_centos6-lv_swap: 4194 MB, 4194304000 bytes
255 heads, 63 sectors/track, 509 cylinders, total 8192000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
Disk /dev/mapper/vg_centos6-lv_home: 49.0 GB, 48964304896 bytes
255 heads, 63 sectors/track, 5952 cylinders, total 95633408 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

3).你們也看到了,我的/dev/sdb還沒(méi)有開(kāi)始使用,下面就用這個(gè)硬盤簡(jiǎn)單的演示下fdisk主要用到的操作菜單

1.在操作菜單下,創(chuàng)建一個(gè)新的分區(qū)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
[root@CentOS6 桌面]# 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 0xe8517189.
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): n
Command action
    e   extended             //擴(kuò)展分區(qū),創(chuàng)建擴(kuò)展分區(qū)會(huì)占用一個(gè)主分區(qū),并且只有創(chuàng)建擴(kuò)展分區(qū)后才能創(chuàng)建邏輯分區(qū)
    p   primary partition (1-4)    //主分區(qū),最多創(chuàng)建4個(gè)
e
Partition number (1-4): 1
First cylinder (1-2610,  default  1):    //起始柱面,默認(rèn)為1
Using  default  value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610,  default  2610):    //終止柱面,默認(rèn)為最后一個(gè)數(shù)
Using  default  value 2610
 
Command (m  for  help): n
Command action
    l   logical (5 or over)     //邏輯分區(qū)
    p   primary partition (1-4)   //主分區(qū)
l
First cylinder (1-2610,  default  1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610,  default  2610): +10G   //終止柱面不僅可以用柱面數(shù)表示,還可以用+[數(shù)值][單位]的格式表示
 
Command (m  for  help): n
Command action
    l   logical (5 or over)
    p   primary partition (1-4)
l
First cylinder (1307-2610,  default  1307):
Using  default  value 1307
Last cylinder, +cylinders or +size{K,M,G} (1307-2610,  default  2610):
Using  default  value 2610
 
Command (m  for  help): p
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xe8517189
 
    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+   5  Extended
/dev/sdb5               1        1306    10490382   83  Linux
/dev/sdb6            1307        2610    10474348+  83  Linux
 
Command (m  for  help):  w       //寫入磁盤,保存并退出,否則之前的操作都無(wú)效。如果不想寫入磁盤就使用q
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

2.在操作菜單下,刪除 一個(gè)分區(qū)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[root@CentOS6 桌面]# fdisk /dev/sdb
 
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: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xe8517189
 
    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+   5  Extended
/dev/sdb5               1        1306    10490382   83  Linux
/dev/sdb6            1307        2610    10474348+  83  Linux
 
Command (m for help): d
Partition number (1-6): 6  //這里輸入的始分區(qū)編號(hào),如果刪除擴(kuò)展分區(qū),那擴(kuò)展分區(qū)下的邏輯分區(qū)也會(huì)被刪除
 
Command (m for help): p
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xe8517189
 
    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+   5  Extended
/dev/sdb5               1        1306    10490382   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

   3.在操作菜單下,修改分區(qū)類型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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): t
Partition number (1-5): 5  //操作哪一個(gè)分區(qū)
Hex code (type L to list codes): L  //這里會(huì)提示你使用L查看類型列表
 
  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
Hex code (type L to list codes): b
Changed system type of partition 5 to b (W95 FAT32)
 
Command (m for help): p  //可以看到由原來(lái)的Linux改成了W95 FAT32
 
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xe8517189
 
    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+   5  Extended
/dev/sdb5               1        1306    10490382    b  W95 FAT32
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

4).對(duì)正在使用的磁盤,再次進(jìn)行分區(qū)時(shí)會(huì)出現(xiàn)以下提示

1
2
3
WARNING: Re-reading the partition table failed with error 16: 設(shè)備或資源忙.
The kernel still uses the old table. The  new  table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)

注意此時(shí)分區(qū)并不會(huì)立刻生效,可以重啟系統(tǒng),也可以使用提示的命令partprobe或kpartx。

  下面展示完整情況內(nèi)容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[root@xuexi ~]# fdisk /dev/sdb
歡迎使用 fdisk (util-linux 2.23.2)。
 
更改將停留在內(nèi)存中,直到您決定將更改寫入磁盤。
使用寫入命令前請(qǐng)三思。
 
命令(輸入 m 獲取幫助):n   //新建分區(qū)
Partition type:
    p   primary (1 primary, 0 extended, 3 free)
    e   extended
Select ( default  p): p   //創(chuàng)建主分區(qū)
分區(qū)號(hào) (2-4,默認(rèn) 2):
起始 扇區(qū) (2099200-4194303,默認(rèn)為 2099200):
將使用默認(rèn)值 2099200
Last 扇區(qū), +扇區(qū) or +size{K,M,G} (2099200-4194303,默認(rèn)為 4194303):
將使用默認(rèn)值 4194303
分區(qū) 2 已設(shè)置為 Linux 類型,大小設(shè)為 1023 MiB
 
命令(輸入 m 獲取幫助):w   //寫入磁盤
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: Re-reading the partition table failed with error 16: 設(shè)備或資源忙.
The kernel still uses the old table. The  new  table will be used at
the next reboot or after you run  partprobe(8) or kpartx(8)
正在同步磁盤。
[root@xuexi ~]# ls /dev/sdb*
/dev/sdb  /dev/sdb1
[root@xuexi ~]# partprobe /dev/sdb   //通知操作系統(tǒng)分區(qū)表已更改
[root@xuexi ~]# ls /dev/sdb*
/dev/sdb  /dev/sdb1  /dev/sdb2

   注意:能reboot重啟最好重啟,不行再使用命令更新

 注意:其實(shí)partprobe是更新分區(qū)表,但kpartx其實(shí)是更新分區(qū)映射(涉及到了鏡像文件,例如.img文件),不過(guò)還有partx可以用來(lái)更新分區(qū)表(-a選項(xiàng)新增,-d選項(xiàng)刪除,-u選項(xiàng)更新(好像不能在刪除時(shí)使用))。


新聞名稱:Linux命令之fdisk
轉(zhuǎn)載源于:http://weahome.cn/article/ihdigs.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部