一温鸽、分區(qū)類型
兩種分區(qū)方式: MBR, GPT
MBR:Master Boot Record手负, 1982年涤垫, 使用32位表示扇區(qū)數(shù), 分區(qū)不超過2T
-
0磁道0扇區(qū): 512bytes
- 446bytes: boot loader 系統(tǒng)啟動(dòng)引導(dǎo)程序
- 64bytes:分區(qū)表竟终,16bytes標(biāo)識(shí)一個(gè)分區(qū)蝠猬,因此最多只能劃分主分或者3個(gè)主分區(qū),一個(gè)擴(kuò)展分區(qū)
- 2bytes:55AA標(biāo)志著已劃分分區(qū)
GPT:
查看分區(qū)命令:
- cat /proc/partitions
- ls /dev/s*
- lsblk
- fdisk -l
fdisk 查看的是磁盤统捶,其他三條命令看的是內(nèi)存榆芦。
掃描新硬盤
當(dāng)添加新硬盤后柄粹,不重啟系統(tǒng),使用以下命令:
echo "- - -" > /sys/class/scsi_host/host0/scan
二匆绣、管理分區(qū)
1驻右、MBR分區(qū):fdisk
SYNOPSIS fdisk [-uc] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
使用fdisk命令對(duì)硬盤/dev/sdc劃分分區(qū):
(1)fdisk /dev/sdc
管理硬盤sdc,進(jìn)入子命令模式
[root@CentOS6 ~]#fdisk /dev/sdc
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):
(2)輸入子命令m
崎淳,查看命令幫助
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)
(3)輸入子命令n
堪夭,新增分區(qū)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
(4)選擇創(chuàng)建主分區(qū),輸入"p
"和分區(qū)號(hào)“1
”
p
Partition number (1-4): 1
(5)輸入1
和+10G
選擇分區(qū)從硬盤第1個(gè)柱面開始拣凹,以及分區(qū)大小為10G
First cylinder (1-13054, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): +10G
(6)輸入子命令w
森爽,保存退出
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
刪除、修改等操作咐鹤,可以參考上面第二步的幫助拗秘。
刪除主分區(qū)圣絮,不會(huì)影響其他分區(qū)祈惶。刪除邏輯分區(qū),后面的邏輯分區(qū)名會(huì)依次向前變更扮匠。
(2)GPT分區(qū):gdisk
SYNOPSIS gdisk [ -l ] device
gdisk命令用于管理gpt分區(qū)捧请,使用方式類似于gdisk:
[root@CentOS6 ~]#gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help):
···略
3、高級(jí)分區(qū)操作:parted
當(dāng)我們想更換分區(qū)類型時(shí)棒搜,可以使用parted命令疹蛉。
這里我們用一個(gè)GPT分區(qū)的硬盤sdc,更換為MBR分區(qū):
(1)fdisk
查看硬盤信息力麸,可以看到系統(tǒng)會(huì)提示該硬盤式gpt分區(qū)可款,建議我們使用parted命令。
[root@CentOS6 ~]#fdisk -l /dev/sdc
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdc: 107.4 GB, 107374182400 bytes
256 heads, 63 sectors/track, 13003 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdc1 1 13004 104857599+ ee GPT
(2)使用parted
命令更換分區(qū)類型
[root@CentOS6 ~]#parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? msdos
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted)
(parted) q
Information: You may need to update /etc/fstab.
mbr轉(zhuǎn)換成gpt也是類似的操作克蚂。
當(dāng)然闺鲸,也可以直接用gdisk命令把mbr分區(qū)換成gpt分區(qū),這里不多說了埃叭。