LinuxQuestions.org
Visit Jeremy's Blog.
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


Closed Thread
  Search this Thread
Old 06-10-2013, 05:13 PM   #1
manuel19
Member
 
Registered: May 2010
Distribution: Fedora Core 8 (Werewolf)
Posts: 40

Rep: Reputation: 0
Expand disk after DD restore


Hi! DD makes an exact copy, including all the blank space.

That means:
2nd drive must be at least as big as first
If 2nd drive is larger, extra space will be wasted (filesystem can be expanded mind you)

So, How can I expand the 2nd disk to fill all the space?

Check my outputs:

Code:
[root@Linux ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00             3.7G  2.7G  762M  79% /
/dev/sda1             190M  188M   12M 98% /boot
tmpfs                 236M   18M  219M   8% /dev/shm
[root@Linux ~]#


fdisk -l


Code:
Disk /dev/sda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000141e0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          25      200781   83  Linux
/dev/sda2              26        9964    79835017+  8e  Linux LVM

As you see, When I restore the image here to this Hard disk, the df -h says is 3.7GB

But the real size is 81.9GB
How can I fix this without loosing any data.?
 
Old 06-10-2013, 08:04 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Extending a file system to take advantage of a larger, physical disk involves at least two steps:
  1. Extend the partition
  2. Extend the file system on that partition
The partition is the physical device on which the file system resides, but merely making that device larger won't do anything to the file system structures that were created when the original device was formatted. This structure has to be modified manually to reflect the size of the new device. If you use one of the ext file systems, resize2fs will do just that.

In your case, the file system doesn't reside on a physical device, but on an LVM volume created from a volume group which in turn consists of a single LVM physical volume residing on a partition device, /dev/sda2 (phew). This adds a third step to the procedure:
  1. Extend the LVM physical volume or create a new PV and add it to the same VG
  2. Extend the LVM logical volume (using the newly available space in the VG)
  3. Extend the file system residing on the LVM logical volume
From your post, it seems /dev/sda2 already covers the entire drive. How did you extend the partition?
 
Old 06-11-2013, 07:37 AM   #3
manuel19
Member
 
Registered: May 2010
Distribution: Fedora Core 8 (Werewolf)
Posts: 40

Original Poster
Rep: Reputation: 0
I use this:

parted -s /dev/sda rm 2
parted -s /dev/sda mkpart primary 26M 100%
parted -s /dev/sda t 2 lvm


But it doesn't work. Please, Can you post a step-by-step guide of all the commands and the steps to do what i want here in the 1st post?
 
Old 06-11-2013, 02:15 PM   #4
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
OK, what you've done is extend the 2nd partition to cover all available space by deleting and recreating it. Now you need to adjust the LVM structures inside that partition to match the new size. All you have to do is this:
Code:
pvresize /dev/sda2
The default behaviour for pvresize is to extend the physical volume to cover the entire device. Afterwards, you should be able to see free space in the volume group when you run vgdisplay.

You can now extend the LVM logical volume with lvresize:
Code:
lvresize /dev/mapper/VolGroup00-LogVol00
Again, the default is to extend the logical volume to use all available space in the volume group, which is what you want.

And finally, you extend the file system on the logical volume. You didn't say which file system you're using (type mount if you're in doubt), but if it's ext2, ext3 or ext4 the command would be:
Code:
resize2fs /dev/mapper/VolGroup00-LogVol00
I don't know about other file systems, but you can safely extend a mounted ext2/3/4 file system with resize2fs.
 
Old 06-12-2013, 12:06 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate.
 
  


Closed Thread



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
[SOLVED] How to expand disk in Linux JALITE Linux - Newbie 6 04-15-2014 04:19 PM
how to easily expand a virtual disk pedenski Linux - Newbie 3 05-15-2013 08:27 PM
[SOLVED] Expand disk size on centos VM? jbennett Linux - Newbie 37 07-17-2012 11:43 AM
[SOLVED] Expand WinXP Disk Size tronayne Linux - Virtualization and Cloud 4 12-15-2011 07:38 AM
How to expand disk space cghcgh Linux - Newbie 7 07-08-2008 09:09 AM

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

All times are GMT -5. The time now is 05:38 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