本文的目的:
假設zLINUX這個z/VM用戶只定義了兩塊盤,在user directory中定義如下:
MDISK 0300 FB-512 V-DISK 131072
MDISK 0100 3390 1 10016 VMC2F9 W
映射到Linux文件系統中分區結構如下:
[root@zLINUX~]# lsdasd
Bus-ID Status Name Device Type BlkSz Size Blocks
=======================================================
0.0.0100 active dasda 94:0 ECKD 4096 7042MB 1802880
0.0.0300 active dasdb 94:4 FBA 512 64MB 131072
它的文件系統:
Filesystem Size Used Avail Use% Mounted on
/dev/dasda1 6.8G 1.7G 4.8G 27% /
tmpfs 57M 0 57M 0% /dev/shm
我們看到此系統根分區下只有6.8G的空間,如果在某應用場合下比如OpenStack 需要建立一個用來放虛擬機鏡像的倉庫並且mount 到/images下,並且要求在空間不夠時能夠自動擴展空間,下面介紹如何實現這一需求。
Step 1 添加磁盤到z/VM用戶
登錄PCOM 3270,用dirm 命令為USER ID 為LX164003的用戶添加一個大小為3339 cylinder 的磁盤。
DIRM FOR LX164003 AMDISK 0101 3390 AUTOG 3339 POOL1W
添加完後LX164003的磁盤為:
MDISK 0300 FB-512 V-DISK 131072
MDISK 0100 3390 1 10016 VMC2F9 W
MDISK 0101 3390 3341 3339 VMD887W
Step 2 上線新添加的設備
重新登錄zLinux 發現磁盤0101已經被加到這個vm上:
[root@zLINUX~]# vmcp q v dasd | grep 0101
DASD 0101 3390 VMD887 R/W 3339 CYL ON DASD D887 SUBCHANNEL = 000C
上線新添加的設備
[root@zLINUX~]# chccwdev -e 0101
Setting device 0.0.0101 online
本欄目更多精彩內容:http://www.bianceng.cn/OS/Linux/
Done
查看這個磁盤的Linux設備名稱
[root@zLINUX~]# lsdasd
Bus-ID Status Name Device Type BlkSz Size Blocks
=======================================================
0.0.0100 active dasda 94:0 ECKD 4096 7042MB 1802880
0.0.0300 active dasdb 94:4 FBA 512 64MB 131072
0.0.0101 active dasdc 94:8 ECKD 4096 2347MB 601020
Step 3 將新加磁盤格式化成cdl類型磁盤
[root@zLINUX~]# dasdfmt -b 4096 -d cdl -y -f /dev/dasdc
Finished formatting the device.
Rereading the partition table... ok
Step 4 為磁盤創建分區表,為簡單起見,為整個設備只創建一個分區
[root@zLINUX~]# fdasd -a /dev/dasdc
reading volume label ..: VOL1
reading vtoc ..........: ok
auto-creating one partition for the whole disk...
writing volume label...
writing VTOC...
rereading partition table...
Step 5 為分區建立文件系統
[root@zLINUX~]# mke2fs -j /dev/dasdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
150480 inodes, 600996 blocks
30049 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=616562688
19 block groups
32768 blocks per group, 32768 fragments per group
7920 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
本欄目更多精彩內容:http://www.bianceng.cn/OS/Linux/
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Step 6 設置自動加載
將 rd_DASD=0.0.0101加入開機配置文件/etc/zipl.conf,以使虛擬機在開機時能自動加載這塊盤。
修改後的/etc/zipl.conf為
[linux-2.6.32-220.el6.s390x]
image=/boot/vmlinuz-2.6.32-220.el6.s390x
ramdisk=/boot/initramfs-2.6.32-220.el6.s390x.img
parameters="root=/dev/disk/by-path/ccw-0.0.0100-part1 rd_NO_LUKS rd_DASD=0.0.0300 rd_NO_MD KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_DASD=0.0.0100 rd_DASD=0.0.0101 rd_NO_LVM rd_NO_DM LANG=en_US.UTF-8"
Step 7 重新加載配置文件
[root@zLINUX~]# zipl -V
Using config file '/etc/zipl.conf'
Target device information
Device..........................: 5e:00
Partition.......................: 5e:01
Device name.....................: dasda
Device driver name..............: dasd
DASD device number..............: 0100
Type............................: disk partition
Disk layout.....................: ECKD/compatible disk layout
Geometry - heads................: 15
Geometry - sectors..............: 12
本欄目更多精彩內容:http://www.bianceng.cn/OS/Linux/
Geometry - cylinders............: 10016
Geometry - start................: 24
File system block size..........: 4096
Physical block size.............: 4096
Device size in physical blocks..: 1802856
Building bootmap in '/boot/'
Building menu 'rh-automatic-menu'
Adding #1: IPL section 'linux-2.6.32-220.el6.s390x' (default)
kernel image......: /boot/vmlinuz-2.6.32-220.el6.s390x
kernel parmline...: 'root=/dev/disk/by-path/ccw-0.0.0100-part1 rd_NO_LUKS rd_DASD=0.0.0300 rd_NO_MD KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_DASD=0.0.0100 rd_DASD=0.0.0101 rd_NO_LVM rd_NO_DM LANG=en_US.UTF-8'
initial ramdisk...: /boot/initramfs-2.6.32-220.el6.s390x.img
component address:
kernel image....: 0x00010000-0x008a8fff
parmline........: 0x00001000-0x00001fff
initial ramdisk.: 0x02000000-0x02a5ffff
internal loader.: 0x0000a000-0x0000afff
Preparing boot device: dasda (0100).
Preparing boot menu
Interactive prompt......: enabled
Menu timeout............: 5 seconds
Default configuration...: 'linux-2.6.32-220.el6.s390x'
Syncing disks...
Done.
Step8 采用LVM來管理這塊磁盤
用reboot重啟系統後,通過以下步驟來進行
8.1 用分區創建物理卷
[root@zLINUX~]# pvcreate /dev/dasdc1
Writing physical volume data to disk "/dev/dasdc1"
Physical volume "/dev/dasdc1" successfully created
本欄目更多精彩內容:http://www.bianceng.cn/OS/Linux/
8.2 創建卷組VG199
[root@zLINUX~]# vgcreate VG199 /dev/dasdc1
Volume group "VG199" successfully created
8.3 查看卷組VG199中空閒PE(Physical extents)個數
[root@zLINUX~]# vgdisplay | grep "Free"
Free PE / Size 586 / 2.29 GiB
8.4 利用VG199中的全部PE來創建邏輯卷LV199
[root@zLINUX~]# lvcreate -l +586 -n /dev/VG199/LV199
Logical volume "LV199" created
[root@zLINUX~]#vgdisplay | grep "Free"
Free PE / Size 0 / 0
8.5 為邏輯卷LV199創建文件系統
[root@zLINUX~]# mke2fs -j /dev/VG199/LV199
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
150176 inodes, 600064 blocks
30003 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=616562688
19 block groups
32768 blocks per group, 32768 fragments per group
7904 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
8.6 修改/etc/fstab表,以使每次系統重啟後/image都能被mount上
[root@zLINUX~]# cp /etc/fstab /etc/fstab.bkup
本欄目更多精彩內容:http://www.bianceng.cn/OS/Linux/
[root@zLINUX~]# mkdir /images
[root@zLINUX~]# echo "/dev/VG199/LV199 /images ext2 defaults 1 2 " >> /etc/fstab
8.7 重新mount後,發現新添加的盤已經被單獨mount到/image並被做鏡像倉庫來使用/images
[root@zLINUX~]# mount -a
[root@zLINUX~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dasda1 6.8G 1.7G 4.8G 27% /
tmpfs 57M 0 57M 0% /dev/shm
/dev/mapper/VG199-LV199
2.3G 68M 2.1G 4% /images
總結:
以上過程演示在zLinux上如何添加DASD磁盤來建立一個虛擬機的鏡像倉庫,如果使用過程中發現/images 空間不夠用時,可以通過類似的步驟添加磁盤到這個z/VM用戶並添加到系統LVM中,從而擴展邏輯卷LV199來擴大空間。