[root@linux-node2 ~]# parted /dev/sdb #對(duì)sdb分區(qū) GNU Parted 3.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p#print 打印 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 3221MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags (parted) mklabel#定義分區(qū)表類型,msdos是MBR分區(qū)表,可以用這個(gè)方法將硬盤轉(zhuǎn)換成MBR New disk label type? gpt #分區(qū)表定義為gpt,之前是mbr分區(qū),所以會(huì)有下面的提醒 Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes#警告sdb之前的內(nèi)容將會(huì)丟失 (parted) mkpart#創(chuàng)建分區(qū) Partition name? []? sdb1#分區(qū)表名稱 File system type? [ext2]? ext4#文件系統(tǒng)類型 Start? 0#起始扇區(qū) End? 1g#結(jié)束扇區(qū) Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i#警告內(nèi)容將刪除,選擇忽略 (parted) p #print打印分區(qū)信息 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 3221MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 117.4kB 1000MB 1000MB ext4 sdb1 (parted) rm1#刪除分區(qū)1 (parted) mkpart primary 0 1g#創(chuàng)建主分區(qū)1gb Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i#警告內(nèi)容會(huì)被刪除,選擇忽略 (parted) mkpart primary 1g 3g #創(chuàng)建主分區(qū)2gb (parted) p #打印 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 3221MB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 117.4kB 1000MB 1000MB ext4 primary 2 1000MB 3220MB 2220MB ext4 primary (parted) q#退出 Information: You may need to update /etc/fstab. [root@linux-node2 ~]# fdisk -l /dev/sdb #查看/dev/sdb分區(qū) WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/sdb: 3221 MB, 3221225472 bytes, 6291456 sectors Units = sectors of 1 * 512=512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt # Start End Size Type Name 1341953125953.7M Microsoft basic primary 2195379262894072.1G Microsoft basic primary [root@linux-node2 ~]# mkfs.ext4 /dev/sdb1 #格式化sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096(log=2) Fragment size=4096(log=2) Stride=0 blocks, Stripe width=0 blocks 61056 inodes, 244136 blocks 12206 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=251658240 8 block groups 32768 blocks per group, 32768 fragments per group 7632 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done [root@linux-node2 ~]# blkid /dev/sdb1 #查看sdb1的UUID /dev/sdb1: UUID="612067e2-12ca-4410-9ab8-682b22c0da87"TYPE="ext4"PARTLABEL="primary"PARTUUID="ae6af195-c535-4380-8a8f-e96c73730d96" [root@linux-node2 ~]# echo 'UUID=612067e2-12ca-4410-9ab8-682b22c0da87 /data ext4 defaults 0 0' >> /etc/fstab #實(shí)現(xiàn)開(kāi)機(jī)自動(dòng)掛載