虛擬化環境中,我們經常會遇到需要增加磁盤容量的情況,通常有兩種方式,第一種是添加一塊新的硬盤,另一種是擴容原有磁盤,以下是添加新磁盤至linux系統的操作規范。注:具體磁盤信息可能有所不同。
##查看新增加磁盤/dev/sdb的信息
[root@CentOS7 ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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
##在新磁盤/dev/sdb上創建分區
[root@CentOS7 ~]# 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 0x8c60b336.
Command (m for help): n ##新建分區
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p ##主分區
Partition number (1-4, default 1): ##保持默認
First sector (2048-10485759, default 2048): ##保持默認
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): +100M ##磁盤分區大小為100MB
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): w ##寫入分區信息
The partition table has been altered!
Using default value 2048
Calling ioctl() to re-read partition table.
Syncing disks.
[root@CentOS7 ~]# fdisk -l /dev/sdb ##再次查看/dev/sdb的信息,此時應該有新增的一個分區/dev/sdb1
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x8c60b336
Device Boot Start End Blocks Id System
/dev/sdb1 2048 206847 102400 83 Linux
[root@CentOS7 ~]# blkid /dev/sdb1 ##查看分區信息,因為此時并沒有格式化,所以此處無任何顯示
[root@CentOS7 ~]# mkfs -t ext4 /dev/sdb1 ##格式化分區/dev/sdb1,格式為ext4
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@CentOS7 ~]# blkid /dev/sdb1 ##再次查看分區信息,此時已經有磁盤ID和分區類型
/dev/sdb1: UUID="a7a1bc0d-eddd-46e8-8b06-27b41b287424" TYPE="ext4"
[root@CentOS7 ~]# mkdir /Data ##創建新的數據掛載點
[root@CentOS7 ~]# mount /dev/sdb1 /Data/ ##掛載新分區/dev/sdb1至新的掛載點
[root@CentOS7 ~]# mount ##查看現在系統的掛載信息
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
……
/dev/sdb1 on /Data type ext4 (rw,relatime,seclabel,data=ordered) ##已經成功掛載
原創文章,作者:Net24-仙鶴,如若轉載,請注明出處:http://www.www58058.com/58901