Chinaunix首页 | 论坛 | 博客
  • 博客访问: 128995
  • 博文数量: 30
  • 博客积分: 2090
  • 博客等级: 大尉
  • 技术积分: 301
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-27 09:11
文章分类

全部博文(30)

文章存档

2011年(2)

2010年(2)

2009年(5)

2008年(21)

我的朋友

分类: LINUX

2008-07-01 16:16:11

1.首先创建LVM格式的分区,在此我们用fdisk命令。

suselinux:~ # uname -a
Linux suselinux 2.6.5-7.97-default #1 Fri Jul 2 14:21:59 UTC 2004 i686 i686 i386 GNU/Linux
suselinux:~ # fdisk -l
Disk /dev/hda: 10.4 GB, 10485522432 bytes
16 heads, 63 sectors/track, 20317 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1       10403     5243080+  83  Linux
/dev/hda2           10404       12484     1048824   82  Linux swap
suselinux:~ # fdisk /dev/hda
The number of cylinders for this disk is set to 20317.
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): n 
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 3
First cylinder (12485-20317, default 12485):
Using default value 12485
Last cylinder or +size or +sizeM or +sizeK (12485-20317, default 20317):
Using default value 20317
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (12485-20317, default 12485):
Using default value 12485
Last cylinder or +size or +sizeM or +sizeK (12485-20317, default 20317): +100M
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (12680-20317, default 12680):
Using default value 12680
Last cylinder or +size or +sizeM or +sizeK (12680-20317, default 20317): +200M
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (13069-20317, default 13069):
Using default value 13069
Last cylinder or +size or +sizeM or +sizeK (13069-20317, default 20317): +300M
Command (m for help): t
Partition number (1-7): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/hda: 10.4 GB, 10485522432 bytes
16 heads, 63 sectors/track, 20317 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1       10403     5243080+  83  Linux
/dev/hda2           10404       12484     1048824   82  Linux swap
/dev/hda3           12485       20317     3947832    5  Extended
/dev/hda5           12485       12679       98248+  8e  Linux LVM
/dev/hda6           12680       13068      196024+  8e  Linux LVM
/dev/hda7           13069       13650      293296+  8e  Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
suselinux:~ # shutdown -fr now
Broadcast message from root (pts/0) (Tue Jul  1 23:35:41 2008):
The system is going down for reboot NOW!
 
2.创建PV
 
suselinux:~ # fdisk -l
Disk /dev/hda: 10.4 GB, 10485522432 bytes
16 heads, 63 sectors/track, 20317 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1       10403     5243080+  83  Linux
/dev/hda2           10404       12484     1048824   82  Linux swap
/dev/hda3           12485       13647      586152    5  Extended
/dev/hda5           12485       12678       97744+  8e  Linux LVM
/dev/hda6           12679       13066      195520+  8e  Linux LVM
/dev/hda7           13067       13647      292792+  8e  Linux LVM
suselinux:~ # pvcreate /dev/hda5
  No physical volume label read from /dev/hda5
  Physical volume "/dev/hda5" successfully created
suselinux:~ # pvcreate /dev/hda6
  No physical volume label read from /dev/hda6
  Physical volume "/dev/hda6" successfully created
suselinux:~ # pvcreate /dev/hda7
  No physical volume label read from /dev/hda7
  Physical volume "/dev/hda7" successfully created
suselinux:~ # pvscan
  PV /dev/hda5         lvm2 [95.76 MB]
  PV /dev/hda6         lvm2 [191.24 MB]
  PV /dev/hda7         lvm2 [286.23 MB]
  Total: 3 [573.24 MB] / in use: 0 [0   ] / in no VG: 3 [573.24 MB]
 
3.创建VG
 
suselinux:~ # vgcreate testvg /dev/hda5 /dev/hda6
  Volume group "testvg" successfully created
suselinux:~ # vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "testvg" using metadata type lvm2
suselinux:~ # vgdisplay -v
    Finding all volume groups
    Finding volume group "testvg"
  --- Volume group ---
  VG Name               testvg
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                255
  Cur LV                0
  Open LV               0
  Max PV                255
  Cur PV                2
  Act PV                2
  VG Size               280.00 MB
  PE Size               4.00 MB
  Total PE              70
  Alloc PE / Size       0 / 0  
  Free  PE / Size       70 / 280.00 MB
  VG UUID               uQAOsM-QLEA-Eezz-tMr0-1WRY-kQ3i-WT0YKp
  
  --- Physical volumes ---
  PV Name               /dev/hda5    
  PV UUID               FThAaT-LgGU-R8l4-awX8-LUJe-IYTZ-C5R896
  PV Status             allocatable
  Total PE / Free PE    23 / 23
  
  PV Name               /dev/hda6    
  PV UUID               1Y7jV1-FyP7-h1vs-qkWQ-Kx5X-8u9Q-3YBZbo
  PV Status             allocatable
  Total PE / Free PE    47 / 47
  
4.创建LV
 
suselinux:~ # lvcreate -l 23 -n testlv1 testvg /dev/hda5
  Logical volume "testlv1" created
suselinux:~ # lvcreate -L 188M testvg /dev/hda6
  Logical volume "lvol0" created
suselinux:~ # lvdisplay
  --- Logical volume ---
  LV Name                /dev/testvg/testlv1
  VG Name                testvg
  LV UUID                VLle39-nwZn-HnvM-n1Gh-SS7b-cv8R-52h5vC
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                92.00 MB
  Current LE             23
  Segments               1
  Allocation             next free (default)
  Read ahead sectors     0
  Block device           253:0
  
  --- Logical volume ---
  LV Name                /dev/testvg/lvol0
  VG Name                testvg
  LV UUID                MuuTIA-aDQ2-CdGA-s6ko-jAr9-ms73-7zjoNB
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                188.00 MB
  Current LE             47
  Segments               1
  Allocation             next free (default)
  Read ahead sectors     0
  Block device           253:1
  
5.创建文件系统
 
suselinux:~ # mkfs -t ext3 /dev/testvg/testlv1
mke2fs 1.34 (25-Jul-2003)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
23616 inodes, 94208 blocks
4710 blocks (5.00%) reserved for the super user
First data block=1
12 block groups
8192 blocks per group, 8192 fragments per group
1968 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729
Writing inode tables: done                           
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
suselinux:~ # mkreiserfs -l fs2 /dev/testvg/lvol0
mkreiserfs 3.6.13 (2003 )
A pair of credits:
Vladimir Demidov wrote the parser for sys_reiser4(), the V3 alpha port, part of
the V3  journal  relocation code,  and helped  Hans keep  the business  side of
things running.
Oleg Drokin was the debugger for  V3 during most of the time that  V4 was under
development,  and was quite  skilled and fast at it.  He wrote  the large write
optimization of V3.

Guessing about desired format.. Kernel 2.6.5-7.97-default is running.
Format 3.6 with standard journal
Count of blocks on the device: 48128
Number of blocks consumed by mkreiserfs formatting process: 8213
Blocksize: 4096
Hash function used to sort names: "r5"
Journal Size 8193 blocks (first block 18)
Journal Max transaction length 1024
inode generation number: 0
UUID: c3f79adc-0cc8-42c2-92ee-9141c1ac7177
LABEL: fs2
ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
        ALL DATA WILL BE LOST ON '/dev/testvg/lvol0'!
Continue (y/n):y
Initializing journal - 0%....20%....40%....60%....80%....100%
Syncing..ok
ReiserFS is successfully created on /dev/testvg/lvol0.
suselinux:~ # mkdir /fs1 /fs2
mkdir: cannot create directory `/fs1': File exists
mkdir: cannot create directory `/fs2': File exists
suselinux:~ # mkdir /fs1
mkdir: cannot create directory `/fs1': File exists
suselinux:~ # mount /dev/testvg/testlv1 /fs1
suselinux:~ # mount /dev/testvg/lvol0 /fs2
suselinux:~ # mount
/dev/hda1 on / type reiserfs (rw,acl,user_xattr)
proc on /proc type proc (rw)
tmpfs on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hdc on /media/dvd type subfs (ro,nosuid,nodev,fs=cdfss,procuid,iocharset=utf8)
/dev/fd0 on /media/floppy type subfs (rw,nosuid,nodev,sync,fs=floppyfss,procuid)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/mapper/testvg-testlv1 on /fs1 type ext3 (rw)
/dev/mapper/testvg-lvol0 on /fs2 type reiserfs (rw)
suselinux:~ # df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/hda1 reiserfs    5.1G  810M  4.3G  16% /
tmpfs        tmpfs    253M   12K  253M   1% /dev/shm
/dev/mapper/testvg-testlv1
              ext3     90M  4.1M   81M   5% /fs1
/dev/mapper/testvg-lvol0
          reiserfs    188M   33M  156M  18% /fs2
suselinux:~ #

 
阅读(4976) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~