parted---磁碟分割槽
阿新 • • 發佈:2018-11-28
parted命令是由GNU組織開發的一款功能強大的磁碟分割槽和分割槽大小調整工具,與fdisk不同,它支援調整分割槽的大小。作為一種設計用於Linux的工具,它沒有構建成處理與fdisk關聯的多種分割槽型別,但是,它可以處理最常見的分割槽格式,包括:ext2、ext3、fat16、fat32、NTFS、ReiserFS、JFS、XFS、UFS、HFS以及Linux交換分割槽。
語法
parted(選項)(引數)
選項
-h:顯示幫助資訊; -i:互動式模式; -s:指令碼模式,不提示使用者; -v:顯示版本號。
引數
- 裝置:指定要分割槽的硬碟所對應的裝置檔案;
- 命令:要執行的parted命令。
例項
從序列技術出現以來,越來越多使用者選擇使用大容量的SATA硬碟建立磁碟陣列;特別是MD1000/MD3000,很輕易就突破2T的LUN,故在此給大家一些指引。
紅帽企業 Linux 4 Update 4供對大於 2 terabytes(TB)的磁碟裝置的支援。
請參考以下操作步驟:
注:
- 綠色代表你需要使用的命令。
- 紅色代表你需要注意到的輸出資訊,在後續需要使用。
[[email protected] ~]# fdisk -l Disk /dev/sda: 35.8 GB, 35862976512 bytes 255 heads, 63 sectors/track, 4360 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocksid System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 144 1052257+ 82 Linux swap /dev/sda3 145 4360 33865020 83 Linux Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
[[email protected] ~]# parted /dev/sdb GNU Parted Copyright (C) 1998 - 2004 free Software Foundation, Inc. This program is free software, covered by the GNU General Public License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 使用/dev/sdb (parted)mklabel gpt (parted)print /dev/sdb的磁碟幾何結構:0.000-2048.000兆位元組 磁碟標籤型別:gpt Minor 起始點 終止點 檔案系統 名稱 標誌 (parted)mkpart primary 0 2048 <-----上面print顯示的數字 (parted)print /dev/sdb的磁碟幾何結構:0.000-2048.000兆位元組 磁碟標籤型別:gpt Minor 起始點 終止點 檔案系統 名稱 標誌 1 0.017 2047.983 (parted)quit
如果必要,不要忘記更新/etc/fstab
。
[[email protected] ~]# fdisk -l Disk /dev/sda: 35.8 GB, 35862976512 bytes 255 heads, 63 sectors/track, 4360 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 144 1052257+ 82 Linux swap /dev/sda3 145 4360 33865020 83 Linux WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 262 2097151+ ee EFI GPT Partition 1 has different physical/logical beginnings (non-Linux?): phys=(0, 0, 1) logical=(0,0, 2) Partition 1 has different physical/logical endings: phys=(1023, 254, 63) logical=(261, 21, 16)
[[email protected] ~]# mkfs.ext3 /dev/sdb1 mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 262144 inodes, 524279 blocks 26213 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] ~]# mount /dev/sdb1 /mnt [[email protected] ~]# df -h Filesystem 容量 已用 可用 已用% 掛載點 /dev/sda3 <?xml:namespace prefix = st1 />32G 2.6G 28G 9% / /dev/sda1 99M 12M 82M 13% /boot none 252M 0 252M 0% /dev/shm /dev/sdb1 2.0G 36M 1.9G 2% /mnt