标签:physical minimum support 信息
20141016
用parted对磁盘进行分区
对大于2T的磁盘无法用fdisk进行管理,需要用parted来进行分区。
对于gpt磁盘,用fdisk -l显示不出磁盘分区信息。
[root@back-hp /]# fdisk -l
WARNING: GPT (GUID Partition Table) detected on ‘/dev/sda‘! The util fdisk doesn‘t support GPT. Use GNU Parted.
Disk /dev/sda: 11999.1 GB, 11999064883200 bytes
255 heads, 63 sectors/track, 1458803 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
Device Boot Start End Blocks Id System
/dev/sda1 1 267350 2147483647+ ee GPT
可以使用parted来查看详细分区信息。
[root@back-hp /]# parted /dev/sda
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
(parted) p
Model: DELL PERC H710 (scsi)
Disk /dev/sda: 12.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 211MB 210MB ext4 boot
2 211MB 108GB 107GB ext4
3 108GB 142GB 34.4GB linux-swap(v1)
用parted对大磁盘进行分区,下面我们新建一个5T的磁盘
[root@back-hp /]# parted /dev/sda
(parted) mkpart
Partition name? []? backup <--分区名
File system type? [ext2]? ext4 <--分区格式
Start? 142GB <--起始位置
End? 5262GB <--结束位置
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.
(parted) p
Model: DELL PERC H710 (scsi)
Disk /dev/sda: 12.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 211MB 210MB ext4 boot
2 211MB 108GB 107GB ext4
3 108GB 142GB 34.4GB linux-swap(v1)
4 142GB 5262GB 5120GB backup
(parted) q
在分区完后,还需要让系统识别出磁盘分区表的变化。
传统的partprobe命令已经不太好用。会提示磁盘正在使用,无法重新加载分区表
[root@back-hp /]# 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.
在此时,系统是检测不到sda4分区的
[root@back-hp /]# ls /dev/sda*
sda sda1 sda2 sda3
这时可以用partx -a 命令来使系统重新加载分区表
[root@back-hp /]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
再次查看就能看到新增的sda4分区了
[root@back-hp /]# ls /dev/sda*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4
分区完成后,还需要对磁盘进行格式化
[root@back-hp /]# mkfs.ext4 /dev/sda4
如果我们需要删除分区,可以用rm number来删除指定分区
[root@back-hp /]# parted
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
(parted) p
Model: DELL PERC H710 (scsi)
Disk /dev/sda: 12.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 211MB 210MB ext4 boot
2 211MB 108GB 107GB ext4
3 108GB 142GB 34.4GB linux-swap(v1)
4 142GB 5142GB 5000GB ext4 primary
(parted) rm 4
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.
(parted) p
Model: DELL PERC H710 (scsi)
Disk /dev/sda: 12.0TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 211MB 210MB ext4 boot
2 211MB 108GB 107GB ext4
3 108GB 142GB 34.4GB linux-swap(v1)
(parted) quit
Information: You may need to update /etc/fstab.
删除后,需要更新分区表来让系统知道已经删除了分区
[root@back-hp /]# partx -d --nr 4 /dev/sda
[root@back-hp /]# ls /dev/sda*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda3
本文出自 “小子无名” 博客,请务必保留此出处http://linuxroad.blog.51cto.com/765922/1565191
标签:physical minimum support 信息
原文地址:http://linuxroad.blog.51cto.com/765922/1565191