You are not logged in.

#1 2013-01-09 02:37:42

felixculpa
Member
From: Alberta, Canada
Registered: 2012-06-12
Posts: 181

[Solved] LVM noobie

Hi all. I recently set up LVM on my netbook and have only two physical partitions where /dev/sda2 is LVM formatted, here is my fstab:

# 
# /etc/fstab: static file system information
#
# <file system>	<dir>	<type>	<options>	<dump>	<pass>
# /dev/mapper/leeSSD-root
UUID=847c1886-3246-4178-9ba8-7fee2bf4d23a	/         	ext4      	defaults,discard 0 1

# /dev/sda1
UUID=27529572-65cd-4e65-9ad6-6af28a01f9b3	/boot     	ext4      	defaults,discard,nodev,nosuid,noexec 0 0

# /dev/mapper/leeSSD-usr
UUID=7ac6c67f-4de6-4f3a-ab1d-8cc3d3d88f9c	/usr      	ext4      	defaults,discard 0 0

# /dev/mapper/leeSSD-var
UUID=0c7d000d-85f0-47e1-a37c-a1a6cb5edd90	/var      	ext4      	defaults,discard,nodev,nosuid,noexec 0 2

# /dev/mapper/leeSSD-home
UUID=725acbc4-ad5a-499c-a06f-7c35ae2036c8	/home     	ext4      	defaults,discard,nodev,nosuid 0 2

I have never had a separate /usr partition before, and because I didn't realize that is where most of the data in root reside when it is not seperated I was surprised to see this:

df -h /:

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/leeSSD-root  6.0G  163M  5.5G   3% /

So now I wish to resize my root partition, obviously! As I am new to the LVM user scene I am hesitant to go 'gung-ho' with lvreduce and whatnot until I gain further clarification. If I am to understand the wiki page correct I need to do the following:

# resize2fs /dev/leeSSD/root 1G
# lvresize -L -5G leeSSD/root
# resize2fs /dev/leeSSD/root

I've heard on random links online that the root filesystem needs to be unmounted before resizing and that ext4 supports online-resizing. Do I need to boot a livecd and then do the resize commands for it to work?

Last edited by felixculpa (2013-01-12 03:39:50)

Offline

#2 2013-01-09 03:00:21

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [Solved] LVM noobie

I emailed a response to you.  But to help this thread along, online resizing can only be used to enlarge a filesystem, not shrink it.  So you are going to have the have the filesystem unmounted no matter what.

I am not sure about the rootfs needing to be unmounted to expand though.  I feel like I have done this before without issue. 

Otherwise, your info is correct there.  You need to make the filesystem smaller than what you plan on shrinking the lv to, then exmpand the filesystem to use all the space.  Though your example above is a bit extreme.  I think that if you did something like 4.5G instead of 1G in the first step, that might make more sense.

In any case, I have to wonder why you want to go through a resize to change by only 1GB.  If you seriously want to make use of that empty space, why not do 2G or 1G?  You can always make it bigger later (and quite easily with LVM).

Offline

#3 2013-01-09 03:25:53

felixculpa
Member
From: Alberta, Canada
Registered: 2012-06-12
Posts: 181

Re: [Solved] LVM noobie

As it stands the system has less than 200M on the root partition being used, with over 5G just sitting around looking pretty. I may reduce it to 1G eventually, and I consider that being generous to my system smile

Edit: As this is my only PC, and I need it for taking notes at school, I will be putting off taking the necessary steps until the weekend in case something goes wrong. The extra space will be most welcome as my SSD is only 64GB.

Last edited by felixculpa (2013-01-09 03:37:08)

Offline

#4 2013-01-09 03:55:35

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [Solved] LVM noobie

Ah okay, so your query above of shrinking the partition to 5G was simply a hypothetical... I was wondering why you wanted to go through the trouble of reducing by 1G.

With 64GB, just be glad you run Linux and not a space hogging proprietary operating system.  The last time I installed a fresh windows 7, it was something like 29GB, and when I restored my Thinkpad with windows 7 because I was curious, it took ~50GB! (Needless to say that didn't stay on my computer for very long!)

Offline

#5 2013-01-09 04:28:01

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,582

Re: [Solved] LVM noobie

WonderWoofy wrote:

The last time I installed a fresh windows 7, it was something like 29GB

Whaaaaaaat?

I just installed 7 Pro SP 1, it didn't take up nearly that much space (~10G I think). Probably it was pagefile.sys and hiberfil.sys taking up most of that space.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#6 2013-01-09 06:43:04

felixculpa
Member
From: Alberta, Canada
Registered: 2012-06-12
Posts: 181

Re: [Solved] LVM noobie

Even 10G seems like alot to me.

Offline

#7 2013-01-09 14:08:13

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,582

Re: [Solved] LVM noobie

To me too when I first installed Win 7, but I got over it.

Anyway, apoligies for the hijack. And good job making the transition to LVM. I remember how daunting it seemed when I first decided to make the switch.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#8 2013-01-09 17:05:49

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [Solved] LVM noobie

Yeah, it did seem like a lot to take in at first.  Also, I was initially unconvinced about the benefits, but decided to give it a whirl anyway since many users around here seem to think its the bees knees.  In the end, I am glad I took the time to learn about it.  I just like being able to make my partitions small and not have to worry about moving them around when I want to expand them.  I guess also spanning multiple drives, snapshots, striping, mirroring, etc are also not too bad either.


About the massive Win7 alphaniner, you are probably right that it was the pagefile and hibernate file.  But I didn't care to investigate and simply removed it.  But I was absolutely shocked that the Lenovo recovery discs created a massive 50GB behemoth of useless crap.  Also removed pretty quickly (I used it to update the bios while I had it on there... before I realized that they offered bootable isos).

Offline

#9 2013-01-12 03:39:28

felixculpa
Member
From: Alberta, Canada
Registered: 2012-06-12
Posts: 181

Re: [Solved] LVM noobie

I was successful at resizing my logical volumes. These are the steps I needed to take to do so, at least for root, but I used the same steps to shrink my other logical volumes. These commands are entered after booting into a live CD (I used the arch setup cd).

Activate all volume groups on the system

lvm vgchange -a y

System will complain if you try to resize the file  system if you don't do this first

e2fsck -f /dev/leeSSD/root

Resize the file system (make it smaller than you want the volume to be)

resize2fs /dev/leeSSD/root 400M

Careful not to accidently cut off data at the end of the partition

lvm lvreduce -L 500M /dev/leeSSD/root

Resizes filesystem to fill up available space on the logical volume

resize2fs /dev/leeSSD/root

Offline

Board footer

Powered by FluxBB