用途描述
创建虚拟机时,分配的磁盘大小不足,需要添加新磁盘,本文讲解如何格式化与挂载新磁盘。
[root@localhost ~]# fdisk -l
将新增磁盘分区
[root@localhost ~]# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x51bcd817
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):
Using default value 1305
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):
Using default value 1305
Command (m for help): p
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x51bcd817
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 5 Extended
/dev/sdb5 1 1305 10482349+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
格式化分区 mkfs.xfs
[root@localhost /]# mkfs.xfs -f /dev/sdb5
meta-data=/dev/sdb5 isize=512 agcount=4, agsize=1310592 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=5242368, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost /]# blkid
/dev/sdb5: UUID="be74c126-1f74-4344-970e-c5148c922743" TYPE="ext4" LABEL="u01"
/dev/sda1: UUID="dc382e14-447e-41c9-9d10-919ffe41130f" TYPE="ext4"
/dev/sda2: UUID="VWKCsV-YZs4-odpP-gWc1-zGM0-HLvU-Y3jAOI" TYPE="LVM2_member"
/dev/sr0: LABEL="OL6.7 x86_64 Disc 1 20150728" TYPE="iso9660"
/dev/mapper/VolGroup-lv_root: UUID="949bfa0a-b903-434a-980f-deb80406c20c" TYPE="ext4"
/dev/mapper/VolGroup-lv_swap: UUID="705d3520-108f-4786-b733-8e85357caae0" TYPE="swap"
[root@localhost /]#
挂载分区
[root@localhost /]# mkdir /u01
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
35G 23G 12G 67% /
tmpfs 1.8G 0 1.8G 0% /dev/shm
/dev/sda1 477M 155M 293M 35% /boot
[root@localhost /]# mount /dev/sdb5 /u01
或者使用label挂载
[root@localhost /]# mount LABEL=u01 /u01
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
35G 23G 12G 67% /
tmpfs 1.8G 0 1.8G 0% /dev/shm
/dev/sda1 477M 155M 293M 35% /boot
/dev/sdb5 9.8G 23M 9.2G 1% /u01
开机启动
在最后一行添加一行
[root@localhost /]# vi /etc/fstab
/dev/sdb5 /u01 xfs defaults 0 0
重启验证
[root@localhost /]# reboot