How to add a Logical Volume (LV) for /var/tmp?

I’ve got one physical volume and one volume group:

/dev/mapper/nvme0n1p3_crypt
VG Name ced-vg

I’ve got five logical volumes:

/dev/ced-vg/root
/dev/ced-vg/var
/dev/ced-vg/swap_1
/dev/ced-vg/tmp
/dev/ced-vg/home

I want to add a sixth logical volume on that same, unique, physical volume (I’m not adding any new SSD), which could maybe look like this:

/dev/ced-vg/vartmp   (I don't know if the name is correct)

Which I’ll then use for /var/tmp/ to have its own logical volume.

I don’t know how to create that. I don’t understand if these logical volumes were created, once, when the OS was installed or if they’re (re-)created at each boot, for example.

Is it as simple as just adding an entry for /var/tmp in /etc/fstab?

Or do I need to first "create", once, the new logical volume and only then add the entry to /etc/fstab? Or something else?

Do I need to manually create a filesystem for that new /var/tmp I plan to add? Or shall this be done automatically?

P.S: This is on Debian but I take it the procedure is similar on many distros.

Asked By: Cedric Martin

||

You need to create a new logical volume of size 32GB with name "vartmp" using

lvcreate -L 32G -n vartmp ced-vg

That’s everything about this that’s LVM-specific! Then you can format it using your favorite file system, e.g.

mkfs.xfs /dev/ced-vg/vartmp

and add it to your /etc/fstab, so that it gets picked up on next boot, for example

/dev/ced-vg/vartmp /var/tmp   xfs   noatime

You might want to check the free space of your volume group first, using vgdisplay.

Answered By: Marcus Müller
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.