Results 1 to 10 of 25

Thread: How To LVM in Mythbuntu

Threaded View

  1. #1
    Join Date
    Oct 2007
    Sioux Falls, SD
    Ubuntu 7.10 Gutsy Gibbon

    Talking How To LVM in Mythbuntu

    Hello, Here is my first contribution to the cause! I am not sure if this is the best spot for this type of a thing, but at least it may help someone!

    After installing Mythubuntu RC I manually configured lvm.

    What is lvm?

    It lets you span partitions into on large volume so that one can add more space later on.

    In the below example we have two disks sda sdb and we want to create a lvm partition on sdb and include sda3 in that lvm so that the /var/lib directory is mounted on lvm partition. This means that /var/lib will span sdb1 and sda3. When I installed Mythbuntu I manually created the partitions and sda1 mounts / (root) and sda2 is swap with sda3 as the /var/lib partition. This was similar to the way Feisty installs were done in the old days. It is also important that the sdb partition be large enough to hold all of /var/lib
    df -h will display the used space in mounted partitions. In my case I deleted all the recordings so that I could fit it on sdb only around 20 GB in my case.
    df -h
    All connections to myth box should use sudo after terminal is open:
    sudo -i

    1. Open a terminal window or SSH into myth box.
    2. Get LVM2 from apt-get
      apt-get install lvm2
    3. Reboot Note: I had to anyway because it messed with the kernel or boot or something
      shutdown -r now
    4. setup an lvm partition. Note: this example assumes that the sdb disk is empty!
      Remember that fdisk can really mess up your existing partitions so know what you are doing before you start doing this stuff! You have been warned!!!!
      fdisk /dev/sdb
    5. At Command (m for help): type n
    6. At Command action
      e extended
      p primary partition (1-4) type p
    7. At Partition number (1-4): type 1
    8. At First cylinder (1-19457, default 1): (press Enter for default)
    9. At Last cylinder or +size or +sizeM or +sizeK (1-19457, default 19457): (Press Enter for default)
    10. At Command (m for help): type t
    11. At Hex code (type L to list codes): type 8e
    12. At Command (m for help): type w
    13. Create the physical volume.
      pvcreate /dev/sdb1

    Great we have a physical lvm partition sdb1 created!

    1. Now we have to create the lvm stuff for the volume.
      Note: Example below is for about 500 GB use the power of two to go to larger table sizes. use 16M for example is for over 1 TB volumes
      vgcreate -s 8M vg /dev/sdb1
    2. Get the vg lvm volume size
      vgdisplay vg | grep "Total PE"
      Display shows on my pc:
      Total PE 9543
      Use that value in cmd below replace 9543 with your value.

      lvcreate -l 9543 vg -n lib
    3. This starts the device mapper on startup. Not sure if this is needed or not, but will not hurt anything.
      modprobe dm-mod 
      echo dm-mod >> /etc/modules
    4. format the partition as xfs Note: LVM partitions created as XFS are difficult to size down, so note that it may not be possible to make smaller very easy, at least that is what I heard on the net. Anyway why would you want to remove space from your lvm. I can only see it getting bigger so that I can store more stuff on it.
      mkfs.xfs -f /dev/vg/lib
    5. Make a mount point and mount.
      mkdir /mnt/sdb1
      mount /dev/vg/lib /mnt/sdb1
      Note: It may be wise to stop myth back-end and mysql at this point, but I did not but do not do this step or following steps why recording anything.
    6. copy all from /var/lib into mounted sdb1.
      cp -p -r /var/lib/* /mnt/sdb1
    7. Make a copy of fstab
      cp /etc/fstab /etc/fstab.backup
    8. Fix fstab to mount lvm vg-lib as /var/lib
      nano /etc/fstab
    9. Comment out your current /var/lib in fstab
      line looks like #UUID=3aa29488-1c13-4042-a246-3f317aa7ddf7 /var/lib xfs defaults in my fstab
    10. Add the new mount-point for xfs lvm partition in fstab file. Iplaced it at the bottom of the file.
      /dev/mapper/vg-lib /var/lib xfs defaults 0 1
      save the fstab file.

      Here is my fstab when done.
      # /etc/fstab: static file system information.
      # <file system> <mount point> <type> <options> <dump> <pass>
      proc /proc proc defaults 0 0
      # /dev/sda1
      UUID=682462da-1414-48a7-8614-21c45ba68529 / ext3 defaults,erro$
      # /dev/sdb1
      # UUID=d790b268-b2af-4380-92f4-e1a8192fbd65 /var/lib xfs defaults $
      # /dev/sda2
      UUID=f9e95dd5-155e-4100-b34c-0725ccfc92d9 none swap sw $
      /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0
      /dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec 0 0

      # mount lvm vg-lib as /var/lib
      /dev/mapper/vg-lib /var/lib xfs defaults 0 1
    11. reboot the system and confirm var/lib is there. If it is not then set the fstab back so
      that you can recopy it to /mnt/sdb1
      ls /var/lib
      Almost done!
      Now add the space taken up by sda3 to the volume group.
    12. fix sda3 with fdisk.
      fdisk /dev/sda
    13. At Command (m for help): type d
    14. At Partition number (1-4): type 3
    15. At Command (m for help): type n
    16. At Command action
      e extended
      p primary partition (1-4): type p
    17. At Partition number (1-4): type 3
    18. At First cylinder (1-19457, default 1): (press Enter for default)
    19. At Last cylinder or +size or +sizeM or +sizeK (1-19457, default 19457): (Press Enter for default)
    20. At Command (m for help): type t
    21. At Partition number (1-4): type 3
    22. At Hex code (type L to list codes): type 8e
      Changed system type of partition 3 to 8e (Linux LVM)
    23. At Command (m for help):type w
    24. Finish creating the partition
      pvcreate /dev/sda3
    25. Extend the vg lvm partition
      vgextend vg /dev/sda3
      note the line:
      Free PE / Size 2925 / 11.43 GB
    26. extend the vg lvm by the amount indicated above in my case 2925 so that is the +2925 below it is important to use your value not mine.
      lvextend -l+2925 /dev/vg/lib
    27. extend xfs
      xfs_growfs /var/lib
    28. confirm sizes
      df -h
    29. reboot
      shutdown -r now
    Last edited by apauna; October 21st, 2007 at 07:49 AM. Reason: forgot to mention sudo -i and fstab


Posting Permissions

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