parted

磁盤分區和分區大小調整工具

補充說明

parted命令 是由GNU組織開發的一款功能強大的磁盤分區和分區大小調整工具,與fdisk不同,它支持調整分區的大小。作爲一種設計用於Linux的工具,它沒有構建成處理與fdisk關聯的多種分區類型,但是,它可以處理最常見的分區格式,包括:ext2、ext3、fat16、fat32、NTFS、ReiserFS、JFS、XFS、UFS、HFS以及Linux交換分區。

語法

1parted(選項)(參數)

選項

1-h:顯示幫助信息;
2-i:交互式模式;
3-s:腳本模式,不提示用戶;
4-v:顯示版本號。

參數

  • 設備:指定要分區的硬盤所對應的設備文件;
  • 命令:要執行的parted命令。

實例

從串行技術出現以來,越來越多用戶選擇使用大容量的SATA硬盤創建磁盤陣列;特別是MD1000/MD3000,很輕易就突破2T的LUN,故在此給大家一些指引。

紅帽企業 Linux 4 Update 4供對大於 2 terabytes(TB)的磁盤設備的支持。

請參考以下操作步驟:

注:

  • 綠色代表你需要使用的命令。
  • 紅色代表你需要注意到的輸出信息,在後續需要使用。
 1[root@localhost ~]# fdisk -l
 2Disk /dev/sda: 35.8 GB, 35862976512 bytes
 3255 heads, 63 sectors/track, 4360 cylinders
 4Units = cylinders of 16065 * 512 = 8225280 bytes
 5   Device Boot      Start         End      Blocks   id  System
 6/dev/sda1   *           1          13      104391   83  Linux
 7/dev/sda2              14         144     1052257+  82  Linux swap
 8/dev/sda3             145        4360    33865020   83  Linux
 9Disk /dev/sdb: 2147 MB, 2147483648 bytes
10255 heads, 63 sectors/track, 261 cylinders
11Units = cylinders of 16065 * 512 = 8225280 bytes
12Disk /dev/sdb doesn't contain a valid partition table
 1[root@localhost ~]# parted /dev/sdb
 2GNU Parted Copyright (C) 1998 - 2004 free Software Foundation, Inc.
 3This program is free software, covered by the GNU General Public License.
 4This program is distributed in the hope that it will be useful, but WITHOUT ANY
 5WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 6PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 7使用/dev/sdb
 8(parted)mklabel gpt
 9(parted)print
10/dev/sdb的磁盤幾何結構:0.000-2048.000兆字節
11磁盤標籤類型:gpt
12Minor   起始點       終止點 文件系統   名稱                 標誌
13(parted)mkpart primary 0 2048  <-----上面print顯示的數字
14(parted)print
15/dev/sdb的磁盤幾何結構:0.000-2048.000兆字節
16磁盤標籤類型:gpt
17Minor   起始點       終止點 文件系統   名稱                 標誌
181          0.017   2047.983
19(parted)quit

如果必要,不要忘記更新/etc/fstab

 1[root@localhost ~]# fdisk -l
 2Disk /dev/sda: 35.8 GB, 35862976512 bytes
 3255 heads, 63 sectors/track, 4360 cylinders
 4Units = cylinders of 16065 * 512 = 8225280 bytes
 5   Device Boot      Start         End      Blocks   Id  System
 6/dev/sda1   *           1          13      104391   83  Linux
 7/dev/sda2              14         144     1052257+  82  Linux swap
 8/dev/sda3             145        4360    33865020   83  Linux
 9WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
10
11Disk /dev/sdb: 2147 MB, 2147483648 bytes
12255 heads, 63 sectors/track, 261 cylinders
13Units = cylinders of 16065 * 512 = 8225280 bytes
14   Device Boot      Start         End      Blocks   Id  System
15/dev/sdb1               1         262     2097151+  ee  EFI GPT
16Partition 1 has different physical/logical beginnings (non-Linux?):
17     phys=(0, 0, 1) logical=(0,0, 2)
18Partition 1 has different physical/logical endings:
19     phys=(1023, 254, 63) logical=(261, 21, 16)
 1[root@localhost ~]# mkfs.ext3 /dev/sdb1
 2mke2fs 1.35 (28-Feb-2004)
 3Filesystem label=
 4OS type: Linux
 5Block size=4096 (log=2)
 6Fragment size=4096 (log=2)
 7262144 inodes, 524279 blocks
 826213 blocks (5.00%) reserved for the super user
 9First data block=0
10Maximum filesystem blocks=536870912
1116 block groups
1232768 blocks per group, 32768 fragments per group
1316384 inodes per group
14Superblock backups stored on blocks:
15        32768, 98304, 163840, 229376, 294912
16Writing inode tables: done
17Creating journal (8192 blocks): done
18Writing superblocks and filesystem accounting information: done
19This filesystem will be automatically checked every 28 mounts or
20180 days, whichever comes first.  Use tune2fs -c or -i to override.
1[root@localhost ~]# mount /dev/sdb1 /mnt
2[root@localhost ~]# df -h
3Filesystem            容量  已用 可用 已用% 掛載點
4/dev/sda3              <?xml:namespace prefix = st1 />32G  2.6G   28G   9% /
5/dev/sda1              99M   12M   82M  13% /boot
6none                  252M     0  252M   0% /dev/shm
7/dev/sdb1             2.0G   36M  1.9G   2% /mnt

來源:https://github.com/jaywcjlove/linux-command

最後修改於: Wednesday, January 31, 2024

相關文章:

翻譯: