Snott

Tag: lvm

  • How to move a system folder into a newly created LVM?

    How to move a system folder into a newly created LVM?

    Let’s say you need to mount /var into a different LVM, how do you do that on a running system?

    Change to root

    $ su

    # telinit 1

    telinit may be used to change the SysV system runlevel. Since the concept of SysV runlevels is obsolete the runlevel requests will be transparently translated into
    systemd unit activation requests (if you are using systemd of course!).

    # lvcreate -L 2G -n suse_var /dev/vg_Dell01

    create 2GB logical volume

    # mkfs -t reiserfs /dev/vg_Dell01/suse_var

    Format using Reiserfs (or whatever filesystem you need

    # mkdir /mnt/tmp
    # mount -t resierfs /dev/vg_Dell01/suse_var /mnt/tmp

    create a folder, and mount your new LVM there

    # cp -R /var /mnt/tmp
    # mv /var /var.old

    Copy everything over, rename the old var folder just in case something goes wrong

    # umount /mnt/tmp
    # rmdir /mnt/tmp

    Unmount LVM and remove mount point directory

    # mount -t resierfs /dev/vg_Dell01/suse_var /var

    Mount our new LVM, now this has all of our /var contents

    # vi /etc/fstab …..

    Edit /var mountpoint to point to your new LVM
    # mount -a

    EXTREMELY IMPORTANT, make sure you get no errors when running this, if you do, fix those errors before rebooting or the system won’t boot.

    # telinit 2

    You are done!