# Работа с дисками

# Работа с дисками parted

Before allocation:

```
server:/$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.5G     0  1.5G   0% /dev
tmpfs           301M  1.1M  300M   1% /run
/dev/sda2        16G   13G  2.4G  84% /
tmpfs           1.5G     0  1.5G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.5G     0  1.5G   0% /sys/fs/cgroup
/dev/loop0       91M   91M     0 100% /snap/core/6350
tmpfs           301M     0  301M   0% /run/user/1000
```

Now extend the partition:

```
server:/$ sudo parted
[sudo] password for username:
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
<strong> 2      2097kB  17.2GB  17.2GB  ext4
</strong>(parted) resizepart 2
Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
Yes/No? Yes
End?  [17.2GB]? <strong>32.2GB</strong>
(parted) q
Information: You may need to update /etc/fstab.
```

5\. Thereafter, grow the filesystem using the *resize2fs:*

```
server:/$ sudo resize2fs /dev/sda2
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 4
The filesystem on /dev/sda2 is now 7860816 (4k) blocks long.
```

Finally, the disk capacity has increased:

```
server:/$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.5G     0  1.5G   0% /dev
tmpfs           301M  1.1M  300M   1% /run
/dev/sda2        30G   15G   14G  53% /
tmpfs           1.5G     0  1.5G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.5G     0  1.5G   0% /sys/fs/cgroup
/dev/loop0       91M   91M     0 100% /snap/core/6350
tmpfs           301M     0  301M   0% /run/user/1000
```

# Работа с дисками lvm

##### Команды с описанием

`df -h` - отображает статус дисков в файловой системе

`fdisk -l` - показать какие есть диски

`lsblk` - показать какие есть диски

`cfdisk /dev/sdb` - редактирование раздела sdb

`/etc/fstab` - тут прописываем новые диски

`mount /media/hdd2` - присоединяет диск, прописанный в файле *fstab* с именем *hdd2*

### Обновление инфы о дисках

```bash
echo 1 > /sys/block/sda/device/rescan
```

```bash
echo "- - -" | tee /sys/class/scsi_host/host*/scan
```

# How to add an extra second hard drive on Linux LVM and increase the size of storage

<div class="headline_area" id="bkmrk-author%3A%C2%A0vivek-gite%C2%A0l"><div class="byline"><span class="post_author_intro">Author:</span> <span class="post_author">Vivek Gite</span> <span class="post_date_intro">Last updated:</span> <span class="post_date date_modified" title="2023-08-06">August 6, 2023</span> [<span class="num_comments">48</span> comments](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/#comments)</div></div><div class="post_content" id="bkmrk-ihave-250gb-disk-ins"><div>  
</div>*<span class="drop_cap">I</span>have 250GB disk installed on my home Linux server. I just bought a brand new 250GB SATA disk and I want to add a new disk to my existing LVM volume to increase its size total size to 500GB. How do I add a disk to LVM and extend an LVM volume on Linux operating system?*  
<span id="bkmrk--1"></span>  
Logical volume management (LVM) creates an easy to use layer over physical disks. You can combine multiple disks and create logical storage volumes. This provides specific benefits such as:</div><div class="post_content" id="bkmrk--2"><div class="card"><div class="card-body">  
</div></div></div><div class="post_content" id="bkmrk-no-restriction-on-di"><div class="card" id="bkmrk--3"><div class="card-body"><div class="card-text">  
</div></div></div>1. No restriction on disk size
2. Increased disk throughput
3. Mirroring volumes for business critical data
4. Volume snapshots
5. Easy backups and restores using snapshots
6. Easy data relocation
7. Resizing storage pools (add or remove disks) without reformatting disks

This tutorial **shows you how to make partitioning, formatting, and add a new disk to LVM volume on Linux**. For demo purpose, I am using Ubuntu VM, but the commands remain same for bare metal or any other virtualization technology such as KVM, Xen, VMware and so on.</div>**Warning**: Be careful with lvm/mkfs.ext4 and other commands, and device names as wrong device name can wipe out all data. **Proceed with caution** and always keep full backups. The nixCraft or author is not responsible for data loss.

## Step 1 – Find out information about existing LVM

LVM Storage Management divided into three parts:

<div class="post_content" id="bkmrk-physical-volumes-%28pv">1. **Physical Volumes (PV)** – Actual disks (e.g. /dev/sda, /dev,sdb, /dev/vdb and so on)
2. **Volume Groups (VG)** – Physical volumes are combined into volume groups. (e.g. my\_vg = /dev/sda + /dev/sdb.)
3. **Logical Volumes (LV)** – A volume group is divided up into logical volumes (e.g. my\_vg divided into my\_vg/data, my\_vg/backups, my\_vg/home, my\_vg/mysqldb and so on)

</div>Type the following commands to find out information about each part.

### How to display physical volumes (pv)

Type the following pvs command to see info about physical volumes:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo pvs`  
Sample outputs:

<div class="post_content" id="bkmrk--4"><div class="wp-caption aligncenter">[![Fig.01: How to display information about LVM physical volumes](https://www.cyberciti.biz/media/new/faq/2017/02/pvs-command-to-display-lvm-physical-volumes.jpg)](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/pvs-command-to-display-lvm-physical-volumes/)</div></div>Fig.01: How to display information about LVM physical volumes

<div class="post_content" id="bkmrk-so-currently-my-lvm-"><div class="wp-caption aligncenter" id="bkmrk--5"></div>So currently my LVM include a physical volume (actual disk) called /dev/vda5. To see detailed attributes information, type:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo pvdisplay`  
Sample outputs:  
<div class="wp-caption aligncenter">[![Fig.02: See attributes of a physical volume (PV)](https://www.cyberciti.biz/media/new/faq/2017/02/pvdisplay-show.jpg)](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/pvdisplay-show/)</div></div>Fig.02: See attributes of a physical volume (PV)

<div class="post_content" id="bkmrk-from-above-output-it"><div class="wp-caption aligncenter" id="bkmrk--6"></div>From above output it is clear that our volume group named ubuntu-box-1-vg is made of a physical volume named /dev/vda5.</div>### How to display information about LVM volume Groups (vg)

Type any one of the following vgs command/vgdisplay command to see information about volume groups and its attributes:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo vgs`  
OR  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo vgdisplay`  
Sample outputs:

<div class="post_content" id="bkmrk--7"><div class="wp-caption aligncenter">[![Fig.03: How to see information about LVM volume groups (vg)](https://www.cyberciti.biz/media/new/faq/2017/02/howto-see-lvm-volume-groups-infomation.jpg)](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/howto-see-lvm-volume-groups-infomation/)</div></div>Fig.03: How to see information about LVM volume groups (vg)

<div class="post_content" id="bkmrk--8"><div class="wp-caption aligncenter" id="bkmrk--9"></div></div>### How to display information about LVM logical volume (lv)

Type any one of the following lvs command/lvdisplay command to see information about volume groups and its attributes:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo lvs`  
OR  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo lvdisplay`  
Sample outputs:

<div class="post_content" id="bkmrk--10"><div class="wp-caption aligncenter">[![Fig.04: How to display information about logical volumes (lv)](https://www.cyberciti.biz/media/new/faq/2017/02/howto-see-display-information-lvm-logical-volumes.jpg)](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/howto-see-display-information-lvm-logical-volumes/)</div></div>Fig.04: How to display information about logical volumes (lv)

<div class="post_content" id="bkmrk-my-ubuntu-box-1-vg-v"><div class="wp-caption aligncenter" id="bkmrk--11"></div>My ubuntu-box-1-vg volume group divided into two logical volumes:</div><div class="post_content" id="bkmrk-%2Fdev%2Fubuntu-box-1-vg">1. /dev/ubuntu-box-1-vg/root – Root file system
2. /dev/ubuntu-box-1-vg/swap\_1 – Swap space

</div>Based upon above commands, you can get a basic idea how LVM organizes storage device into Physical Volumes (PV), Volume Groups (VG), and Logical Volumes (LV):

<div class="post_content" id="bkmrk--12"><div class="wp-caption aligncenter">[![Fig.05: How LVM organizes storage device into Physical Volumes (PV), Volume Groups (VG), & Logical Volumes (LV)](https://www.cyberciti.biz/media/new/faq/2017/02/understanding-LVM-Architecture.jpg)](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/understanding-lvm-architecture/)</div></div>Fig.05: How LVM organizes storage device into Physical Volumes (PV), Volume Groups (VG), &amp; Logical Volumes (LV)

<div class="post_content" id="bkmrk--13"><div class="wp-caption aligncenter" id="bkmrk--14"></div></div>## Step 2 – Find out information about new disk

You need to add a new disk to your server. In this example, for demo purpose I added a new disk drive, and it has 5GiB size. To find out information about new disks run:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo fdisk -l`  
OR  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo fdisk -l | grep '^Disk /dev/'`  
Sample outputs:

<div class="post_content" id="bkmrk--15"><div class="wp-caption aligncenter">[![Fig.06: Find out installed disk names on Linux](https://www.cyberciti.biz/media/new/faq/2017/02/list-linux-disks-using-fdisk-lcommand.jpg)](https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/list-linux-disks-using-fdisk-lcommand/)</div></div>Fig.06: Find out installed disk names on Linux

<div class="post_content" id="bkmrk-another-option-is-to"><div class="wp-caption aligncenter" id="bkmrk--16"></div>Another option is to scan for all devices visible to LVM2:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo lvmdiskscan`  
Sample outputs:</div>```
  /dev/ram0                   [      64.00 MiB] 
  /dev/ubuntu-box-1-vg/root   [      37.49 GiB] 
  /dev/ram1                   [      64.00 MiB] 
  /dev/ubuntu-box-1-vg/swap_1 [       2.00 GiB] 
  /dev/vda1                   [     487.00 MiB] 
  /dev/ram2                   [      64.00 MiB] 
  /dev/ram3                   [      64.00 MiB] 
  /dev/ram4                   [      64.00 MiB] 
  /dev/ram5                   [      64.00 MiB] 
  /dev/vda5                   [      39.52 GiB] LVM physical volume
  /dev/ram6                   [      64.00 MiB] 
  /dev/ram7                   [      64.00 MiB] 
  /dev/ram8                   [      64.00 MiB] 
  /dev/ram9                   [      64.00 MiB] 
  /dev/ram10                  [      64.00 MiB] 
  /dev/ram11                  [      64.00 MiB] 
  /dev/ram12                  [      64.00 MiB] 
  /dev/ram13                  [      64.00 MiB] 
  /dev/ram14                  [      64.00 MiB] 
  /dev/ram15                  [      64.00 MiB] 
  /dev/vdb                    [       5.00 GiB] 
  2 disks
  18 partitions
  0 LVM physical volume whole disks
  1 LVM physical volume
```

## Step 3 – Create physical volumes (pv) on new disk named /dev/vdb

Type the following command:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo pvcreate /dev/vdb`  
Sample outputs:

```
  Physical volume "/dev/vdb" successfully created
```

Now run the following command to verify:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo lvmdiskscan -l`  
Sample outputs:

```
  WARNING: only considering LVM devices
  /dev/vda5                   [      39.52 GiB] LVM physical volume
  /dev/vdb                    [       5.00 GiB] LVM physical volume
  1 LVM physical volume whole disk
  1 LVM physical volume
```

## Step 4 – Add newly created pv named /dev/vdb to an existing lv

Type the following command to add a physical volume /dev/vdb to “ubuntu-box-1-vg” volume group:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo vgextend ubuntu-box-1-vg /dev/vdb`  
Sample outputs:

```
  Volume group "ubuntu-box-1-vg" successfully extended
```

Finally, you need extend the /dev/ubuntu-box-1-vg/root to create total 45GB (/dev/vdb (5G)+ existing /dev/ubuntu-box-1-vg/root (40G))  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo lvm lvextend -l +100%FREE /dev/ubuntu-box-1-vg/root`  
Sample outputs:

```
  Size of logical volume ubuntu-box-1-vg/root changed from 37.49 GiB (9597 extents) to 42.52 GiB (10885 extents).
  Logical volume root successfully resized.
```

However, if you run df -h or any other command you will still see /dev/ubuntu-box-1-vg/root as 40G. You need to run the following command to enlarge the filesystem created inside the “root” volume:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>sudo resize2fs -p /dev/mapper/ubuntu--box--1--vg-root`  
Sample outputs:

```
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/ubuntu--box--1--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 3
The filesystem on /dev/mapper/ubuntu--box--1--vg-root is now 11146240 (4k) blocks long.
```

Verify it again using the [df command](https://www.cyberciti.biz/faq/df-command-examples-in-linux-unix/ "How to use df command in Linux / Unix {with examples}") or mount command. For example:  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>mount<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>mount | <a href="https://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/" title="How to use grep command in Linux/ Unix with examples">grep</a> '/dev/mapper/ubuntu'`  
OR  
`<span class="normaluserprompt" title="The shell prompt usually ends in a $ sign and is not part of the command for the nonprivileged user.">$ </span>df -H`  
Sample outputs:

```
Filesystem                           Size  Used Avail Use% Mounted on
udev                                 1.1G     0  1.1G   0% /dev
tmpfs                                146M   12M  135M   9% /run
<strong>/dev/mapper/ubuntu--box--1--vg-root   45G  2.3G   41G   6% /</strong>
tmpfs                                512M     0  512M   0% /dev/shm
tmpfs                                5.3M     0  5.3M   0% /run/lock
tmpfs                                512M     0  512M   0% /sys/fs/cgroup
/dev/vda1                            495M  109M  361M  24% /boot
tmpfs                                103M     0  103M   0% /run/user/0
```

# Изменения размера раздела

## Complete Steps and Explanation

ssh to server, sudo -i to become root

Confirm there is a limited amount of disk space. In the output below, note the / (root) volume only has 3.9 GB disk space:

```
user@server:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 394M 1.1M 393M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 3.9G 3.2G 489M 87% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/loop0 89M 89M 0 100% /snap/core/7270
/dev/sda2 976M 77M 833M 9% /boot
/dev/loop1 90M 90M 0 100% /snap/core/7713
tmpfs 394M 0 394M 0% /run/user/1000
```

Next confirm in Linux that there is actually a lot more space available. As you will see from the output below, there is `24G` on the `/dev/sda3` volume. The other 1GB is used in the boot volume and the `BIOS boot`

```
user@server:~# fdisk -l
Disk /dev/loop0: 88.5 MiB, 92778496 bytes, 181208 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/loop1: 89 MiB, 93327360 bytes, 182280 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/sda: 25 GiB, 26843545600 bytes, 52428800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: ED41F7A6-5D09-457B-A55C-C7F1E30DE419

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 52426751 50325504 24G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
```

The one set of instructions referred to starting this process using `parted`, so parted log is below. The instructions as per Stack read something like:

*“First you need to run parted and use its resizepart command to expand the partition to use the whole disk, then run pvresize to tell LVM about the new space, then run lvresize to grow the logical volume, and finally resize2fs on the logical volume to grow the filesystem to use the new space. This can be done without a reboot.”*

Please note however I diverted slightly from these steps. The first command I learnt / used in parted, was just used to print the partition information:

```
user@server:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 26.8GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 1076MB 1074MB ext4
3 1076MB 26.8GB 25.8GB

(parted) quit
```

This was followed by me checking and re-checking information using fdisk and df -h to make sure I was understanding the current situation.

Then I finally started the procedure:

```
user@server:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart
Partition number? 3
End? [26.8GB]?
(parted) quit
Information: You may need to update /etc/fstab.
```

…

```
user@server:~# pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
```

At this point I tried using `lvresize` but couldn’t get it to work. It appears there is both `lvresize` and `lvextend`. As per the “microhowto.info” article:

*“The difference is that lvextend can only increase the size of a volume, whereas lvresize can increase or reduce it.”*

The first attempt at specifying 24GB did not work. After I completed the procedure I found that you can also specify a flag 100%, but unfortunately, I didn’t get that information in time and just ended up specifying 23GB. If I have the time I might try and use the 100% flag. For reference, the flag is `lvextend -l +100%FREE /dev/VGNAME/LVNAME`

Below first attempt but insufficient space:

```
user@server:~# lvextend --size 24G /dev/mapper/ubuntu--vg-ubuntu--lv
Insufficient free space: 5120 extents needed, but only 5119 available
```

Second attempt reducing space to allocate:

```
user@server:~# lvextend --size 23G /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to 23.00 GiB (5888 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
```

After `lvextend`, one has to use `resize2fs`. This was kind of scary because it appeared I was going to work on a live disk, but it went quick.

```
user@server:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 6029312 (4k) blocks long.
```

TADA! The disk is now 23G big as seen by df-h output below:

```
user@server:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 394M 1.1M 393M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 23G 3.2G 19G 15% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/loop0 89M 89M 0 100% /snap/core/7270
/dev/sda2 976M 77M 833M 9% /boot
/dev/loop1 90M 90M 0 100% /snap/core/7713
tmpfs 394M 0 394M 0% /run/user/1000
user@server:~#
```

В Centos 7 файловая система по умолчанию- **xfs** .

**поддержка файловой системы xfs** только расширяется, а не уменьшается. Поэтому, если вы хотите изменить размер файловой системы, используйте xfs\_growfs, а не resize2fs.

```
<span class="pln">xfs_growfs </span><span class="pun">/</span><span class="pln">dev</span><span class="pun">/</span><span class="pln">root_vg</span><span class="pun">/</span><span class="pln">root </span>
```

Примечание: Для использования файловой системы ext4

```
<span class="pln">resize2fs </span><span class="pun">/</span><span class="pln">dev</span><span class="pun">/</span><span class="pln">root_vg</span><span class="pun">/</span><span class="pln">root</span>
```

# How to expand /dev/mapper/cl-root (/dev/mapper/centos-root)

<div class="test-id__field-label-container slds-form-element__label" data-aura-rendered-by="82:318;a" id="bkmrk-step-by-step-instruc"><span class="test-id__field-label" data-aura-rendered-by="83:318;a">Step-by-step instructions</span></div><div class="test-id__field-label-container slds-form-element__label" data-aura-rendered-by="82:318;a" id="bkmrk-"></div><div class="test-id__field-label-container slds-form-element__label" data-aura-rendered-by="82:318;a" id="bkmrk-when-adding-a-code-s">When adding a Code Sample, please choose the 'Normal (DIV)' formatting, in order to avoid text glitch over the page borders</div><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk----you-must-be-root-"><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">**---You MUST be root to perform the below steps---**  
  
1. Check the current disk status to ensure dev/mapper/cl-root /dev/mapper/centos-root) is exactly 50G and /dev/mapper/cl-home (/dev/mapper/centos-home) is much larger in size.  
*df -h*  
  
Example:</div></div></div>```
[root@ptaserver /]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             7.8G     0  7.8G   0% /dev
tmpfs                7.8G     0  7.8G   0% /dev/shm
tmpfs                7.8G  802M  7.0G  11% /run
tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/cl-root   50G   11G   40G  22% /
/dev/sda1           1014M  265M  750M  27% /boot
/dev/mapper/cl-home  441G   33M  441G   1% /home
tmpfs                1.6G     0  1.6G   0% /run/user/1001
tmpfs                1.6G     0  1.6G   0% /run/user/1007
tmpfs                1.6G     0  1.6G   0% /run/user/1003
tmpfs                1.6G     0  1.6G   0% /run/user/1005
tmpfs                1.6G     0  1.6G   0% /run/user/1006
tmpfs                1.6G     0  1.6G   0% /run/user/1008
tmpfs                1.6G     0  1.6G   0% /run/user/0
```

<div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk-2.-stop-ptaservice-a"><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">  
  
2. Stop PTA  
*service appmgr stop*  
  
  
3. Copy everything from the home directory out  
*cp -a /home /home2*  
  
  
4. Unmount the volume  
*umount /dev/mapper/cl-home (umount /dev/mapper/centos-home)*  
  
  
5. Delete the home logical volume  
*lvremove /dev/mapper/cl-home (lvremove /dev/mapper/centos-home)*  
  
Example:</div></div></div>```
[root@ptaserver /]# lvremove /dev/mapper/cl-home
Do you really want to remove active logical volume cl/home? [y/n]: y
  Logical volume "home" successfully removed
```

<div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk-6.-extend-the-root-l"><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">  
  
6. Extend the root logical volume to take up the rest of the space  
*lvextend -l +100%FREE /dev/mapper/cl-root (lvextend -l +100%FREE /dev/mapper/centos-root)*  
  
Example:</div></div></div>```
[root@ptaserver /]# lvextend -l +100%FREE /dev/mapper/cl-root
  Size of logical volume cl/root changed from 50.00 GiB (12800 extents) to 481.12 GiB (123167 extents).
  Logical volume cl/root successfully resized.
```

<div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk-7.-extend-the-xfs-pa"><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">  
  
7. Extend the xfs partition  
*xfs\_growfs /dev/mapper/cl-root (xfs\_growfs /dev/mapper/centos-root)*  
  
Example:</div></div></div>```
[root@ptaserver /]# xfs_growfs /dev/mapper/cl-root
meta-data=/dev/mapper/cl-root    isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 128744448
```

<div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk-8.-check-that-%2Fdev%2Fm"><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">  
  
8. Check that /dev/mapper/cl-root (/dev/mapper/centos-root) has been increased in size and that /dev/mapper/cl-home (/dev/mapper/centos-home) has been removed  
*df -h*  
  
Example:</div></div></div>```
[root@ptaserver /]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             7.8G     0  7.8G   0% /dev
tmpfs                7.8G     0  7.8G   0% /dev/shm
tmpfs                7.8G  810M  7.0G  11% /run
tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/cl-root  492G   11G  481G   3% /
/dev/sda1           1014M  265M  750M  27% /boot
tmpfs                1.6G     0  1.6G   0% /run/user/1001
tmpfs                1.6G     0  1.6G   0% /run/user/0
tmpfs                1.6G     0  1.6G   0% /run/user/1007
tmpfs                1.6G     0  1.6G   0% /run/user/1003
tmpfs                1.6G     0  1.6G   0% /run/user/1005
tmpfs                1.6G     0  1.6G   0% /run/user/1006
tmpfs                1.6G     0  1.6G   0% /run/user/1008
```

<div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk-9.-move-the-home-dir"><div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">  
9. Move the home directory data back and remove the temporary home2 directory  
*mv /home2/\* /home/  
rmdir /home2*  
  
  
10. Remove the /dev/mapper/cl-home (lvremove /dev/mapper/centos-home) entry from /etc/fstab  
*vi /etc/fstab*  
DELETE the line:</div></div></div>```
/dev/mapper/cl-home     /home                   xfs     defaults        0 0
```

<div class="slds-form-element__control slds-grid itemBody" data-aura-rendered-by="85:318;a" id="bkmrk-11.-start-ptaservice"><div class="slds-rich-text-editor__output uiOutputRichText forceOutputRichText" data-aura-class="uiOutputRichText forceOutputRichText" data-aura-rendered-by="77:318;a" dir="ltr">  
  
11. Start PTA  
*service appmgr start*  
  
  
12. Run Diagnostics to ensure PTA is functioning again:  
*RUN\_DIAGNOSTICS*  
</div></div>