![]() The names can be choosen arbitrarily, and I used these names during installation just for simplicity.ĭo sudo fdisk -l to list all disks. The first ‘home’ in ‘home-home’ stands for the Volume Group (VG) and the second for the Logical Volume (LV) of the VG. dev/mapper/store-store 30T 27T 2.9T 90% /storeĪnd the two LVM dirs /home and /store show differently ( /dev/mapper/home-home and /dev/mapper/store-store) from physical volume like /opt in the first ‘Filesystem’ column. Use df -h to check current status of file systems, and we’ll get output like: Filesystem Size Used Avail Use% Mounted on And when the /store dir is about to be full, I added the 4-TB free space to it. A physical space of 4 TB was not in use at first. I created 2 LVs when installing Ubuntu Server 16.04 LTS on a computer: /home which is users’ home directory and /store for data storage. LV (logical volume): (virtual) volume created on VG.VG (volume group): (virtual) group based on at least one PV.PV (physical volume): actual disk or partions on it. ![]() For people who want to overcome volume shortage in their workstations/servers, it is a economic and brilliant choice. With LVM, however, we can combine different physical volumes together and always add new space to an exsiting LVM partition in principle. Traditionally, if we add a new hard drive to an exsiting Linux computer, we would assign a new mount point to the disk, and use some techniques to mount automatically at startup for convenience. The most attractive feature of LVM to me, is the capability to resize the disk volume dynamically. ![]() Since version 12.10, Ubuntu has introduced LVM support in the installation process. LVM (Logical Volume Manager) is a powerful tool for logical volume management on Linux systems. If no errors, then you’re all set.Be careful with your disk when reading this note and similar ones. Note: For all of the below commands, change “sdc” to match your disk’s identifier Convert the new disk to be an LVM physical volume pvcreate /dev/sdc Create the volume group vgcreate vg_extra /dev/sdc Check the volume group vgdisplay Create a logical volume (named lv_logs in this example) lvcreate vg_extra -L 5G -n lv_logs Format the logical volume mkfs.ext4 /dev/mapper/vg_extra-lv_logs Create a directory to mount the new logical volume mkdir /mnt/extra/logs Mount the logical volume mount /dev/mapper/vg_extra-lv_logs /mnt/extra/logs Find the “block id” of the new logical volume blkid /dev/mapper/vg_extra-lv_logs Back up your fstab file to be safe cp /etc/fstab /etc/fstab.bak Edit the fstab file nano /etc/fstab Add a line to the fstab to mount the volume, similar to this UUID= /mnt/extra/logs ext4 defaults 0 2 Test the new mount, first making sure it’s not mounted umount /mnt/extra/logs Then test your fstab file (BEFORE rebooting) mount -a ![]() Note: Make sure you change “sdb” to the identifier of your drive): pvcreate /dev/sdb Add the new physical volume to the volume group vgextend vg_ubuntu /dev/sdb Check the status vgdisplay Extend the physical volume by 10GB (or however many “GB” you want) lvextend -L +10G /dev/mapper/vg_ubuntu-lv_root Grow the logical volume with ALL of the available space, without specifying a particular size lvextend -resizefs -l +100%FREE /dev/mapper/vg_ubuntu-lv_root Grow the filesystem to match the newly available space resize2fs /dev/mapper/vg_ubuntu-lv_root Check current available space df -h Creating a brand-new LVM setupĪdd a new virtual or physical disk to the server. Convert the new disk to an LVM physical volume First, get a tiny bit of space back for tmp files (this command clears apt caches and etc): sudo apt clean Extend the logical volume lvextend -resizefs -l +100%FREE /dev/mapper/vg_ubuntu-lv_root Adding a disk to LVMĪfter adding a physical or virtual disk to the server, run the following commands.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |