首页
学习
活动
专区
圈层
工具
发布

LVM-HOWTO/学习笔记(三)

1. 在现有的系统中附加新的scsi硬盘

A data centre machine has 6 disks attached as follows:

# pvscan pvscan -- ACTIVE   PV "/dev/sda"  of VG "dev"   [1.95 GB / 0 free] pvscan -- ACTIVE   PV "/dev/sdb"  of VG "sales" [1.95 GB / 0 free] pvscan -- ACTIVE   PV "/dev/sdc"  of VG "ops"   [1.95 GB / 44 MB free] pvscan -- ACTIVE   PV "/dev/sdd"  of VG "dev"   [1.95 GB / 0 free] pvscan -- ACTIVE   PV "/dev/sde1" of VG "ops"   [996 MB / 52 MB free] pvscan -- ACTIVE   PV "/dev/sde2" of VG "sales" [996 MB / 944 MB free] pvscan -- ACTIVE   PV "/dev/sdf1" of VG "ops"   [996 MB / 0 free] pvscan -- ACTIVE   PV "/dev/sdf2" of VG "dev"   [996 MB / 72 MB free] pvscan -- total: 8 [11.72 GB] / in use: 8 [11.72 GB] / in no VG: 0 [0]

代码语言:javascript
复制
# df
代码语言:javascript
复制
Filesystem           1k-blocks      Used Available Use% Mounted on
代码语言:javascript
复制
/dev/dev/cvs           1342492    516468    757828  41% /mnt/dev/cvs
代码语言:javascript
复制
/dev/dev/users         2064208   2060036      4172 100% /mnt/dev/users
代码语言:javascript
复制
/dev/dev/build         1548144   1023041    525103  66% /mnt/dev/build
代码语言:javascript
复制
/dev/ops/databases     2890692   2302417    588275  79% /mnt/ops/databases
代码语言:javascript
复制
/dev/sales/users       2064208    871214   1192994  42% /mnt/sales/users
代码语言:javascript
复制
/dev/ops/batch         1032088    897122    134966  86% /mnt/ops/batch

准备磁盘分区

代码语言:javascript
复制
# fdisk /dev/sdg
代码语言:javascript
复制
代码语言:javascript
复制
Device contains neither a valid DOS partition table, nor Sun or SGI
代码语言:javascript
复制
disklabel Building a new DOS disklabel. Changes will remain in memory
代码语言:javascript
复制
only, until you decide to write them. After that, of course, the
代码语言:javascript
复制
previous content won't be recoverable.
代码语言:javascript
复制
代码语言:javascript
复制
Command (m for help): n
代码语言:javascript
复制
Command action
代码语言:javascript
复制
   e   extended
代码语言:javascript
复制
   p   primary partition (1-4)
代码语言:javascript
复制
p
代码语言:javascript
复制
Partition number (1-4): 1
代码语言:javascript
复制
First cylinder (1-1000, default 1):
代码语言:javascript
复制
Using default value 1
代码语言:javascript
复制
Last cylinder or +size or +sizeM or +sizeK (1-1000, default 1000): 500
代码语言:javascript
复制
代码语言:javascript
复制
Command (m for help): n
代码语言:javascript
复制
Command action
代码语言:javascript
复制
   e   extended
代码语言:javascript
复制
   p   primary partition (1-4)
代码语言:javascript
复制
p
代码语言:javascript
复制
Partition number (1-4): 2
代码语言:javascript
复制
First cylinder (501-1000, default 501): 
代码语言:javascript
复制
Using default value 501
代码语言:javascript
复制
Last cylinder or +size or +sizeM or +sizeK (501-1000, default 1000): 
代码语言:javascript
复制
Using default value 1000
代码语言:javascript
复制
代码语言:javascript
复制
Command (m for help): t
代码语言:javascript
复制
Partition number (1-4): 1
代码语言:javascript
复制
Hex code (type L to list codes): 8e
代码语言:javascript
复制
Changed system type of partition 1 to 8e (Unknown)
代码语言:javascript
复制
代码语言:javascript
复制
Command (m for help): t
代码语言:javascript
复制
Partition number (1-4): 2
代码语言:javascript
复制
Hex code (type L to list codes): 8e
代码语言:javascript
复制
Changed system type of partition 2 to 8e (Unknown)
代码语言:javascript
复制
代码语言:javascript
复制
Command (m for help): w
代码语言:javascript
复制
The partition table has been altered!
代码语言:javascript
复制
代码语言:javascript
复制
Calling ioctl() to re-read partition table.
代码语言:javascript
复制
代码语言:javascript
复制
WARNING: If you have created or modified any DOS 6.x partitions,

please see the fdisk manual page for additional information

Next physical volumes are created on this partition:

# pvcreate /dev/sdg1 pvcreate -- physical volume "/dev/sdg1" successfully created   # pvcreate /dev/sdg2 pvcreate -- physical volume "/dev/sdg2" successfully created

在vg中添加新的磁盘

The volumes are then added to the dev and ops volume groups:

# vgextend ops /dev/sdg1 vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte vgextend -- doing automatic backup of volume group "ops" vgextend -- volume group "ops" successfully extended   # vgextend dev /dev/sdg2 vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte vgextend -- doing automatic backup of volume group "dev" vgextend -- volume group "dev" successfully extended   # pvscan pvscan -- reading all physical volumes (this may take a while...) pvscan -- ACTIVE   PV "/dev/sda"  of VG "dev"   [1.95 GB / 0 free] pvscan -- ACTIVE   PV "/dev/sdb"  of VG "sales" [1.95 GB / 0 free] pvscan -- ACTIVE   PV "/dev/sdc"  of VG "ops"   [1.95 GB / 44 MB free] pvscan -- ACTIVE   PV "/dev/sdd"  of VG "dev"   [1.95 GB / 0 free] pvscan -- ACTIVE   PV "/dev/sde1" of VG "ops"   [996 MB / 52 MB free] pvscan -- ACTIVE   PV "/dev/sde2" of VG "sales" [996 MB / 944 MB free] pvscan -- ACTIVE   PV "/dev/sdf1" of VG "ops"   [996 MB / 0 free] pvscan -- ACTIVE   PV "/dev/sdf2" of VG "dev"   [996 MB / 72 MB free] pvscan -- ACTIVE   PV "/dev/sdg1" of VG "ops"   [996 MB / 996 MB free] pvscan -- ACTIVE   PV "/dev/sdg2" of VG "dev"   [996 MB / 996 MB free] pvscan -- total: 10 [13.67 GB] / in use: 10 [13.67 GB] / in no VG: 0 [0]

扩展文件系统

代码语言:javascript
复制
# umount /mnt/ops/batch
代码语言:javascript
复制
# umount /mnt/dev/users

We then use the e2fsadm command to resize the logical volume and the ext2 file system on one operation. We are using ext2resize instead of resize2fs (which is the default command for e2fsadm) so we define the environment variable E2FSADM_RESIZE_CMD to tell e2fsadm to use that command.

# export E2FSADM_RESIZE_CMD=ext2resize # e2fsadm /dev/ops/batch -L+500M e2fsck 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09 Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/ops/batch: 11/131072 files (0.0<!--  non-contiguous), 4127/262144 blocks lvextend -- extending logical volume "/dev/ops/batch" to 1.49 GB lvextend -- doing automatic backup of volume group "ops" lvextend -- logical volume "/dev/ops/batch" successfully extended   ext2resize v1.1.15 - 2000/08/08 for EXT2FS 0.5b e2fsadm -- ext2fs in logical volume "/dev/ops/batch" successfully extended to 1.49 GB     # e2fsadm /dev/dev/users -L+900M e2fsck 1.18, 11-Nov-1999 for EXT2 FS 0.5b, 95/08/09 Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/dev/users: 12/262144 files (0.0% non-contiguous), 275245/524288 blocks lvextend -- extending logical volume "/dev/dev/users" to 2.88 GB lvextend -- doing automatic backup of volume group "dev" lvextend -- logical volume "/dev/dev/users" successfully extended   ext2resize v1.1.15 - 2000/08/08 for EXT2FS 0.5b e2fsadm -- ext2fs in logical volume "/dev/dev/users" successfully extended to 2.88 GB

代码语言:javascript
复制
# mount /dev/ops/batch
代码语言:javascript
复制
# mount /dev/dev/users
代码语言:javascript
复制
# df
代码语言:javascript
复制
Filesystem           1k-blocks      Used Available Use% Mounted on
代码语言:javascript
复制
/dev/dev/cvs           1342492    516468    757828  41% /mnt/dev/cvs
代码语言:javascript
复制
/dev/dev/users         2969360   2060036    909324  69% /mnt/dev/users
代码语言:javascript
复制
/dev/dev/build         1548144   1023041    525103  66% /mnt/dev/build
代码语言:javascript
复制
/dev/ops/databases     2890692   2302417    588275  79% /mnt/ops/databases
代码语言:javascript
复制
/dev/sales/users       2064208    871214   1192994  42% /mnt/sales/users
代码语言:javascript
复制
/dev/ops/batch         1535856    897122    638734  58% /mnt/ops/batch
下一篇
举报
领券