LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 04-26-2012, 02:40 AM   #1
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Rep: Reputation: 4
How to determine number of blocks of a logical volume


My LVM looks like this

LV VG Attr LSize Origin Snap% Move Log Copy% Convert
blackberry mobile -wi-ao 1.00G
motorolla mobile -wi-ao 700.00M
nokia mobile -wi-ao 900.00M
sony mobile -wi-ao 1.46G

now i am able to extend sony lv to 2 GB. And able to bring back to 1.46G. Since i know the number of blocks of sony lv, i am able to specify it, while shrinking back to 1.46G. Now i want to resize the sony lv around to 1.2G. How can i find the number of blocks for 1.2G, so that i can resize the lv to 1.26G excatly.

when i use tune2fs -l /dev/mobile/sony. It gives the following info


tune2fs 1.39 (29-May-2006)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: 80424503-7ce2-4dd5-8be5-953422116d47
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode dir_index filetype sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 187008
Block count: 384000
Reserved block count: 14906
Free blocks: 199767
Free inodes: 109076
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 53
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 15584
Inode blocks per group: 487
Filesystem created: Thu Apr 26 15:30:30 2012
Last mount time: Thu Apr 26 17:56:57 2012
Last write time: Thu Apr 26 18:04:13 2012
Mount count: 0
Maximum mount count: 26
Last checked: Thu Apr 26 18:04:13 2012
Check interval: 15552000 (6 months)
Next check after: Tue Oct 23 18:04:13 2012
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: c92882f3-c595-4764-90b5-0e28d40db4ee
Journal backup: inode blocks

Which block attribute should i use. Here its shows block size, block count. I tried using online blocks to gb converter, but the values does not match at all....

Can someone help me .

Last edited by Iyyappan; 04-26-2012 at 02:44 AM.
 
Old 04-26-2012, 02:53 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Do you actually need the blocks or would this be of use to you:
Code:
lvresize -L 1.26G /dev/mobile/sony
Also have a look here: LVM Resizing Guide

Hope this helps.
 
Old 04-26-2012, 03:45 AM   #3
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
Before using this lvresize -L 1.26G /dev/mobile/sony, we need to use resize2fs command right. For that, is it a must to specify the blocks. resize2fs /dev/mobile/sony *******. In a doc, it was specified that for increasing the lv, resize2fs /dev/mobile/sony is enough, but while shrinking, we need to specify the blocks resize2fs /dev/mobile/sony ******* .Thats what i need to know, whether its a must do it.
 
Old 04-26-2012, 03:50 AM   #4
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
I checked the document, in resize2fs command itself they have speicified the lv size and also in lvresize command. Will follow it and update you the o/p
 
Old 04-26-2012, 03:53 AM   #5
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
Fine it worked for me. Kindly check whether, what i have is correct or not


umount /mnt/sony
[root@mustang mnt]# e2fsck -f /dev/mobile/sony
e2fsck 1.39 (29-May-2006)
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/mobile/sony: 13/187008 files (23.1% non-contiguous), 31494/384000 blocks
[root@mustang mnt]# resize2fs /dev/mobile/sony 1200M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mobile/sony to 307200 (4k) blocks.
The filesystem on /dev/mobile/sony is now 307200 blocks long.

[root@mustang mnt]# lvresize -L1.2G /dev/mobile/sony
Rounding up size to full physical extent 1.20 GB
WARNING: Reducing active logical volume to 1.20 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce sony? [y/n]: y
Reducing logical volume sony to 1.20 GB
Logical volume sony successfully resized
[root@mustang mnt]# mount /dev/mobile/sony /mnt/sony
[root@mustang mnt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.8G 2.9G 1.7G 64% /
tmpfs 252M 0 252M 0% /dev/shm
/dev/mapper/mobile-nokia
886M 59M 787M 7% /mnt/nokia
/dev/mapper/mobile-motorolla
689M 17M 638M 3% /mnt/motorolla
/dev/mapper/mobile-blackberry
1008M 34M 924M 4% /mnt/blackberry
/dev/mapper/mobile-sony
1.2G 101M 1.1G 9% /mnt/sony
 
Old 04-26-2012, 04:11 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

That looks ok.

I would run an additional e2fsck -f /dev/mobile/sony (after unmounting) just to be sure.
 
Old 04-26-2012, 11:38 PM   #7
Iyyappan
Member
 
Registered: Dec 2008
Location: Chennai, India
Distribution: CentOS 5, SLES 11
Posts: 245

Original Poster
Rep: Reputation: 4
Is it fine to run e2fsck if the size is large.Y i am asking is, lvm is used because we can add hard drives, while we keep on working. If we run e2fsck on a mac where it has huge datas, it will consume more time right.. but for extending file systems its a must do it..
 
Old 04-27-2012, 12:58 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,
Quote:
Originally Posted by Iyyappan View Post
Is it fine to run e2fsck if the size is large.Y i am asking is, lvm is used because we can add hard drives, while we keep on working. If we run e2fsck on a mac where it has huge datas, it will consume more time right.. but for extending file systems its a must do it..
If at all possible I wouldn't do the things you mention on a machine running in RL 3/4/5. At least unmount the partition(s) you are going to work on. It is always better to have planned downtime instead of having possible data corruption, which would lead to an unplanned and longer downtime.

As for adding HD's to a running machine: I can only assume you have hardware that supports this.

Hope this helps.
 
  


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
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
I have spce in volume group but it can not increase the size of logical volume anis123 Linux - Newbie 14 04-16-2012 06:23 AM
How Data blocks and Logical Partitions related fizeelinux AIX 11 08-21-2010 09:23 PM
How to determine number of blocks for a partition rcmonroig Linux - Newbie 1 07-01-2010 05:27 AM
Extending logical volume LogVol01 Insufficient allocatable logical exte swap space umeshsharma Linux - Newbie 4 06-22-2009 12:26 PM

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

All times are GMT -5. The time now is 12:26 AM.

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