df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 16G 22G 42% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 40K 16G 1% /dev/shm
tmpfs 16G 1.4M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
tmpfs 3.2G 48K 3.2G 1% /run/user/0
tmpfs 3.2G 0 3.2G 0% /run/user/1000
只有第一块硬盘/dev/vda
已经配置到/dev/vda1
,另外三块硬盘只有设备没有device boot
fdisk -l
Disk /dev/vda: 42.9 GB, 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 / 512 bytes
Disk label type: dos
Disk identifier: 0x000b1b45
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83875364 41936658+ 83 Linux
Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 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 /dev/vdc: 536.9 GB, 536870912000 bytes, 1048576000 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 /dev/vdd: 536.9 GB, 536870912000 bytes, 1048576000 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
fdisk /dev/vdb
n # 1
t # 8e
w #fdisk -l 看到device boot:/dev/vdb1
fdisk /dev/vdc
n # 1
t # 8e
w #fdisk -l 看到device boot:/dev/vdc1
完整记录
Command (m for help): n 1
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-1048575999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):
Using default value 1048575999
Partition 1 of type Linux and of size 500 GiB is set
Command (m for help): t 8e
Selected partition 1
Hex code (type L to list all codes):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): w
The partition table has been altered!
pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created.
pvcreate /dev/vdc1
Physical volume "/dev/vdc1" successfully created.
pvdisplay
"/dev/vdc1" is a new physical volume of "<500.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdc1
VG Name
PV Size <500.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
"/dev/vdb1" is a new physical volume of "<500.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vdb1
VG Name
PV Size <500.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
vgcreate vgdata /dev/vdb1 /dev/vdc1
Volume group "vgdata" successfully created
vgdisplay
--- Volume group ---
VG Name vgdata
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 999.99 GiB
PE Size 4.00 MiB
Total PE 255998
Alloc PE / Size 0 / 0
Free PE / Size 255998 / 999.99 GiB
lvcreate -l 100%VG vgdata -n lvdata
Logical volume "lvdata" created.
lvdisplay
--- Logical volume ---
LV Path /dev/vgdata/lvdata
LV Name lvdata
VG Name vgdata
LV UUID dmfqds-IiEY-l3JV-cYQj-KAOM-hcFu-30sh8O
LV Write Access read/write
LV Creation host, time iZbp1d4tisi44j6vxze02fZ, 2019-05-29 19:56:14 +0800
LV Status available
# open 0
LV Size 999.99 GiB
Current LE 255998
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:0
ll /dev/vgdata/lvdata
lrwxrwxrwx 1 root root 7 May 29 19:56 /dev/vgdata/lvdata -> ../dm-0
mkfs.ext4 /dev/vgdata/lvdata
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
65536000 inodes, 262141952 blocks
13107097 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2409627648
8000 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
mkdir /fdisk1
mount /dev/vgdata/lvdata /fdisk1/
echo "/dev/vgdata/lvdata /fdisk1 ext4 defaults 0 0" >> /etc/fstab
df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/mapper/vgdata-lvdata 985G 77M 935G 1% /fdisk1
...