1.磁碟分區命令
1.fdisk 支援mbr分區格式,2tb以內磁碟
2.gdisk 支援mbr,gpt
3.parted fdisk升級版(僅支援gpt格式)
2.fdisk
1.參看磁碟分區資訊
fdisk -l
2.用fdisk進行分區
fdisk /dev/sdb
[root@JYC ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
# 你當前的修改都保存在記憶體中,知道你決定保存他們
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
# 磁碟當前沒有磁碟分區列表
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xbcb9ea13.
Command (m for help):
# 一些常用命令
n new 創建磁碟分區 partition(分區)
p print 顯示分區資訊
d delete 刪除磁碟分區
q 退出不保存
w 保存並退出
# 創建一個磁碟分區
Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: dos
Disk identifier: 0xbcb9ea13
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary(主分區) (0 primary, 0 extended, 4 free)
e extended(擴展分區)
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +200M
Partition 1 of type Linux and of size 200 MiB is set
Command (m for help): P
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: dos
Disk identifier: 0xbcb9ea13
Device Boot Start End Blocks Id System
/dev/sdb1 2048 411647 204800 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
註:期間若有輸入錯誤需要取消則 ctrl+u
3.格式化文件系統
mkfs.xfs /dev/sdb1
[root@JYC ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=12800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=51200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
4.掛載
mount /dev/sdb1 /mnt
[root@JYC ~]# mount /dev/sdb1 /mnt
[root@JYC ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 512M 0 part /boot
└─sda2 8:2 0 99.5G 0 part
└─centos-root 253:0 0 99.5G 0 lvm /
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 200M 0 part /mnt
sr0 11:0 1 4.4G 0 rom