Linux磁盘分区
查看磁盘[root@localhost ~]# fdisk -lDisk /dev/vda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (m...
·
- 查看磁盘
[root@localhost ~]# fdisk -l
Disk /dev/vda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x0009680e
Device Boot Start End Blocks Id System
/dev/vda1 2048 4194303 2096128 82 Linux swap / Solaris
/dev/vda2 * 4194304 56623103 26214400 83 Linux
- 初始化磁盘
[root@localhost ~]# fdisk /dev/vda
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.
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
...
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
...
Command (m for help): w
...
- 创建物理卷
[root@localhost ~]# pvcreate /dev/vda1
- 创建卷组
[root@localhost ~]# vgcreate mygroup /dev/vda1 //mygroup是卷组名,自己起
- 创建逻辑卷
[root@localhost ~]# vgdisplay mygroup | grep "Total PE" //查看该卷组的逻辑数
- 激活卷组
[root@localhost ~]# vgchange -ay mygroup //还记得mygroup是你自己起的卷组名么,激活卷组是懒得重启VPS
1 logical volume(s) in volume group "mygroup" now active
- 扩展卷组
[root@localhost ~]# vgextend mygroup /dev/vda1
- 创建逻辑卷
[root@localhost ~]# vgdisplay mygroup | grep "Total PE"
Total PE 127999
[root@localhost ~]# lvcreate -l 127999 mygroup -n ccc
- 格式化逻辑卷
[root@localhost ~]# mkfs.ext4 /dev/mygroup/ccc //格式化mygroup卷组的ccc卷组盘
- 创建要挂载盘的目录
[root@localhost ~]# mkdir /data //根据要挂载盘的文件而定,所创建的文件目录。
- 加入启动项
[root@localhost ~]# echo /dev/mygroup/ccc /data ext4 defaults 0 0 >> /etc/fstab //根据要挂载盘的文件而定,所创建的文件目录。
[root@localhost ~]# vim /etc/fstab // 查看写入状况
---
# /etc/fstab
# Created by anaconda on Mon Jan 2 22:58:53 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=381f5199-12a4-4d44-91af-be015a752145 / ext4 defaults 1 1
UUID=4b0d629d-79d8-43e3-82bd-8a7b98fcfb75 swap swap defaults 0 0
/dev/mygroup/ccc /data ext4 defaults 0 0
- 挂载
[root@localhost ~]# mount -a
[root@localhost ~]# df -h //磁盘就挂载上去了。
Filesystem Size Used Avail Use% Mounted on
/dev/vda2 25G 4.6G 19G 20% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 777M 7.0G 10% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/mygroup-ccc 493G 81G 387G 18% /data
/dev/mapper/zfrgroup-zfr 99G 1.4G 92G 2% /home
tmpfs 1.6G 0 1.6G 0% /run/user/0
- 新增磁盘空间
[root@localhost ~]# partprobe
[root@localhost ~]# pvcreate /dev/vda2
[root@localhost ~]# pvdisplay
[root@localhost ~]# vgdisplay
[root@localhost ~]# vgextend mygroup /dev/vda2
[root@localhost ~]# lvextend -L +5G /dev/mygroup/ccc
[root@localhost ~]# resize2fs /dev/mygroup/ccc
更多推荐
已为社区贡献1条内容
所有评论(0)