Find the answer to your Linux question:
Results 1 to 4 of 4
Hello all, Is there any way to simulate physical volume in linux using files? Like we can simulate a logical volume and create a FS on it using files in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    6

    Can we simulate physical volumes in LINUX


    Hello all,

    Is there any way to simulate physical volume in linux using files? Like we can simulate a logical volume and create a FS on it using files in the same way..

  2. #2
    Linux Guru gogalthorp's Avatar
    Join Date
    Oct 2006
    Location
    West (by God) Virginia
    Posts
    3,104
    I don't understand the question. Maybe you can explain what you want to do.

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,754
    Google: dd loopback block device

    Code:
    If you have LVM on top of Raid5, you can easily add another volume to the array by using the various resize functions.
    
    Here's a working example you can run as root.  Start in a fresh directory somewhere.
    
    Steps:
    1. Create the initial array using three 100MB loopback devices
    2. Create an LVM volume
    3. Format it with reiserfs, mount it, then add a file.
    4. Create a new 100MB loopback device and expand the raid array with it.
    5. Resize raid, lvm, and reiserfs (note that this is done LIVE, while the device is still mounted)
    6. Tear down everything since this is just for practice.
    
    Be sure to step through each line individually so you understand how it works.  Especially take care with lvcreate and lvresize.  Be sure to use vgdisplay first to see how many extents you have available.  In this example, you start with 49 and later add another 25.
    
    Steps 1-5: Build the array+lvm, then resize them.
    
    mkdir mnt
    dd if=/dev/zero of=raid-0 bs=10240 count=10240
    cp raid-0 raid-1
    cp raid-0 raid-2
    losetup /dev/loop0 raid-0
    losetup /dev/loop1 raid-1
    losetup /dev/loop2 raid-2
    mdadm --create --verbose /dev/md0 -l5 -n3 /dev/loop0 /dev/loop1 /dev/loop2
    pvcreate /dev/md0
    vgcreate lvm-test /dev/md0
    vgdisplay lvm-test
    lvcreate -l 49 lvm-test -n lvm0
    mkreiserfs /dev/lvm-test/lvm0
    mount /dev/lvm-test/lvm0 mnt
    dd if=/dev/zero of=mnt/testfile.bin bs=1024 count=10240
    mdadm --grow /dev/md0 -n4 --backup-file=raidbackup
    dd if=/dev/zero of=raid-3 bs=10240 count=10240
    losetup /dev/loop3 raid-3
    mdadm -a /dev/md0 /dev/loop3
    pvresize /dev/md0
    vgdisplay lvm-test
    lvresize -l +25 /dev/lvm-test/lvm0
    resize_reiserfs -s 296M /dev/lvm-test/lvm0
    
    
    Step 6: Teardown and cleanup (destroys the array and cleans up everything you did):
    
    umount mnt
    lvremove -f lvm-test
    vgremove lvm-test
    mdadm --stop /dev/md0
    mdadm --remove /dev/md0
    losetup -d /dev/loop0
    losetup -d /dev/loop1
    losetup -d /dev/loop2
    losetup -d /dev/loop3
    rm raid-0 raid-1 raid-2 raid-3
    rmdir mnt

  4. #4
    Just Joined!
    Join Date
    Nov 2009
    Posts
    6
    I am using SUSE 11.1 and I have only one hard drive..

    I dont have free partions on my disk. Using loopback devices can I simulate virtual PV's? (Here a PV may be a file) and I am not using any RAID.

    By creating data files of some size (2 or more) can we treat them as PV's and create LV and FS on it? (which will be useful for testing or as LAB purpose)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •