Sunday, April 28, 2024
60
rated 0 times [  60] [ 0]  / answers: 1 / hits: 87489  / 3 Years ago, sun, may 30, 2021, 2:43:00

I'm sure this has been answered somewhere on here before (I even found kinda a guide here, but seemed to be a bit spotty and incomplete) but I was wondering if someone could assist me or at least point me in the right direction to get what I'm trying done accomplished.



Basically I installed Ubuntu 14.04 (via "Guided - use the entire disk and setup LVM") on a 20GB disk. I then physically added a clean 80GB disk to the machine, which it detects as 'sdb'.



Basically my question is, I want to be able to add/combine the allocated amount of space from the new disk (80GB) to my machine so that instead of showing two drives (20GB and 80GB), it simply shows one drive (100GB). I'm not worried about RAID or any other special add-ons.



I'm somewhat new to Linux, but understand that I need to use LVM to accomplish this.



If there is anyone who can help me out or link me to a helpful guide/tutorial, it would be very much appreciated! Not sure if this is needed either, but here is my 'fdisk -l' and '/etc/fstab' output:



fdisk output (shortened):



Disk /dev/sda: 21.5 GB, 21474836480 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 41940991 20719617 5 Extended
/dev/sda5 501760 41940991 20719616 8e Linux LVM

Disk /dev/sdb: 85.9 GB, 85899345920 bytes
Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/mapper/ubuntu--vg-root: 20.4 GB, 20392706048 bytes
Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition table

Disk /dev/mapper/ubuntu--vg-swap_1: 801 MB, 801112064 bytes
Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table


/etc/fstab (shortened):



# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=26710773-7a64-4f34-a34e-0057cb1739d7 /boot ext2 defaults 0 2
/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0

More From » partitioning

 Answers
5

After reviewing a combination of random guides and tutorials on the net, I was able to successfully add a disk to my Ubuntu Server 14.04 machine, and essentially set it up so I have multiple hard drives appearing as one single drive. To do this, I used LVM.



To help anyone else who might want to do this at some point, I will post here what I did.






These steps assume that you are essentially starting from scratch except having already installed Ubuntu on your machine (via "Guided - use the entire disk and setup LVM"), and physically added the additional disk. These steps may work if you have existing data on the machine but I can't say for sure if it would be safe to do this.



These commands assume the following information, and will vary depending on your setup:




  • Your new disk is 'sdb'


    • This can be found by running ls /dev/sd*


  • That your volume group name is 'ubuntu-vg'


    • This can be found by running vgdisplay


  • That your logical volume path is '/dev/ubuntu-vg/root'


    • This can be found by running lvdisplay


  • Your new disk is 20GB


    • Hopefully you know how big the disk is.








  1. Install Logical Volume Manager (you may or may not need to do this).



    sudo apt-get install system-config-lvm

  2. Convert your new disk to a physical volume (in this case, the new disk is 'sdb').



    sudo pvcreate /dev/sdb

  3. Add the physical volume to the volume group via 'vgextend'.



    sudo vgextend ubuntu-vg /dev/sdb

  4. Allocate the physical volume to a logical volume (extend the volume size by your new disk size).



    sudo lvextend -l +100%FREE /dev/ubuntu-vg/root

  5. Resize the file system on the logical volume so it uses the additional space.



    sudo resize2fs /dev/ubuntu-vg/root



That should do it. Five simple steps! You also don't have to reboot. Just run df -h and your new disk space should show allocated correctly, as well as any webapps you may be running will pick up the new disk space amount.


[#25527] Monday, May 31, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
otputler

Total Points: 53
Total Questions: 105
Total Answers: 93

Location: Zimbabwe
Member since Wed, Nov 9, 2022
2 Years ago
otputler questions
Tue, Aug 23, 22, 14:36, 2 Years ago
Fri, Jul 23, 21, 11:57, 3 Years ago
Sun, Feb 12, 23, 18:37, 1 Year ago
;