First of all, a primary partition for LVM should be created on HDD with fdisk command.
# fdisk /dev/sdb
The number of cylinders for this disk is set to 60801.
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)
* p is a command for printing information.
Command (m for help): p
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801):
Using default value 60801
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
* 8e is a code of LVM partition.
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 60801 488384001 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Please note a Hex code of the LVM is 8e.
Physical volume should be created with pvcreate command.
# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created
Volume Group should be created with pvcreate command.
# vgcreate usbvg /dev/sdb1 Volume group "usbvg" successfully created
Logical Volume should be created with pvcreate command. It's going to be logical partition which you will use as real partition.
# lvcreate -L 15G -n usb_15g usbvg Logical volume "usb_15g" created
# mke2fs -j /dev/usbvg/usb_15g mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 1966080 inodes, 3932160 blocks 196608 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4026531840 120 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 21 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
# mount -t ext3 /dev/usbvg/usb_15g /mnt/usb_15/