免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1470 | 回复: 0
打印 上一主题 下一主题

practice - create lvm on suse linux [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-23 03:07 |只看该作者 |倒序浏览

                ENV: SUSE 11.1
1. use command "fdisk -l" to see disk info, it can print the partition info of all hard disk( if you have more than one disk ), it does not include the un-partitioned partition
linux-me6t:~ # fdisk -lDisk /dev/sda: 320.0 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x487f487e   Device Boot      Start         End      Blocks   Id  System/dev/sda1               1        2550    20482843+   c  W95 FAT32 (LBA)/dev/sda2            2551       25497   184321777+   f  W95 Ext'd (LBA)/dev/sda3   *       25498       28108    20972857+  83  Linux/dev/sda5            2551        8925    51207156    7  HPFS/NTFS/dev/sda6            8926       22578   109659690    7  HPFS/NTFS/dev/sda7           22578       23361     6297417   82  Linux swap / Solaris/dev/sda8           23362       25497    17157388+  83  LinuxDisk /dev/sdb: 500.1 GB, 500107862016 bytes255 heads, 63 sectors/track, 60801 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x758070a2   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1        6374    51199123+   7  HPFS/NTFS/dev/sdb2            6375       60801   437184877+   7  HPFS/NTFS
2. use command "fdisk" to add a new partition
a. execute command "fdisk"
linux-me6t:~ # fdisk /dev/sda                                    The number of cylinders for this disk is set to 38913.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:               1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs               (e.g., DOS FDISK, OS/2 FDISK)                               Command (m for help): mCommand action            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)Command (m for help): pDisk /dev/sda: 320.0 GB, 320072933376 bytes255 heads, 63 sectors/track, 38913 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x487f487e   Device Boot      Start         End      Blocks   Id  System/dev/sda1               1        2550    20482843+   c  W95 FAT32 (LBA)/dev/sda2            2551       25497   184321777+   f  W95 Ext'd (LBA)/dev/sda3   *       25498       28108    20972857+  83  Linux/dev/sda5            2551        8925    51207156    7  HPFS/NTFS/dev/sda6            8926       22578   109659690    7  HPFS/NTFS/dev/sda7           22578       23361     6297417   82  Linux swap / Solaris/dev/sda8           23362       25497    17157388+  83  LinuxCommand (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (28109-38913, default 28109):
Using default value 28109
Last cylinder, +cylinders or +size{K,M,G} (28109-38913, default 38913):
Using default value 38913
Command (m for help):
-----------note: now, you can see the newly added partition
Command (m for help): p
Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x487f487e
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        2550    20482843+   c  W95 FAT32 (LBA)
/dev/sda2            2551       25497   184321777+   f  W95 Ext'd (LBA)
/dev/sda3   *       25498       28108    20972857+  83  Linux
/dev/sda4           28109       38913    86791162+  8e  Linux LVM
/dev/sda5            2551        8925    51207156    7  HPFS/NTFS
/dev/sda6            8926       22578   109659690    7  HPFS/NTFS
/dev/sda7           22578       23361     6297417   82  Linux swap / Solaris
/dev/sda8           23362       25497    17157388+  83  Linux
------------note: remember to write the operation to table, according to prompt information when quite fdisk, the new partition will take effect after system restart
Command (m for help): w
3. restart OS so that new partition table takes effect
4. create logic volume
linux-me6t:~ # pvcreate  /dev/sda4                     
File descriptor 4 left open                           
File descriptor 9 left open                           
File descriptor 10 left open                           
File descriptor 11 left open                           
File descriptor 12 left open                           
  Device /dev/sda4 not found (or ignored by filtering).
------------note: although add new partition, but device can not be found
check the devices using the command below, it really does not exist:
linux-me6t:~ # ls -l /dev/sda*
brw-rw---- 1 root disk 8, 0 Jan 23 01:55 /dev/sda
brw-rw---- 1 root disk 8, 1 Jan 23  2009 /dev/sda1
brw-rw---- 1 root disk 8, 2 Jan 23 02:43 /dev/sda2
brw-rw---- 1 root disk 8, 3 Jan 23  2009 /dev/sda3
brw-rw---- 1 root disk 8, 5 Jan 23  2009 /dev/sda5
brw-rw---- 1 root disk 8, 6 Jan 23  2009 /dev/sda6
brw-rw---- 1 root disk 8, 7 Jan 23  2009 /dev/sda7
brw-rw---- 1 root disk 8, 8 Jan 23 02:43 /dev/sda8
problem solution: use command "partprobe" to make the partition info take effect
inux-me6t:~ # partprobe
linux-me6t:~ #
question: why the partition does not take effect although OS restartnow, logic volume can be created:
linux-me6t:~ # pvcreate /dev/sda4
File descriptor 4 left open
File descriptor 9 left open
File descriptor 10 left open
File descriptor 11 left open
File descriptor 12 left open
  Physical volume "/dev/sda4" successfully created
5. create volume group
inux-me6t:~ # vgcreate lvm-1 /dev/sda4File descriptor 4 left openFile descriptor 9 left openFile descriptor 10 left openFile descriptor 11 left openFile descriptor 12 left open  Volume group "lvm-1" successfully created
linux-me6t:~ #
question: creating volume group can be ignored (if only one physical volume, it is no needed)
6. change attribute for volume group
linux-me6t:~ #  vgchange -a y lvm-1File descriptor 4 left openFile descriptor 9 left openFile descriptor 10 left openFile descriptor 11 left openFile descriptor 12 left open  0 logical volume(s) in volume group "lvm-1" now activelinux-me6t:~ #
7. check and see the info of newly created lmv
inux-me6t:~ # pvdisplayFile descriptor 4 left openFile descriptor 9 left openFile descriptor 10 left openFile descriptor 11 left openFile descriptor 12 left open  --- Physical volume ---  PV Name               /dev/sda4  VG Name               lvm-1  PV Size               82.77 GB / not usable 1018.50 KB  Allocatable           yes  PE Size (KByte)       4096  Total PE              21189  Free PE               21189  Allocated PE          0  PV UUID               LbLZMT-g4u2-9Oz0-Eibi-izvd-tLc8-qx0TeI
8. create logic volume
linux-me6t:~ # lvcreate -L 20G  lvm-1
File descriptor 4 left open
File descriptor 9 left open
File descriptor 10 left open
File descriptor 11 left open
File descriptor 12 left open
  Logical volume "lvol0" created
--------note: for above, it create a logic volume of 20G size, and the name is given automatically.
and we can check and see the newly device(it is a virtual device)
inux-me6t:~ # ls -l /dev/lvm*total 0lrwxrwxrwx 1 root root 24 Jan 23 03:25 lvol0 -> /dev/mapper/lvm--1-lvol0linux-me6t:~ #
9. create file system
linux-me6t:~ # mkfs.ext3 /dev/mapper/lvm--1-lvol0mke2fs 1.41.1 (01-Sep-2008)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)1310720 inodes, 5242880 blocks262144 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,        4096000Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 31 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.
9. mount it and it is ready for use
linux-me6t:/ # mkdir lvmlinux-me6t:/ # mount  /dev/mapper/lvm--1-lvol0  /lvmlinux-me6t:/ # df -hFilesystem            Size  Used Avail Use% Mounted on/dev/sda3              20G   19G  317M  99% /udev                  499M  228K  499M   1% /dev/dev/sda1              20G  6.1G   14G  31% /windows/C/dev/sda5              49G   22G   28G  45% /windows/D/dev/sda6             103G   95G  7.3G  93% /windows/E/dev/sr0              4.4G  4.4G     0 100% /media/SU1110.001/dev/mapper/lvm--1-lvol0                       20G  173M   19G   1% /lvmlinux-me6t:/ #
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/68079/showart_1807138.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP