How to extend centos-root with new physical HDD?

Issues related to hardware problems
Post Reply
nark
Posts: 2
Joined: 2017/11/07 16:58:21

How to extend centos-root with new physical HDD?

Post by nark » 2017/11/07 17:11:10

Hello,
This is my first post in Centos.org Forums.

I have searched the forum for a solution for my situation but found none, so here it is:

I have a server running CentOS 7 where I host a mail, web and ftp software servers (sentora to be more specific)
In my server I have a 250Gb HDD that is at 90% full.
I have bought a 1Tb HDD and I want to extend /dev/mapper/centos-root partition.

And following are my 2 questions.

1. Should I clone the old HDD (250Gb) to the new one (1Tb)? If yes, how can I do it?
-or-
2. Can I somehow map the new HDD (1Tb) to the /dev/mapper/centos-root partition so that I wil have a total of 1,25Gb? If yes, how? :)

Here is my "lsblk" command:

Code: Select all

NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 232.9G  0 disk
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0 231.8G  0 part
  ├─centos-root 253:0    0   198G  0 lvm  /
  ├─centos-swap 253:1    0   3.9G  0 lvm  [SWAP]
  └─centos-home 253:2    0    30G  0 lvm  /home
sr0              11:0    1  1024M  0 rom
I have to mention I am not a guru in the linux-side, so please be as explicit as possible :)

Thanks in advanced!

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to extend centos-root with new physical HDD?

Post by TrevorH » 2017/11/07 18:49:33

Partition your new drive using fdisk or parted. Make the new partition an LVM volume (type 0x8e if using fdisk) and save the changes. Run pvcreate /dev/sdb1 (for example! Make sure you use the correct device name on your system, do not just blindly copy what I wrote!). Add the new PV you just created to the existing volume group using the vgextend command and then you can use lvextend -r ... on your existing /dev/mapper/centos-root to add more space to it.

The commands I list are mostly incomplete. You can find more detail about them by reading the man page (man vgextend for example) and you should read those before you start to run anything.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

nark
Posts: 2
Joined: 2017/11/07 16:58:21

Re: How to extend centos-root with new physical HDD?

Post by nark » 2017/11/07 20:23:11

Thank you for the reply. I will read the documentation for vgextend!

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How to extend centos-root with new physical HDD?

Post by jlehtone » 2017/11/07 23:31:10

nark wrote:1. Should I clone the old HDD (250Gb) to the new one (1Tb)? If yes, how can I do it?
-or-
2. Can I somehow map the new HDD (1Tb) to the /dev/mapper/centos-root partition so that I wil have a total of 1,25Gb? If yes, how? :)
There is also:

3. Create a separate filesystem into the new disk, transfer the "sentora" files into it, and then mount them back to original locations. Apart from setting mounts, selinux is likely to require some attention. You did not ask, so I won't be explicit.

The reason to consider separate filesystem is that now you have both OS and service in same filesystem. At some point a major OS upgrade might become relevant, but you cannot simply wipe your current centos-root, for it contains data too. Furthermore, when a filesystem spans multiple drives, the failure of any drive will corrupt the filesystem.

Whatever you do, or even if you do nothing, you surely have a solid backup?


PS. When a LVM volume group spans multiple drives, one can also move (rather than expand) logical volumes to other drive. In that sense you could "clone" the content of sda2 into the new drive, and after the move remove the sda2 from the volume group. The sda1 and boot record are different though.

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: How to extend centos-root with new physical HDD?

Post by scottro » 2017/11/08 11:59:03

I have a page, with links to better pages, about working with LVM that some have found useful.

http://srobb.net/lvm.html
New users should check the FAQ and Read Me First pages

Post Reply