LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 05-31-2012, 09:46 PM   #1
tuberb
LQ Newbie
 
Registered: Feb 2012
Location: Belmont, MA, US
Distribution: Centos
Posts: 4

Rep: Reputation: Disabled
Moving Centos installation to smaller disk


I am running Centos 6.2 and the hard disk in the system started to fail, so I was able to clone it to another, slower disk to keep things running temporarily.

I want to replace that disk with a new one, but the new one is slightly smaller than the original and the partitions don't fit. The disk has an LVM on it, and while there is plenty of unused space and I was able to resize the partitions inside the logical volume (doing a resize2fs followed by an lvreduce) so that there is free space, I cannot shrink the LVM itself to get the physical partition to be small enough so that I can clone it to the new disk.

I have tried to vgreduce it (while booted into a rescue cd) but I am told it is "still in use". I also looked at pvresize but that gave me an error (sorry, did not make a note) and would not do anything.

I also tried gparted to resize the partitions as I cloned the disk, but found that it does not support lvm2.

Is there a way to get there from here?

Thanks,

Barry

Last edited by tuberb; 06-01-2012 at 08:27 AM.
 
Old 06-01-2012, 02:48 AM   #2
jason_not
Member
 
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76

Rep: Reputation: 19
Actually, you may be able to do it more simply using dump and restore. (assuming the same filesytem type in use...) As long as the old filesystem is smaller than the new partition, the restore command will do the right thing.

Create fresh and clean filesystems and mount them on your OS.
install dump and restore.

resize your old disk to slightly smaller than the new replacement disk's.

note the disk partitions that correspond to your old disk

cd <new mount point!)
dump -0af - /dev/<partition on old disk> | restore -rf -

run fsck on the restored filesystem, if all is well, delete the "restoresymtable" file.

--jason
 
Old 06-01-2012, 06:37 AM   #3
tuberb
LQ Newbie
 
Registered: Feb 2012
Location: Belmont, MA, US
Distribution: Centos
Posts: 4

Original Poster
Rep: Reputation: Disabled
The part about "resize your old disk to slightly smaller than the new replacement disk's." is exactly the part I can't figure out how to do. So if you could tell me how I can do that, then I am all set.
 
Old 06-01-2012, 09:28 AM   #4
jason_not
Member
 
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76

Rep: Reputation: 19
Hi,

Sorry, I made the assumption you had already done that based on a tiny blurb in your initial post.

Quote:
(doing a resize2fs
once you use resize2fs, you don't really need to do much else, at least as far as using the dump command is concerned. Resize2fs will alter the size of the filesystem, but not the partition size. dump looks only at the filesystem-block level, and the partition size won't even interest the program. That's why I suggested dump: you can totally skip resizing the original partition.

Actually, now that I think about it, so long as the actual used filesystem space is smaller than the destination partition, dump and restore are smart enough to do that correctly.

restore will take the output of dump (or a dump file) and re-build the filesystem structure onto an existing filesystem. It CAN be used to restore to a subdirectory on a used filesystem, it is best to have a clean filesystem to restore to.

dump and restore will ALSO place important files such as your boot images (if it's THAT partition) at the correct inode number, which rsync, tar, cp, et al will not. dump and restore also correctly handle sparse files, sockets, block and character devices, and will stay in it's own filesystem (won't accidentally backup up /proc for instance).

so I will carefully list out the steps:
Quote:
1) note the original parition number you wish to backup (in this example, I will call it /dev/sdb1)
2) unmount the original filesystem (this will ensure it is totally quiescent!)
a) umount /dev/sdb1
3) build a new filesystem on the new disk, and mount it. (in this example, I will call the new partition /dev/sdc2 and the mount point /mnt/newfs)
a) mkfs.ext4 /dev/sdc2 <-- I like ext4 filesystem, but you choose...
b) mount /dev/sdc2 /mnt/newfs
4) dump and restore
a) cd /mnt/newfs
b) dump -0af - /dev/sdb1 | restore -rf -
5) cd /
6) umount /mnt/newfs
7) fsck -f /dev/sdc2
once done, mount the new filesystem and make sure it looks right. alter your fstab and boot into it.

--jason
 
Old 06-02-2012, 10:55 AM   #5
tuberb
LQ Newbie
 
Registered: Feb 2012
Location: Belmont, MA, US
Distribution: Centos
Posts: 4

Original Poster
Rep: Reputation: Disabled
I ended up following the directions here: http://fedorasolved.org/Members/zcat...-new-partition to shrink the physical partition enough so that I could clone the disk to the new one using Acronis True Image. Things seem to working ok with the new disk, and hopefully will stay that way.
 
Old 06-02-2012, 11:43 AM   #6
jason_not
Member
 
Registered: Aug 2010
Location: Beaverton, Oregon, USA
Distribution: Pfsense, Ubuntu, Centos, Fedora, Redhat, Scientfic, MacOS
Posts: 76

Rep: Reputation: 19
Good! I am glad it worked for you! No doubt, there is always more than one way to do it.

--jason
 
  


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
Moving an existing Centos to a XenServer with different disk layout cerien Linux - Newbie 2 01-17-2012 06:21 AM
Install CloneZilla image to smaller disk EricTRA Linux - Software 1 08-18-2010 04:36 PM
[SOLVED] how to launch Disk Druid after CentOS installation? avee137 Linux - Newbie 2 05-20-2010 10:12 PM
Rebuild A Server Installation Disk from RHEL of CentOS Source RPm kenwee Red Hat 2 05-09-2006 04:36 AM
Free disk space in '/' getting smaller and smaller. simjii SUSE / openSUSE 5 12-16-2005 11:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

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