1 | parted
|
2 | ===
|
3 |
|
4 | 磁盘分区和分区大小调整工具
|
5 |
|
6 | ## 补充说明
|
7 |
|
8 | **parted命令** 是由GNU组织开发的一款功能强大的磁盘分区和分区大小调整工具,与fdisk不同,它支持调整分区的大小。作为一种设计用于Linux的工具,它没有构建成处理与fdisk关联的多种分区类型,但是,它可以处理最常见的分区格式,包括:ext2、ext3、fat16、fat32、NTFS、ReiserFS、JFS、XFS、UFS、HFS以及Linux交换分区。
|
9 |
|
10 | ### 语法
|
11 |
|
12 | ```shell
|
13 | parted(选项)(参数)
|
14 | ```
|
15 |
|
16 | ### 选项
|
17 |
|
18 | ```shell
|
19 | -h:显示帮助信息;
|
20 | -i:交互式模式;
|
21 | -s:脚本模式,不提示用户;
|
22 | -v:显示版本号。
|
23 | ```
|
24 |
|
25 | ### 参数
|
26 |
|
27 | * 设备:指定要分区的硬盘所对应的设备文件;
|
28 | * 命令:要执行的parted命令。
|
29 |
|
30 | ### 实例
|
31 |
|
32 | 从串行技术出现以来,越来越多用户选择使用大容量的SATA硬盘创建磁盘阵列;特别是MD1000/MD3000,很轻易就突破2T的LUN,故在此给大家一些指引。
|
33 |
|
34 | 红帽企业 Linux 4 Update 4供对大于 2 terabytes(TB)的磁盘设备的支持。
|
35 |
|
36 | 请参考以下操作步骤:
|
37 |
|
38 | 注:
|
39 |
|
40 | * 绿色代表你需要使用的命令。
|
41 | * 红色代表你需要注意到的输出信息,在后续需要使用。
|
42 |
|
43 | ```shell
|
44 | [root@localhost ~]# fdisk -l
|
45 | Disk /dev/sda: 35.8 GB, 35862976512 bytes
|
46 | 255 heads, 63 sectors/track, 4360 cylinders
|
47 | Units = cylinders of 16065 * 512 = 8225280 bytes
|
48 | Device Boot Start End Blocks id System
|
49 | /dev/sda1 * 1 13 104391 83 Linux
|
50 | /dev/sda2 14 144 1052257+ 82 Linux swap
|
51 | /dev/sda3 145 4360 33865020 83 Linux
|
52 | Disk /dev/sdb: 2147 MB, 2147483648 bytes
|
53 | 255 heads, 63 sectors/track, 261 cylinders
|
54 | Units = cylinders of 16065 * 512 = 8225280 bytes
|
55 | Disk /dev/sdb doesn't contain a valid partition table
|
56 | ```
|
57 |
|
58 | ```shell
|
59 | [root@localhost ~]# parted /dev/sdb
|
60 | GNU Parted Copyright (C) 1998 - 2004 free Software Foundation, Inc.
|
61 | This program is free software, covered by the GNU General Public License.
|
62 | This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
63 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
64 | PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
65 | 使用/dev/sdb
|
66 | (parted)mklabel gpt
|
67 | (parted)print
|
68 | /dev/sdb的磁盘几何结构:0.000-2048.000兆字节
|
69 | 磁盘标签类型:gpt
|
70 | Minor 起始点 终止点 文件系统 名称 标志
|
71 | (parted)mkpart primary 0 2048 <-----上面print显示的数字
|
72 | (parted)print
|
73 | /dev/sdb的磁盘几何结构:0.000-2048.000兆字节
|
74 | 磁盘标签类型:gpt
|
75 | Minor 起始点 终止点 文件系统 名称 标志
|
76 | 1 0.017 2047.983
|
77 | (parted)quit
|
78 | ```
|
79 |
|
80 | 如果必要,不要忘记更新`/etc/fstab`。
|
81 |
|
82 | ```shell
|
83 | [root@localhost ~]# fdisk -l
|
84 | Disk /dev/sda: 35.8 GB, 35862976512 bytes
|
85 | 255 heads, 63 sectors/track, 4360 cylinders
|
86 | Units = cylinders of 16065 * 512 = 8225280 bytes
|
87 | Device Boot Start End Blocks Id System
|
88 | /dev/sda1 * 1 13 104391 83 Linux
|
89 | /dev/sda2 14 144 1052257+ 82 Linux swap
|
90 | /dev/sda3 145 4360 33865020 83 Linux
|
91 | WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
|
92 |
|
93 | Disk /dev/sdb: 2147 MB, 2147483648 bytes
|
94 | 255 heads, 63 sectors/track, 261 cylinders
|
95 | Units = cylinders of 16065 * 512 = 8225280 bytes
|
96 | Device Boot Start End Blocks Id System
|
97 | /dev/sdb1 1 262 2097151+ ee EFI GPT
|
98 | Partition 1 has different physical/logical beginnings (non-Linux?):
|
99 | phys=(0, 0, 1) logical=(0,0, 2)
|
100 | Partition 1 has different physical/logical endings:
|
101 | phys=(1023, 254, 63) logical=(261, 21, 16)
|
102 | ```
|
103 |
|
104 | ```shell
|
105 | [root@localhost ~]# mkfs.ext3 /dev/sdb1
|
106 | mke2fs 1.35 (28-Feb-2004)
|
107 | Filesystem label=
|
108 | OS type: Linux
|
109 | Block size=4096 (log=2)
|
110 | Fragment size=4096 (log=2)
|
111 | 262144 inodes, 524279 blocks
|
112 | 26213 blocks (5.00%) reserved for the super user
|
113 | First data block=0
|
114 | Maximum filesystem blocks=536870912
|
115 | 16 block groups
|
116 | 32768 blocks per group, 32768 fragments per group
|
117 | 16384 inodes per group
|
118 | Superblock backups stored on blocks:
|
119 | 32768, 98304, 163840, 229376, 294912
|
120 | Writing inode tables: done
|
121 | Creating journal (8192 blocks): done
|
122 | Writing superblocks and filesystem accounting information: done
|
123 | This filesystem will be automatically checked every 28 mounts or
|
124 | 180 days, whichever comes first. Use tune2fs -c or -i to override.
|
125 | ```
|
126 |
|
127 | ```shell
|
128 | [root@localhost ~]# mount /dev/sdb1 /mnt
|
129 | [root@localhost ~]# df -h
|
130 | Filesystem 容量 已用 可用 已用% 挂载点
|
131 | /dev/sda3 <?xml:namespace prefix = st1 />32G 2.6G 28G 9% /
|
132 | /dev/sda1 99M 12M 82M 13% /boot
|
133 | none 252M 0 252M 0% /dev/shm
|
134 | /dev/sdb1 2.0G 36M 1.9G 2% /mnt
|
135 | ```
|
136 |
|
137 |
|