Linux – Easiest way to change directory into its own logical volume in LVM2

linuxlvm

I have a dir called /mydir on logical volume /dev/vg1/lv_root ( / )

var is on its own logical volume, so is opt and /usr.. If I have free space in the volume group, what is the easiest way to change /mydir to make /mydir the mountpoint for a new logical volume in the vol group called /dev/vg1/lv_mydir ? Cent 6 EXT4 file system.

Edit: I havent created the new logical volume yet.

Best Answer

Just mount your /dev/vg1/lv_mydir to /mydir.

mount -t ext4 /dev/vg1/lv_mydir /mydir

As Adrian pointed out i assumed a lot, so yes if you have any files residing in current directory you will have to preserve them somewhere and then copy to the new mount. Also on the new LV you will need to create ext4 partition before mounting it.