Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
28
rated 0 times [  28] [ 0]  / answers: 1 / hits: 87645  / 3 Years ago, wed, november 17, 2021, 9:39:54

I don’t need to actually shrink the MBR partition, just the logical volume that contains the root “/” filesystem. It’s ~200GB now, and I need to shrink it to ~150GB to make room for a new logical volume. How do I go about this?


More From » 11.10

 Answers
0

BEFORE YOU CHANGE ANYTHING MAKE SURE YOU HAVE A CURRENT BACKUP. This all worked for me, but it might not work for you. If it blows up for some reason, you don’t want to lose anything that you can’t recover. Continuing on…



It is not possible (to my knowledge) to shrink a filesystem while it is mounted, so we need to do the actual resizing from a Live CD. All the following instructions assume you have booted off of the 11.10 Desktop Install CD.



After the Live CD boots up to the desktop, open up the Terminal.



The LVM tool are not built-in to the Live CD, so first we must install them:



sudo apt-get install lvm2


Find the name of the Volume Group (henceforth “somevg”) that contains the root Logical Volume:



sudo lvs


(If it’s not showing up, try running sudo lvmdiskscan and sudo pvscan then try again.)



If you run ls /dev/mapper/ you may see that the Logical Volumes is not showing up. If it’s not there, you need to run the following command to make the kernel aware of the logical volumes:



sudo vgchange --available y <somevg>


Since we haven’t mounted the root filesystem, it should be safe to resize. Proceed to perform the actual resizing of the Logical Volume. Note that this command (--size -50G) shrinks the volume by 50GB — read the lvreduce(8) man page to learn how to specify a different size.



sudo lvreduce --resizefs --size -50G /dev/<somevg>/root


(My Logical Volume is called “root”, but yours may be named something different.)



This command will first shrink the filesystem, then shrink the Logical Volume that contains it, which is the only safe way to do it.



You can now restart the system and boot into your now-resized root filesystem.


[#39141] Friday, November 19, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laiuct

Total Points: 44
Total Questions: 105
Total Answers: 107

Location: Seychelles
Member since Mon, Feb 15, 2021
3 Years ago
;