What is DASD:
Dynaical Access Storage Device
a striped set of DASDs for Linux on System z. The following steps create a striped volume with stripe size 64k on the DASDs /dev/dasdv1 and /dev/dasdw1. We assume that the used DASDs have already been formatted and partitioned.
1. Create "physical volumes" with the command pvcreate
pserver10:~ # pvcreate /dev/dasd/56c5 /dev/dasd/56c6
pvcreate -- physical volume "/dev/dasdv1" successfully created
pvcreate -- physical volume "/dev/dasdw1" successfully created
2. Create a "volume group" with the command vgcreate
pserver10:~ # vgcreate myvolgroup /dev/dasdv1 /dev/dasdw1
vgcreate -- INFO: using default physical extent size 4MB
vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte
vgcreate -- doing automatic backup of volume group "myvolgroup"
vgcreate -- volume group "myvolgroup" successfully created and activated
3. Get the maximum number of extents with the command vgdisplay
pserver10:~ # vgdisplay myvolgroup
--- Volume group ---
VG Name myvolgroup
VG Access read/write
VG Status available/resizable
VG # 0
MAX LV 256
Cur LV 0
Open LV 0
MAX LV Size 255.99GB
Max PV 256
Cur PV 2
Act PV 2
VG Size 13.74GB
PE Size 4MB
Total PE 3518
Alloc PE / Size 0 / 0
Free PE / Size 3518 / 13.74GB
VG UUID hNoJPC-N3a0-g7md-dK64-PwJ7-T1De-Y0jF7V
4. Create the "logical volume" with the command lvcreate
lvcreate --name mylvolume --stripes 2 --stripesize 64 --extents 3518 myvolgroup
lvcreate -- doing automatic backup of "myvolgroup"
lvcreate -- logical volume "/dev/myvolgroup/mylvolume" successfully created
5. Create a file system on the created logical volume
pserver10:~ # mke2fs -j /dev/myvolgroup/mylvolume
mke2fs 1.28 (31-Aug-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1802240 inodes, 3602432 blocks
180121 blocks (5.00%) reserved for the super user
First data block=0
110 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
If you want to learn more about the commands described here, please have a look at the man pages or the complete LVM-HOWTO (http://tldp.org/HOWTO/LVM-HOWTO/).
Note that the first step of the LVM-HOWTO (http://tldp.org/HOWTO/LVM-HOWTO/):
1. Set the partition system id to 0x8e on /dev/sdc1 and /dev/sde1.
is obsolete for DASD devices on Linux on System z (but valid for SCSI disks)
To reduce an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend): Replace /dev/VolGroup00/LogVol01 with your HD partition.
1.
Disable swapping for the associated logical volume:
# swapoff -v /dev/VolGroup00/LogVol01
2.
Reduce the LVM2 logical volume by 512 MB:
# lvm lvreduce /dev/VolGroup00/LogVol01 -L -512M
3.
Format the new swap space:
# mkswap /dev/VolGroup00/LogVol01
4.
Enable the extended logical volume:
# swapon -va
5.
Test that the logical volume has been reduced properly:
# cat /proc/swaps or # free
---------------------------------
9.1. Initializing disks or disk partitions
Before you can use a disk or disk partition as a physical volume you will have to initialize it:
For entire disks:
*
Run pvcreate on the disk:
# pvcreate /dev/hdb
This creates a volume group descripter at the start of disk.
*
If you get an error that LVM can't initialize a disk with a partition table on it, first make sure that the disk you are operating on is the correct one. If you are very sure that it is, run the following:
Warning DANGEROUS
The following commands will destroy the partition table on the disk being operated on. Be very sure it is the correct disk.
# dd if=/dev/zero of=/dev/diskname bs=1k count=1
# blockdev --rereadpt /dev/diskname
For partitions:
*
Set the partition type to 0x8e using fdisk or some other similar program.
*
Run pvcreate on the partition:
# pvcreate /dev/hdb1
This creates a volume group descriptor at the start of the /dev/hdb1 partition.
9.2. Creating a volume group
Use the 'vgcreate' program:
# vgcreate my_volume_group /dev/hda1 /dev/hdb1
NOTE: If you are using devfs it is essential to use the full devfs name of the device rather than the symlinked name in /dev. so the above would be:
# vgcreate my_volume_group /dev/ide/host0/bus0/target0/lun0/part1 \
/dev/ide/host0/bus0/target1/lun0/part1
You can also specify the extent size with this command if the default of 32MB is not suitable for you with the '-s' switch. In addition you can put some limits on the number of physical or logical volumes the volume can have.
9.3. Activating a volume group
After rebooting the system or running vgchange -an, you will not be able to access your VGs and LVs. To reactivate the volume group, run:
# vgchange -a y my_volume_group
9.4. Removing a volume group
Make sure that no logical volumes are present in the volume group, see later section for how to do this.
Deactivate the volume group:
# vgchange -a n my_volume_group
Now you actually remove the volume group:
# vgremove my_volume_group
9.5. Adding physical volumes to a volume group
Use 'vgextend' to add an initialized physical volume to an existing volume group.
# vgextend my_volume_group /dev/hdc1
^^^^^^^^^ new physical volume
9.6. Removing physical volumes from a volume group
Make sure that the physical volume isn't used by any logical volumes by using then 'pvdisplay' command:
# pvdisplay /dev/hda1
--- Physical volume ---
PV Name /dev/hda1
VG Name myvg
PV Size 1.95 GB / NOT usable 4 MB [LVM: 122 KB]
PV# 1
PV Status available
Allocatable yes (but full)
Cur LV 1
PE Size (KByte) 4096
Total PE 499
Free PE 0
Allocated PE 499
PV UUID Sd44tK-9IRw-SrMC-MOkn-76iP-iftz-OVSen7
If the physical volume is still used you will have to migrate the data to another physical volume.
Then use 'vgreduce' to remove the physical volume:
# vgreduce my_volume_group /dev/hda1
9.7. Creating a logical volume
Decide which physical volumes you want the logical volume to be allocated on, use 'vgdisplay' and 'pvdisplay' to help you decide.
To create a 1500MB linear LV named 'testlv' and its block device special '/dev/testvg/testlv':
# lvcreate -L1500 -ntestlv testvg
To create a 100 LE large logical volume with 2 stripes and stripesize 4 KB.
# lvcreate -i2 -I4 -l100 -nanothertestlv testvg
If you want to create an LV that uses the entire VG, use vgdisplay to find the "Total PE" size, then use that when running lvcreate.
# vgdisplay testvg | grep "Total PE"
Total PE 10230
# lvcreate -l 10230 testvg -n mylv
This will create an LV called mylv filling the testvg VG.
9.8. Removing a logical volume
A logical volume must be closed before it can be removed:
# umount /dev/myvg/homevol
# lvremove /dev/myvg/homevol
lvremove -- do you really want to remove "/dev/myvg/homevol"? [y/n]: y
lvremove -- doing automatic backup of volume group "myvg"
lvremove -- logical volume "/dev/myvg/homevol" successfully removed
9.9. Extending a logical volume
To extend a logical volume you simply tell the lvextend command how much you want to increase the size. You can specify how much to grow the volume, or how large you want it to grow to:
# lvextend -L12G /dev/myvg/homevol
lvextend -- extending logical volume "/dev/myvg/homevol" to 12 GB
lvextend -- doing automatic backup of volume group "myvg"
lvextend -- logical volume "/dev/myvg/homevol" successfully extended
will extend /dev/myvg/homevol to 12 Gigabytes.
# lvextend -L+1G /dev/myvg/homevol
lvextend -- extending logical volume "/dev/myvg/homevol" to 13 GB
lvextend -- doing automatic backup of volume group "myvg"
lvextend -- logical volume "/dev/myvg/homevol" successfully extended
will add another gigabyte to /dev/myvg/homevol.
After you have extended the logical volume it is necessary to increase the file system size to match. how you do this depends on the file system you are using.
By default, most file system resizing tools will increase the size of the file system to be the size of the underlying logical volume so you don't need to worry about specifying the same size for each of the two commands.
1.
ext2
Unless you have patched your kernel with the ext2online patch it is necessary to unmount the file system before resizing it.
# umount /dev/myvg/homevol/dev/myvg/homevol
# resize2fs /dev/myvg/homevol
# mount /dev/myvg/homevol /home
If you don't have e2fsprogs 1.19 or later, you can download the ext2resize command from ext2resize.sourceforge.net and use that:
# umount /dev/myvg/homevol/dev/myvg/homevol
# resize2fs /dev/myvg/homevol
# mount /dev/myvg/homevol /home
For ext2 there is an easier way. LVM ships with a utility called e2fsadm which does the lvextend and resize2fs for you (it can also do file system shrinking, see the next section) so the single command
# e2fsadm -L+1G /dev/myvg/homevol
is equivalent to the two commands:
# lvextend -L+1G /dev/myvg/homevol
# resize2fs /dev/myvg/homevol
Note Note
You will still need to unmount the file system before running e2fsadm.
2.
reiserfs
Reiserfs file systems can be resized when mounted or unmounted as you prefer:
*
Online:
# resize_reiserfs -f /dev/myvg/homevol
*
Offline:
# umount /dev/myvg/homevol
# resize_reiserfs /dev/myvg/homevol
# mount -treiserfs /dev/myvg/homevol /home
3.
xfs
XFS file systems must be mounted to be resized and the mount-point is specified rather than the device name.
# xfs_growfs /home
9.10. Reducing a logical volume
Logical volumes can be reduced in size as well as increased. However, it is very important to remember to reduce the size of the file system or whatever is residing in the volume before shrinking the volume itself, otherwise you risk losing data.
1.
ext2
If you are using ext2 as the file system then you can use the e2fsadm command mentioned earlier to take care of both the file system and volume resizing as follows:
# umount /home
# e2fsadm -L-1G /dev/myvg/homevol
# mount /home
If you prefer to do this manually you must know the new size of the volume in blocks and use the following commands:
# umount /home
# resize2fs /dev/myvg/homevol 524288
# lvreduce -L-1G /dev/myvg/homevol
# mount /home
2.
reiserfs
Reiserfs seems to prefer to be unmounted when shrinking
# umount /home
# resize_reiserfs -s-1G /dev/myvg/homevol
# lvreduce -L-1G /dev/myvg/homevol
# mount -treiserfs /dev/myvg/homevol /home
3.
xfs
There is no way to shrink XFS file systems.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment