# Add another HDD to GPT and LVM

**URL:** <https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751>\
**Category:** Rocky Linux Help & Support\
**Tags:** rocky-linux-9\
**Created:** [December 5, 2024, 4:02pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751 "2024-12-05T16:02:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafa](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mostafa](https://forums.rockylinux.org/u/mostafa)\
**Post date:** [December 5, 2024, 4:02pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/1 "2024-12-05T16:02:51Z")

</div>

I have Rocky Linux 9 and right now I have

```auto
df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 12G 0 12G 0% /dev/shm
tmpfs 4.7G 8.8M 4.7G 1% /run
efivarfs 256K 28K 223K 12% /sys/firmware/efi/efivars
/dev/mapper/rl-root 220G 3.4G 217G 2% /
/dev/sdb2 960M 273M 688M 29% /boot
/dev/sdb1 599M 7.1M 592M 2% /boot/efi
tmpfs 2.4G 0 2.4G 0% /run/user/0

```

I add another HDD to this server and I see

```auto
lsblk 
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 240G 0 disk 
sdb 8:16 0 240G 0 disk 
├─sdb1 8:17 0 600M 0 part /boot/efi
├─sdb2 8:18 0 1G 0 part /boot
└─sdb3 8:19 0 238.4G 0 part 
  ├─rl-root 253:0 0 219.8G 0 lvm /
  └─rl-swap 253:1 0 1.6G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom  

```

I see too

```auto
fdisk -l
Disk /dev/sdb: 240 GiB, 257698038272 bytes, 503316481 sectors
Disk model: Virtual disk    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B133D9B5-CF8F-4786-BE67-B0734B59F71D

Device Start End Sectors Size Type
/dev/sdb1 2048 1230847 1228800 600M EFI System
/dev/sdb2 1230848 3327999 2097152 1G Linux filesystem
/dev/sdb3 3328000 503316447 499988448 238.4G Linux LVM

Disk /dev/sda: 240 GiB, 257698037760 bytes, 503316480 sectors
Disk model: Virtual disk    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/rl-root: 219.81 GiB, 236017680384 bytes, 460972032 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/rl-swap: 1.6 GiB, 1719664640 bytes, 3358720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

```

I want add this

```auto
sda

```

to this disk and after that add it to

```auto
/dev/mapper/rl-root

```

and I want have 480GB after that

---

<div class="post-metadata">

**Author:** ![hs303](https://avatars.discourse-cdn.com/v4/letter/h/e47774/32.png) [@hs303](https://forums.rockylinux.org/u/hs303)\
**Post date:** [December 5, 2024, 6:23pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/2 "2024-12-05T18:23:41Z")

</div>

You need to create a physical volume (`PV`), add it to your volume group (`VG`), expand the logical volume (`LV`) and grow the file system.

- Create a partition table and an empty partition. `gdisk /dev/sda`. Once in interactive mode, hit `o` to create a `GPT` partition table, than hit `n` to create an empty partition: just go with the defaults and use `8E00` as partition type (it stands for `LVM`). Hit `w` to commit the changes to the disk. This step could be omitted and you could create the `PV` on the raw disk, but I prefer to create a partition table for consistency - it may look weird and confuse some admins or tools. If you prefer to omit this step, just run below commands on `/dev/sda` instead of `/dev/sda1`.
- Create the `PV` with `pvcreate /dev/sda1`. You can verify it by `pvdisplay /dev/sda1`.
- Find out the name of your `VG` by running `vgdisplay`. Than run `vgextend <name of your vg> /dev/sda1`. Verify with `vgdisplay`.
- Expand your `LV` by the amount you need. `lvextend -L +50G /dev/mapper/rl-root` (adjust the size on `-L` to your needs).  
Consider not commiting the whole disk now, if you do not need it. `xfs` cannot be shrunk and if you should want to create another partition at some point in the future you will not be able to.
- Grow the file system with `xfs_growfs /`.

You need to run the commands as `root` or with `sudo`. Be aware that the disk will be wiped by writing a new partition table. So be sure you run the commands on the right disk. If possible, do a backup because any operations on the disks come with some risk.

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [December 5, 2024, 6:33pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/3 "2024-12-05T18:33:49Z")

</div>

> [@hs303](#):
>
> do a backup

And keep doing them in the future too. After all, if either HDD fails, then the entire `/dev/mapper/rl-root` dies.

---

<div class="post-metadata">

**Author:** ![gerry666uk](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gerry666uk](https://forums.rockylinux.org/u/gerry666uk)\
**Post date:** [December 5, 2024, 10:46pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/4 "2024-12-05T22:46:20Z")

</div>

Yes, this looks risky to me. A filesystem spanning two physical disks?

---

<div class="post-metadata">

**Author:** ![mostafa](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mostafa](https://forums.rockylinux.org/u/mostafa)\
**Post date:** [December 6, 2024, 8:25am UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/5 "2024-12-06T08:25:32Z")

</div>

What is best solution?

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [December 6, 2024, 6:03pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/6 "2024-12-06T18:03:47Z")

</div>

Solution for what? Getting the space in use or backups?

* * *

A convenience of big filesystem volume is that any subset of data can grow to use (all) space.

A benefit of multiple small filesystem volumes is that no subset of data can grow to use space of other subsets. The downside is that some volumes may be unnecessarily big and unused space in them is “wasted”. One should thus predict wisely, if one wants multiple volumes as resizing volumes can become tricky (e.g. one cannot shrink XFS).

* * *

A system has basically three things:

- system files (installed from packages)
- config (configuration systems can make logical copy of it that is trivial to redeploy and easy to backup)
- user data (that is the most valuable piece and also least predictable)

* * *

The default install creates ‘rl-root’ and ‘rl-home’, for `/` and `/home`. The latter has only “user data”. The latter is also example of mounting an additional filesystem (into the directory hierarchy) where “extra” space is required.

Lets say that the largest “user data” will be a Postgresql database that may need almost 240 GB.  
One could create a partition into the second HDD (either plain partition or PV for new VG that has LV). Then mount that to `/var/lib/pgsql`, before installing the Postgresql packages. Now all of the SQL database will be in the “sda”, while system remains in “sdb”.

If the “sda” breaks, you get a new HDD, recreate filesystem, mount it to `/var/lib/pgsql` and restore database contents from backup.

If the “sdb” breaks, you get a new HDD, reinstall Rocky, mount “sda” to `/var/lib/pgsql` and restore rest of config and userdata that were in sda from backups.

---

<div class="post-metadata">

**Author:** ![gerry666uk](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gerry666uk](https://forums.rockylinux.org/u/gerry666uk)\
**Post date:** [December 6, 2024, 7:35pm UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/7 "2024-12-06T19:35:30Z")

</div>

In addition, looking at the original post, isn’t there supposed to be a ‘/home’ mount point too?

---

<div class="post-metadata">

**Author:** ![hs303](https://avatars.discourse-cdn.com/v4/letter/h/e47774/32.png) [@hs303](https://forums.rockylinux.org/u/hs303)\
**Post date:** [December 7, 2024, 12:52am UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/8 "2024-12-07T00:52:21Z")

</div>

It is not mandatory.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [February 5, 2025, 12:53am UTC](https://forums.rockylinux.org/t/add-another-hdd-to-gpt-and-lvm/16751/9 "2025-02-05T00:53:02Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
