树莓派 apt-get install lvm2
root@test-VirtualBox:/# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000670f1
设备 启动 起点 终点 块数 Id 系统
/dev/sda1 * 2048 15728639 7863296 83 Linux
/dev/sda2 15730686 16775167 522241 5 扩展
/dev/sda5 15730688 16775167 522240 82 Linux 交换 / Solaris
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders, total 4194304 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45c39e6a
root@test-VirtualBox:/# fdisk /dev/sdb
命令(输入 m 获取帮助): m
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
命令(输入 m 获取帮助): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认为 1): 1
起始 sector (2048-4194303,默认为 2048):
将使用默认值 2048
Last sector, +扇区 or +size{K,M,G} (2048-4194303,默认为 4194303): 1000000
命令(输入 m 获取帮助): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@test-VirtualBox:/#
root@test-VirtualBox:/# fdisk /dev/sdb
命令(输入 m 获取帮助): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
分区号 (1-4,默认为 2): 2
起始 sector (1000001-4194303,默认为 1000001):
将使用默认值 1000001
Last sector, +扇区 or +size{K,M,G} (1000001-4194303,默认为 4194303):
将使用默认值 4194303
命令(输入 m 获取帮助): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@test-VirtualBox:/#
root@test-VirtualBox:/# fdisk -l /dev/sdb
Disk /dev/sdb: 2147 MB, 2147483648 bytes
64 heads, 2 sectors/track, 32768 cylinders, total 4194304 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45c39e6a
设备 启动 起点 终点 块数 Id 系统
/dev/sdb1 2048 1000000 498976+ 83 Linux
/dev/sdb2 1000001 4194303 1597151+ 83 Linux
root@test-VirtualBox:/#
root@test-VirtualBox:/# fdisk /dev/sdb
命令(输入 m 获取帮助): t
分区号 (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
命令(输入 m 获取帮助): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@test-VirtualBox:/# fdisk /dev/sdb
命令(输入 m 获取帮助): t
分区号 (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
命令(输入 m 获取帮助): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@test-VirtualBox:/# fdisk -l /dev/sdb
Disk /dev/sdb: 2147 MB, 2147483648 bytes
64 heads, 2 sectors/track, 32768 cylinders, total 4194304 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45c39e6a
设备 启动 起点 终点 块数 Id 系统
/dev/sdb1 2048 1000000 498976+ 8e Linux LVM
/dev/sdb2 1000001 4194303 1597151+ 8e Linux LVM
root@test-VirtualBox:/#
root@test-VirtualBox:/# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
root@test-VirtualBox:/# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
root@test-VirtualBox:/#
root@test-VirtualBox:/# pvdisplay
"/dev/sdb1" is a new physical volume of "487.28 MiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 487.28 MiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID TGttb4-y79K-zoUW-iQfc-q8SD-48Jy-S3u726
"/dev/sdb2" is a new physical volume of "1.52 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb2
VG Name
PV Size 1.52 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID oD94Uc-4KMe-uHmy-7CWZ-ROvC-T4Ft-sX352k
root@test-VirtualBox:/#
root@test-VirtualBox:/# vgcreate lvmdisk /dev/sdb1 /dev/sdb2
Volume group "lvmdisk" successfully created
root@test-VirtualBox:/# vgdisplay
--- Volume group ---
VG Name lvmdisk
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 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 0 / 0
Free PE / Size 510 / 1.99 GiB
VG UUID kRqFDk-3X9R-6Ju9-QHhK-S7oq-3UsF-9yeGd2
root@test-VirtualBox:/#
root@test-VirtualBox:/# lvcreate -L 1G -n pldy1 lvmdisk
Logical volume "pldy1" created
root@test-VirtualBox:/# lvdisplay
--- Logical volume ---
LV Name /dev/lvmdisk/pldy1
VG Name lvmdisk
LV UUID RlYmJ3-mDFc-Nz8r-uzCr-i2s6-QrqT-mNmAdm
LV Write Access read/write
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
root@test-VirtualBox:/#
root@test-VirtualBox:/# vgdisplay
--- Volume group ---
VG Name lvmdisk
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 256 / 1.00 GiB
Free PE / Size 254 / 1016.00 MiB
VG UUID kRqFDk-3X9R-6Ju9-QHhK-S7oq-3UsF-9yeGd2
root@test-VirtualBox:/#
root@test-VirtualBox:/# lvextend -L+100M /dev/lvmdisk/pldy1
Extending logical volume pldy1 to 1.10 GiB
Logical volume pldy1 successfully resized
root@test-VirtualBox:/# vgdisplay
--- Volume group ---
VG Name lvmdisk
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 281 / 1.10 GiB
Free PE / Size 229 / 916.00 MiB
VG UUID kRqFDk-3X9R-6Ju9-QHhK-S7oq-3UsF-9yeGd2
root@test-VirtualBox:/# mkfs.ext3 /dev/lvmdisk/pldy1
mke2fs 1.42 (29-Nov-2011)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
72000 inodes, 287744 blocks
14387 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=297795584
9 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
root@test-VirtualBox:/# mkdir /opt/oracle
root@test-VirtualBox:/# mount /dev/lvmdisk/pldy1 /opt/oracle/
root@test-VirtualBox:/# df -lhT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext4 7.5G 2.8G 4.4G 39% /
udev devtmpfs 241M 4.0K 241M 1% /dev
tmpfs tmpfs 100M 784K 99M 1% /run
none tmpfs 5.0M 0 5.0M 0% /run/lock
none tmpfs 248M 124K 248M 1% /run/shm
/dev/sr0 iso9660 56M 56M 0 100% /media/VBOXADDITIONS_4.3.20_96996
/dev/mapper/lvmdisk-pldy1 ext3 1.1G 34M 1017M 4% /opt/oracle
root@test-VirtualBox:/#
root@test-VirtualBox:/# lvextend -L+100M /dev/lvmdisk/pldy1
Extending logical volume pldy1 to 1.20 GiB
Logical volume pldy1 successfully resized
root@test-VirtualBox:/# df -hlT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext4 7.5G 2.8G 4.4G 39% /
udev devtmpfs 241M 4.0K 241M 1% /dev
tmpfs tmpfs 100M 784K 99M 1% /run
none tmpfs 5.0M 0 5.0M 0% /run/lock
none tmpfs 248M 124K 248M 1% /run/shm
/dev/sr0 iso9660 56M 56M 0 100% /media/VBOXADDITIONS_4.3.20_96996
/dev/mapper/lvmdisk-pldy1 ext3 1.1G 34M 1017M 4% /opt/oracle
root@test-VirtualBox:/# resize2fs /opt/oracle/
resize2fs 1.42 (29-Nov-2011)
open: 是一个目录 打开/opt/oracle/时
root@test-VirtualBox:/# resize2fs /dev/lvmdisk/pldy1
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/lvmdisk/pldy1 is mounted on /opt/oracle; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/lvmdisk/pldy1 to 313344 (4k) blocks.
The filesystem on /dev/lvmdisk/pldy1 is now 313344 blocks long.
root@test-VirtualBox:/# df -hlT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext4 7.5G 2.8G 4.4G 39% /
udev devtmpfs 241M 4.0K 241M 1% /dev
tmpfs tmpfs 100M 784K 99M 1% /run
none tmpfs 5.0M 0 5.0M 0% /run/lock
none tmpfs 248M 124K 248M 1% /run/shm
/dev/sr0 iso9660 56M 56M 0 100% /media/VBOXADDITIONS_4.3.20_96996
/dev/mapper/lvmdisk-pldy1 ext3 1.2G 34M 1.1G 3% /opt/oracle
root@test-VirtualBox:/# resize2fs /dev/lvmdisk/pldy1
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/lvmdisk/pldy1 is mounted on /opt/oracle; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/lvmdisk/pldy1 to 338944 (4k) blocks.
The filesystem on /dev/lvmdisk/pldy1 is now 338944 blocks long.
root@test-VirtualBox:/# df -lhT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda1 ext4 7.5G 2.8G 4.4G 39% /
udev devtmpfs 241M 4.0K 241M 1% /dev
tmpfs tmpfs 100M 784K 99M 1% /run
none tmpfs 5.0M 0 5.0M 0% /run/lock
none tmpfs 248M 124K 248M 1% /run/shm
/dev/sr0 iso9660 56M 56M 0 100% /media/VBOXADDITIONS_4.3.20_96996
/dev/mapper/lvmdisk-pldy1 ext3 1.3G 34M 1.2G 3% /opt/oracle
root@test-VirtualBox:/#
root@test-VirtualBox:/# pvcreate /dev/sdb3
root@test-VirtualBox:/# pvdisplay
root@test-VirtualBox:/# vgdisplay
root@test-VirtualBox:/# vgextend lvmdisk /dev/sdb3
root@test-VirtualBox:/# vgdisplay
umount /dev/test_vg/test_lv1
umount /dev/test_vg/test_lv2
#卸载文件系统
lvremove /dev/test_vg/test_lv1
lvremove /dev/test_vg/test_lv2
#移除逻辑卷
vgremove test_vg
#删除卷组
pvremove /dev/sdb{1,2,3,4,5}
#删除物理卷