LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-04-2013, 04:48 PM   #1
Professor Dent
LQ Newbie
 
Registered: Mar 2013
Location: Singapore
Distribution: rhel,sl
Posts: 4

Rep: Reputation: Disabled
shrink lv_root from safely


Hi,
I would like to shrink my lv_root from 9.54g to 8g safely. This is a SL6.3 vm running on SL6.3 base box. I tried "single" from grub and booted the box but lv_root gets mounted automatically so I didn't run any disk related commands to prevent loss of data.

This is my current disk layout:
[root@outsider1 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lv_root vg_outsider1 -wi-ao-- 9.54g
lv_swap vg_outsider1 -wi-ao-- 1.97g
[root@outsider1 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 vg_outsider1 lvm2 a-- 11.51g 0
[root@outsider1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_outsider1-lv_root
9.4G 2.3G 6.7G 26% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/vda1 485M 33M 427M 8% /boot
[root@outsider1 ~]#
 
Old 03-04-2013, 05:58 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
Read over http://www.linuxquestions.org/questi...volume-337823/

This is a reason why I never make my root/boot partitions logical. You will need to boot off of a live cd with lvm2 support.
 
1 members found this post helpful.
Old 03-04-2013, 08:00 PM   #3
Professor Dent
LQ Newbie
 
Registered: Mar 2013
Location: Singapore
Distribution: rhel,sl
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Kustom42 View Post
Read over http://www.linuxquestions.org/questi...volume-337823/

This is a reason why I never make my root/boot partitions logical. You will need to boot off of a live cd with lvm2 support.
''



Thanks but I need to make this change on a VM. I am not sure how I can do this on a VM. How to boot a VM on rescue/ or using live cd?
 
Old 03-04-2013, 08:47 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try Section 2 linux.dell.com/files/whitepapers/KVM_Virtualization_in_RHEL_6_Made_Easy_Part2.pdf (HOWTO rescue VM)
 
1 members found this post helpful.
Old 03-04-2013, 08:53 PM   #5
Professor Dent
LQ Newbie
 
Registered: Mar 2013
Location: Singapore
Distribution: rhel,sl
Posts: 4

Original Poster
Rep: Reputation: Disabled
I found a way to boot the VM using resuce mode and was successful with shrinking the size of lv_root safely following the steps provided by Kustom42 member. Thanks.

# yum install libguestfs-tools
# virt-rescue -d vm-name

><rescue> vgs
VG #PV #LV #SN Attr VSize VFree
vg_outsider1 1 2 0 wz--n- 11.51g 0

><rescue> lvm vgchange -ay
2 logical volume(s) in volume group "vg_outsider1" now active

><rescue> e2fsck -f /dev/mapper/vg_outsider1-lv_root
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_outsider1-lv_root: 50262/625856 files (0.2% non-contiguous), 464559/2500608 blocks

><rescue> resize2fs -f /dev/mapper/vg_outsider1-lv_root 8G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_outsider1-lv_root to 2097152 (4k) blocks.
The filesystem on /dev/mapper/vg_outsider1-lv_root is now 2097152 blocks long.

><rescue> lvreduce -L 8G /dev/mapper/vg_outsider1-lv_root
WARNING: Reducing active logical volume to 8.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_root? [y/n]: y
Reducing logical volume lv_root to 8.00 GiB
Logical volume lv_root successfully resized

><rescue> exit
exit

virt-rescue: Syncing the disk now before exiting ...

[ 366.112306] md: stopping all md devices.
[ 366.213614] Restarting system.
[ 366.214264] machine restart
 
Old 03-04-2013, 08:56 PM   #6
Professor Dent
LQ Newbie
 
Registered: Mar 2013
Location: Singapore
Distribution: rhel,sl
Posts: 4

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by chrism01 View Post
Try Section 2 linux.dell.com/files/whitepapers/KVM_Virtualization_in_RHEL_6_Made_Easy_Part2.pdf (HOWTO rescue VM)
Thanks Chris. I followed those steps.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LVMError: lvactivate failed for lv_root 2flay Linux - Newbie 3 04-22-2013 10:08 PM
[SOLVED] Shrunk a LVM2 PV, now can't do ANYTHING to lv_root halp Linux - General 3 05-12-2011 04:30 AM
how do I shrink a postscript from A0 to A4? kalleanka Linux - General 2 07-22-2008 02:07 PM
xdvd shrink brotell Linux - Desktop 1 12-13-2007 06:19 PM
can you apply 2.6.x kernel config to 2.4.x safely/somewhat safely? silex_88 Linux - Software 3 12-09-2005 11:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration