概要说明
磁盘划分-分区,是针对磁盘设备,而不是分区。所以执行fdisk /dev/vda ,而不是fdisk /dev/vda4
[root@170-BE ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, untilyou decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/vda: 107.4 GB, 107374182400bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier: 0x99cb0000
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 10239 4096 41 PPC PReP Boot
/dev/vda2 10240 1034239 512000 83 Linux
/dev/vda3 1034240 178143231 88554496 8e Linux LVM
/dev/vda4 178143232 209715199 15785984 5 Extended
/dev/vda5 178145280 199116799 10485760 83 Linux --vda的start和end在vda4之内,表示vda5是由vda4分区出来的。
Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector(199118848-209715199, default 199118848): +2G 扇区开始,不要输入直接回车,方便对齐。
Value out of range.
First sector (199118848-209715199, default199118848):
Using default value 199118848
Last sector, +sectors or +size{K,M,G}(199118848-209715199, default 209715199): +2G
Partition6 of type Linux and of size 2 GiB is set
Command (m for help): P
Disk /dev/vda: 107.4 GB, 107374182400bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier: 0x99cb0000
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 10239 4096 41 PPC PReP Boot
/dev/vda2 10240 1034239 512000 83 Linux
/dev/vda3 1034240 178143231 88554496 8e Linux LVM
/dev/vda4 178143232 209715199 15785984 5 Extended
/dev/vda5 178145280 199116799 10485760 83 Linux
/dev/vda6 199118848 203313151 2097152 83 Linux
Command (m for help): W
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.
The kernel still uses the old table. Thenew table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@170-BE ~]# fdisk -l
Disk /dev/vda: 107.4 GB, 107374182400bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier: 0x99cb0000
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 10239 4096 41 PPC PReP Boot
/dev/vda2 10240 1034239 512000 83 Linux
/dev/vda3 1034240 178143231 88554496 8e Linux LVM
/dev/vda4 178143232 209715199 15785984 5 Extended
/dev/vda5 178145280 199116799 10485760 83 Linux
/dev/vda6 199118848 203313151 2097152 83 Linux
Disk /dev/mapper/redosbe_bogon-swap: 4294MB, 4294967296 bytes, 8388608 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk /dev/mapper/redosbe_bogon-root: 42.9GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk /dev/mapper/redosbe_bogon-home: 43.4GB, 43432017920 bytes, 84828160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes /512 bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
[root@170-BE ~]# partprobe --强制让内核重新查找一次分区表
Warning: Unable to open /dev/sr0 read-write(Read-only file system). /dev/sr0 hasbeen opened read-only.
注意:没有fdisk /dev/vda划分时,是没有Extended扩展分区的。
LVM管理
查看pv
[root@RedOS-LE-23cjxlv]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb3 redosbe_bogon lvm2 a-- 331.47g 4.00m
/dev/sdd3 redosle_bogon lvm2 a-- 411.53g 4.00m
/dev/sde storage lvm2 a-- 532.02g 207.02g
/dev/sdf1 jyx lvm2 a-- 100.00g 100.00g
/dev/sdi3 cjxvg lvm2 a-- 50.00g 5.00g
创建PV
[root@RedOS-LE-23cjxlv]# pvcreate /dev/sdi5
Physical volume "/dev/sdi5"successfully created
创建逻辑卷组vg
[root@RedOS-LE-23cjxlv]# vgcreate vgcjx /dev/sdi5
Volume group "vgcjx" successfullycreated
创建LV
[root@RedOS-LE-23cjxlv]# lvcreate -n cjxlv2 -L 1G vgcjx
Logical volume "cjxlv2" created.
查看创建成功的LV
[root@RedOS-LE-23cjxlv]# lvdisplay vgcjx
--- Logical volume ---
LV Path /dev/vgcjx/cjxlv2
LV Name cjxlv2
VG Name vgcjx
LV UUID fSrCog-j00R-vtsf-RuIO-87Wv-3dJe-o1P2e2
LV Write Access read/write
LV Creation host, time RedOS-LE-23,2015-11-13 17:20:05 +0800
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:12
[root@RedOS-LE-23cjxlv]# ll /dev/vgcjx/cjxlv2
lrwxrwxrwx. 1 rootroot 8 Nov 13 17:20 /dev/vgcjx/cjxlv2 -> ../dm-12
格式化成ext4的文件系统,挂载到/mnt下就可以使用了
[root@RedOS-LE-23cjxlv]# mkfs.ext4 /dev/vgcjx/cjxlv2
mke2fs 1.42.9(28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096(log=2)
Fragment size=4096(log=2)
Stride=0 blocks,Stripe width=0 blocks
65536 inodes,262144 blocks
13107 blocks(5.00%) reserved for the super user
First data block=0
Maximum filesystemblocks=268435456
8 block groups
32768 blocks pergroup, 32768 fragments per group
8192 inodes pergroup
Superblock backupsstored on blocks:
32768, 98304, 163840, 229376
Allocating grouptables: done
Writing inodetables: done
Creating journal(8192 blocks): done
Writingsuperblocks and filesystem accounting information: done