parted
查看需要处理的磁盘:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 894.3G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 893.1G 0 part
├─centos-root 253:0 0 809G 0 lvm /
├─centos-swap 253:1 0 4G 0 lvm [SWAP]
└─centos-home 253:2 0 80G 0 lvm /home
sdb 8:16 0 3.7T 0 disk //这个磁盘需要处理
$ sudo parted /dev/sdb //第 1步
(parted) mklabel gpt //第 2步
(parted) p //第3步,查看磁盘标签格式
Model: LSI Logical Volume (scsi)
Disk /dev/sdb: 4000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt //标签为gpt,设置成功。
Disk Flags:
Number Start End Size File system Name 标志
(parted) units s
(parted) mkpart 分区名称(例primary) 2048s 100% //第4步,创建1个主分区,磁盘起始位置为2048,即第一扇区;结束点为100,即最后一个扇区]
警告: The resulting partition is not properly aligned for best performance.
忽略/Ignore/放弃/Cancel? Ignore //第5步
(parted) p //查看分区是否OK
Model: LSI Logical Volume (scsi)
Disk /dev/sdb: 4000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 17.4kB 4000GB 4000GB primary
(parted) q //退出
信息: You may need to update /etc/fstab.
格式分区:
$ sudo mkfs -t ext4 /dev/sdb1
创建挂载目录:
sudo mkdir /data
查看磁盘的uuid:
sudo blkid|grep '/dev/sdb1'
/dev/sdb1: UUID="d0e0c766-1001-4bb8-a449-aa9fbba5e3c0" TYPE="ext4" PARTLABEL="primary" PARTUUID="82102673-a0f5-408d-bce6-642e2e3e6eda"
将UUID写入fstab里,实现开机自动挂载:
$ sudo echo 'UUID="d0e0c766-1001-4bb8-a449-aa9fbba5e3c0" /data ext4 defaults 0 0' >> /etc/fstab
挂载
sudo mount -a
结束。