creating new logical volume on root partition

General support questions
qwerty1111
Posts: 24
Joined: 2016/11/23 13:22:32

creating new logical volume on root partition

Post by qwerty1111 » 2017/12/20 09:13:53

Hi,

the question is :

How can I create a new 3GB logical volume on the system below?

I tried many many times but without being successful...

As this is for an exam, there is no live cd provided


[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─vggroup-swap 253:0 0 2G 0 lvm [SWAP]
└─vggroup-root 253:1 0 17.5G 0 lvm /
sr0 11:0 1 6.6G 0 rom /run/media/marc/CentOS 7 x86_64
[root@localhost ~]#


[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vggroup-root ext4 18G 3.3G 13G 20% /
devtmpfs devtmpfs 912M 0 912M 0% /dev
tmpfs tmpfs 921M 84K 921M 1% /dev/shm
tmpfs tmpfs 921M 8.7M 912M 1% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/sda1 ext4 477M 95M 353M 22% /boot
/dev/sr0 iso9660 6.6G 6.6G 0 100% /run/media/marc/CentOS 7 x86_64
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vggroup
PV Size 19.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4994
Free PE 0
Allocated PE 4994
PV UUID qk2o5a-Or3f-6iFV-LtYe-cL7n-vLax-4eSqfV

[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name vggroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.51 GiB
PE Size 4.00 MiB
Total PE 4994
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 0 / 0
VG UUID 4w7Ng6-XiRy-yNRk-0ytz-29XT-Zfz0-V4HvFa

[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vggroup/root
LV Name root
VG Name vggroup
LV UUID nkK2AF-dj51-seDJ-D3bQ-C2RZ-zi0U-08V49j
LV Write Access read/write
LV Creation host, time localhost, 2017-12-18 13:55:40 +0000
LV Status available
# open 1
LV Size 17.51 GiB
Current LE 4482
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Path /dev/vggroup/swap
LV Name swap
VG Name vggroup
LV UUID BVGDek-CCNm-k7sQ-EylW-dwbP-dSX1-Q2bsfd
LV Write Access read/write
LV Creation host, time localhost, 2017-12-18 13:55:41 +0000
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# cat /proc/partitions
major minor #blocks name

11 0 6896640 sr0
8 0 20971520 sda
8 1 512000 sda1
8 2 20458496 sda2
253 0 2097152 dm-0
253 1 18358272 dm-1
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#


Thank you for your help!

User avatar
TrevorH
Forum Moderator
Posts: 22789
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: creating new logical volume on root partition

Post by TrevorH » 2017/12/20 09:52:50

How can I create a new 3GB logical volume on the system below?
You cannot as you have no space left - " Free PE / Size 0 / 0 "
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

qwerty1111
Posts: 24
Joined: 2016/11/23 13:22:32

Re: creating new logical volume on root partition

Post by qwerty1111 » 2017/12/20 10:17:11

Thank you for the input.

I should have give more precision : As there is no space left, how can I reduce the size of the volume group "vggroup" from 18 G to 15 G in order to create the new logical volume?

User avatar
TrevorH
Forum Moderator
Posts: 22789
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: creating new logical volume on root partition

Post by TrevorH » 2017/12/20 10:31:03

You don't want to reduce the size of the volume group as that would mean there's even less space available. The volume group is the container that holds your logical volumes.

What you need to do is shrink the filesystem on one of the existing LVs and then resize the LV which will return space to the VG so that you can use lvcreate to create a new LV. Depending on the filesystem in use on the existing LVs that may be possible or impossible. If you used the xfs filesystem on your vggroup-root LV then you will be unable to shrink it and will need to delete it and start over - reinstall in this case. If you used ext4 or ext3 then you can resize the filesystem as long as it's not mounted at the time. Running the lvresize command with the -r switch will resize the filesystem and the LV at the same time. Use man lvresize to see the syntax.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

qwerty1111
Posts: 24
Joined: 2016/11/23 13:22:32

Re: creating new logical volume on root partition

Post by qwerty1111 » 2017/12/20 21:26:23

Thank you for the insights.

I read previously we have to umount the root partition and boot from a live CD.

The thing is (I'm preparing for the RHCE I actually failed) , there is no live CD in the virtual system.

I reproduced the environment below which seems more accurate than the one I posted previously but was still unable to create a 3GB logical volume.

They don't say how you need to proceed to create the logical volume, but you need to create definitely a 3 GB logical volume,regardless the method employed.

I really still can't see how I could create that 3GB logical volume with a such configuration...

The file sytem is EXT4.

[root@localhost home]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 25G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 24.5G 0 part
├─vggroup-swap 253:0 0 2G 0 lvm [SWAP]
├─vggroup-root 253:1 0 14.7G 0 lvm /
└─vggroup-home 253:2 0 7.8G 0 lvm /home
sr0 11:0 1 6.6G 0 rom
[root@localhost home]#
[root@localhost home]#
[root@localhost home]#
[root@localhost home]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vggroup-root ext4 15G 4.0G 9.6G 30% /
devtmpfs devtmpfs 912M 0 912M 0% /dev
tmpfs tmpfs 921M 140K 921M 1% /dev/shm
tmpfs tmpfs 921M 8.7M 912M 1% /run
tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/sda1 ext4 477M 95M 353M 22% /boot
/dev/mapper/vggroup-home ext4 7.6G 6.0G 1.3G 83% /home
[root@localhost home]#
[root@localhost home]#
[root@localhost home]# pvdisplay

--- Physical volume ---
PV Name /dev/sda2
VG Name vggroup
PV Size 24.48 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 6266
Free PE 0
Allocated PE 6266
PV UUID ifu8mj-A8Po-Cvdg-GvPj-pCy3-WMCb-4YrYWe

[root@localhost home]#
[root@localhost home]#
[root@localhost home]#
[root@localhost home]# vgdisplay
--- Volume group ---
VG Name vggroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 24.48 GiB
PE Size 4.00 MiB
Total PE 6266
Alloc PE / Size 6266 / 24.48 GiB
Free PE / Size 0 / 0
VG UUID IRPpN0-5rV1-GNqk-rhlR-w6ai-zzvj-D0lQWI

[root@localhost home]#
[root@localhost home]#
[root@localhost home]# lvdisplay
--- Logical volume ---
LV Path /dev/vggroup/root
LV Name root
VG Name vggroup
LV UUID a3Y33q-u8Vo-Qm8u-132f-6gnR-it1n-lDDPjI
LV Write Access read/write
LV Creation host, time localhost, 2017-12-20 11:06:48 +0000
LV Status available
# open 1
LV Size 14.65 GiB
Current LE 3750
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Path /dev/vggroup/swap
LV Name swap
VG Name vggroup
LV UUID H5YrYJ-InSe-ckqv-GEoR-dsqd-67j6-Pv2wZ3
LV Write Access read/write
LV Creation host, time localhost, 2017-12-20 11:06:50 +0000
LV Status available
# open 2
LV Size 2.02 GiB
Current LE 516
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/vggroup/home
LV Name home
VG Name vggroup
LV UUID oJ8BCN-CsEv-A4mD-J9bz-ArPv-jpxl-wrXwhV
LV Write Access read/write
LV Creation host, time localhost, 2017-12-20 11:06:50 +0000
LV Status available
# open 1
LV Size 7.81 GiB
Current LE 2000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2

[root@localhost home]#
[root@localhost home]#
[root@localhost home]#
[root@localhost home]# cat /proc/partitions
major minor #blocks name

11 0 6896640 sr0
8 0 26214400 sda
8 1 512000 sda1
8 2 25668608 sda2
253 0 2113536 dm-0
253 1 15360000 dm-1
253 2 8192000 dm-2
[root@localhost home]#
[root@localhost home]#
[root@localhost home]#


Thank you for your help

hunter86_bg
Posts: 1136
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: creating new logical volume on root partition

Post by hunter86_bg » 2017/12/20 22:24:46

As the "/home" is almost full, you are almost out of options. I say almost, as you can reduce the "/home" with 1 GB and then get rid of the swap. After that - you will have those 3 GB for the new LV.

Note: It is not recommended to have a system without swap. There are a lot of software that rely on it.

qwerty1111
Posts: 24
Joined: 2016/11/23 13:22:32

Re: creating new logical volume on root partition

Post by qwerty1111 » 2017/12/21 00:38:25

Hi,

thank you for the reply

Actually,as far as I remember,the /home size was lower ,something like 800 MB in total size with around 400MB free space.

I remember when I tried to create a partition with fdisk /dev/sda1, I had only only 96 free PE which prevented me to create the 3 GB partition.

and when I did the fdisk /dev/sda, I could select +3GB for the size of the partition but during the reboot, I got a dracut error saying : unable to find /vggroup-root..so the system was unable to reboot...

It was more something like that:

[root@localhost home]# df -Th

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/vggroup-root ext4 15G 4.0G 9.6G 3 30% /

devtmpfs devtmpfs 912M 0 912M 0% /dev

tmpfs tmpfs 921M 140K 921M 1% /dev/shm

tmpfs tmpfs 921M 8.7M 912M 1% /run

tmpfs tmpfs 921M 0 921M 0% /sys/fs/cgroup

/dev/sda1 ext4 477M 95M 353M 22% /boot

/dev/mapper/vggroup-home ext4 800M 400M 400M 50% /home


Which options do I have to create then a 3GB logical volume with something like that ?

I spent ages for a solution but still can't find how...

thank you

hunter86_bg
Posts: 1136
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: creating new logical volume on root partition

Post by hunter86_bg » 2017/12/21 06:07:08

Are you sure that there was only a single disk with no free space on it?

qwerty1111
Posts: 24
Joined: 2016/11/23 13:22:32

Re: creating new logical volume on root partition

Post by qwerty1111 » 2017/12/21 08:09:49

There was only 1 disk ,for sure.

And the only available space I could see was in dev/mapper/vggroup-root that had 12 GB free available space and thatwas mounted on /.

Code: Select all

Filesystem               Type   Size   Used   Avail   Use%    Mounted on

/dev/mapper/vggroup-root ext4    15G   4.0G   9.6G    3 30%    /

A parted print free space showed me as well there was enough free space in the disk.

I asked to the proctor at the end but he couldn't remember exactly my environment and told me it was just about creating a new partition with fdisk on the disk as there was only a single disk,that's all .. but it kept failing by creating a new partition ..

hunter86_bg
Posts: 1136
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: creating new logical volume on root partition

Post by hunter86_bg » 2017/12/21 11:19:01

Most probably it was a bug in the environment.
If there was a space on the only disk - you can use fdisk/cfdisk/parted or gdisk (depending if its the legacy MSDOS or GPT partition table) and then a simple partprobe to redect the new layout.

Post Reply