Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Safe way to shrink lvm vg_*-lv_swap partition and reclaim freed space on Linux? Post 303039333 by centosadmin on Tuesday 1st of October 2019 05:23:52 AM
Old 10-01-2019
Safe way to shrink lvm vg_*-lv_swap partition and reclaim freed space on Linux?

Hello,

Code:
[root@host2 ~]# lsblk
NAME                        MAJ:MIN    RM  SIZE RO TYPE MOUNTPOINT
sr0                          11:0       1 1024M  0 rom
sda                           8:0       0 38.2G  0 disk
├─sda1                        8:1       0  500M  0 part /boot
└─sda2                        8:2       0 37.7G  0 part
  ├─vg_host2-lv_root (dm-0) 253:0       0   31G  0 lvm  /
  └─vg_host2-lv_swap (dm-1) 253:1       0  6.7G  0 lvm  [SWAP]
ploop38874                  182:621984  0  9.8G  0 disk
└─ploop38874p1              182:621985  0  9.8G  0 part /vz/root/1810

.

Moderator's Comments:
Mod Comment deleted all external links



My aim is to SAFELY shrink my swap partition (lvm vg_host2-lv_swap) so its size is 4GB and assign freed space to my root partition (lvm vg_host2-lv_root (dm-0)). I am on CentOS 6.10 64bit and i am wondering if i can do it on a running system without need to go into recovery - maybe i can go this way superuser.com/a/1024226/590209 (without reboot), maybe i can unmounting swap lvm on live system, but not lvresize (grow) root partition? How can i automatically grow root lvm partition during next boot (like editing boot parameters in grub)?









Last edited by centosadmin; 10-01-2019 at 06:53 AM..
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

mv files still in use - space not freed

Had a issue recently where DB admins did: mv listener.log listener.log.old gzip listener.log.old Where file listener.log is continually being written to by an oracle process. Anyway, according to the DB admins they successfully created the listener.log.old.gz file (i.e. all went okay).... (4 Replies)
Discussion started by: apra143
4 Replies

2. Red Hat

add lvm space from a regular partition

Hi, I have red hat enterprise 4. I would like to add more space on my lvm from the first partition that is not lvm type. Here's the config # fdisk -l Disk /dev/sda: 73.4 GB, 73406611456 bytes 255 heads, 63 sectors/track, 8924 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes... (6 Replies)
Discussion started by: itik
6 Replies

3. UNIX for Advanced & Expert Users

Shrink my partition to new disk

I want to backup my partitions by shrinking it my issue is like I want to create a new disk copy from only the used blocks I my current image. How would I redirect the output of resize2fs to new disk and dd the current partition so that I can boot my new image without issues and also without... (3 Replies)
Discussion started by: amol28kulkarni
3 Replies

4. Linux

How to reclaim the space which i used to increse the swap space on Xen,

Hi, i have done a blunder here, i increased the swap space on Xen5.6 server machine using below steps :- 1056 dd if=/dev/zero of=/root/myswapfile bs=1M count=1024 1057 ls -l /root/myswapfile 1058 chmod 600 /root/myswapfile 1059 mkswap /root/myswapfile 1060 swapon /root/myswapfile ... (1 Reply)
Discussion started by: apm
1 Replies

5. UNIX for Dummies Questions & Answers

How to convert non LVM root partition to LVM?

Hi Guys, I m using redhat 6, I have installed root partition as non-LVM . Is there any way i can convert it to LVM? (1 Reply)
Discussion started by: pinga123
1 Replies

6. Linux

About shrinking LVM and then adding the freed space to another OS on dualboot system

Hi all, Fedora 17, 64bit Ubuntu 12.04 desktop 64bit HD 160G I installed Ubuntu 12.04 on the HD first taking up the whole disc. Later I added/installed Fedora 17 selecting the "Shrink" option and save the bootloader on /dev/sda1 to make them dualboot. Installation is successful with... (0 Replies)
Discussion started by: satimis
0 Replies

7. UNIX for Advanced & Expert Users

How to shrink root file system (LVM) in Linux Fedora 9?

My root file system is of type LVM. i wanna shrink it but unable to do so. When i give the below command: resize2fs /dev/mapper/VolGroup00-VolLog00 10000M it messages that online shrink can't can't be done as the logical volume is mounted on /. i switched to single user mode by giving command:... (2 Replies)
Discussion started by: ravisingh
2 Replies

8. Red Hat

Linux partition with LVM

Hi, I need a suggesstion i have 2 disk if i installed OS / root partition by making Lvm in one disk and data in other disk also with the lvm, means 2 different lvms. Is making LVM partition for OS disk will the performacne will be good? Can i make 2 different lvm one is for OS and other for... (1 Reply)
Discussion started by: Rahulne25
1 Replies

9. Red Hat

Shrink LVM partition & create new Linux Primary partition

Hello All, I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows, /boot - Linux Partition & another is LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc). Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
Discussion started by: gr8_usk
5 Replies

10. UNIX for Beginners Questions & Answers

CentOS 6 ran out of space, need to reclaim it

Hello everyone, I am having an issue here with CentOS release 6.6 (Final) that shows all of the space used up, but I can't tell where the space went. Seemingly I am using up 100%, according to df -h Filesystem Size Used Avail Use% Mounted on... (27 Replies)
Discussion started by: DannyBoyCentOS
27 Replies
dtc_kill_vps_disk(8)					      System Manager's Manual					      dtc_kill_vps_disk(8)

NAME
dtc_kill_vps_disk - destroy LVM disks for freeing space SYNOPSIS
dtc_kill_vps_disk VPS_NUMBER [ lvm|loopback ] DESCRIPTION
dtc_kill_vps_disk This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script is used to delete a partitions that was used by a VPS. It will delete the normal partition that was used as a root disk, and the swap partition. dtc_kill_vps_disk is to be used by the dtc-xen SOAP server, but can also be used as a standalone userland tool. OPTIONS
VPS_NUMBER has to be a number between 01 and 19. Let's say the number is 16, and that dtc-xen is configured to use the volume group called lvm1, then this script will create /dev/lvm1/xen16 and /dev/lvm1/xen16swap. IMAGE_TYPE This parameter can have 2 values: either lvm or loopback. If ommited, then lvm is used. If lvm is used, then this script will create a partition using lvmcreate, otherwise it will create an image file. Both will later be used for the VPS. EXAMPLE
dtc_setup_vps_disk 04 lvm This will delete the 2 LVM partitions that were used by the VPS named xen04, the first one being the root partition, and the second one being the swap partition. VERSION
This documentation describes dtc_kill_vps_disk See http://www.gplhost.com/software-dtc-xen.html for updates. SEE ALSO
dtc_reinstall_os(8), dtc_setup_vps_disk(8) dtc_kill_vps_disk(8)
All times are GMT -4. The time now is 11:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy