Tuesday, February 24, 2009

Create New Linux EXT3 File System In LVM



This is another 3-minutes Linux guide for newbie on How to create or add new Linux EXT3 file system in Logical Volume Manager (LVM) with a new disk partition, which involves creating new logical volume (LV)?




How to create new Linux EXT3 file system in LVM with new hard disk by creating new logical volume?

Assuming a new IDE hard disk hooked up to Secondary-Slave IDE bus for the new logical volume / file system. Hence, the Linux device code will be /dev/hdd for this IDE hard disk, according to LANANA Linux Device List or the offline copy in /usr/src/linux-2.x/Documentation/devices.txt
  1. Using the whole secondary-slave IDE hard disk for existing LVM volume group (called vg0 in my case) by creating the physical volume (PV):
    pvcreate /dev/hdd

    A similar message of this will be shown upon successful execution of pvcreate command:

    pvcreate — physical volume “/dev/hdd” successfully created
  2. Adding the new physical volume (PV) to volume group vg0, i.e. to extend the existing volume group size with new physical volume:
    vgextend vg0 /dev/hdd

    If no errors encounter while executing vgextend, a similar message of this will be seen:

    vgextend — INFO: maximum logical volume size is 1023.97 Gigabyte
    vgextend — doing automatic backup of volume group “vg0″
    vgextend — volume group “vg0″ successfully extended

  3. Create the new logical volume (LV) at 400MB (not fully utilize the whole IDE hard disk) to host the new EXT3 file system in question:
    lvcreate -L 400M -n lvol1 vg0

    Suppose lvcreate completed successfully, this similar message will be seen:

    lvcreate — doing automatic backup of “vg0″
    lvcreate — logical volume “/dev/vg0/lvol1″ successfully created

  4. Now, create the new EXT3 file system on the new logical volume (LV) with 1% file system reserved block count:
    mkfs -t ext3 -m 1 -v /dev/vg0/lvol1

    Once the new EXT3 file system creation completed, you can examine the file system by executing

    tune2fs -l /dev/vg0/lvol1
  5. Create a mount point directory for the new EXT3 file system:
    mkdir /mnt/newfs
  6. It’s now ready to mount the new EXT3 file system:
    mount -t ext3 /dev/vg0/lvol1 /mnt/newfs

    To confirm that the new EXT3 file system has been mounted successful, type df -h

No comments: