LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-26-2007, 04:42 AM   #1
yod9999
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Rep: Reputation: 0
moving/resizing partitions between drives


I've got an 80GB drive with the following partitions.

Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 5112 40957717+ 83 Linux
/dev/hda3 5113 5239 1020127+ 82 Linux swap / Solaris

/dev/hda1 is boot, /dev/hda2 is everything else. This box is used as a CCTV server (using Zoneminder - highly recommended btw), and the images it records are all written to a directory on /dev/hda1. This doesn't cause the disk to fill up because Zoneminder auto deletes when the free space gets below a certain percentage, but I want to move the images to a separate partition and add a much larger disk at the same time.

I think I can copy the existing partitions to a new larger disk using the following (or equivalent - here hda is the existing disk, hdb is the new larger disk - obviously I'll have to boot from a rescue cd to do this):

dd if=/dev/hda of=/dev/hdb

and then add a new partition at the end, but what I really want to do is also resize /dev/hda2 down to about 10Gb (it's currently ~40Gb) to maximise the amount of space available. I'll delete all the image files from /dev/hda2, which should bring the spaced used down to about 7Gb.

I think I can create the partitions on the new disk with the desired size using fdisk and then copy them individually. So /dev/hdb1 would be exactly the same as /dev/hda1, and /dev/hdb2 would be about 10Gb. I could then do

dd if=/dev/hda1 of=/dev/hdb1

which should work fine because the partitions are identically sized, but if I try

dd if=/dev/hda2 of=/dev/hdb2

then this will fail as hda2 is bigger than hdb2. I guess I could add conv=noerror but how do I guarantee that I'll get all the files off hda2. The total space used should be less than the size of the new partition, but is there the possibility that some files might be missed because they're located higher up the partition that the 10Gb point (remember that I've deleted all the images by this point so it's just important files left). Or is ext3 cleverer than this and will move all the files towards the start of the partition when I delete the images files. Or is there a totally different and better way to do this?

Cheers
 
Old 07-26-2007, 07:34 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
You may be making this too complicated.....
First, you talk of deleting files before resizing or cloning....If the stuff you need to keep is not too large, maybe it's better to simply copy the files. (Or are you trying to preserve the OS as well?)

I would back up essential files to some other media (DVD, external USB drive, etc.), install the new harddrive, and re-install the OS and configure.

Quote:
dd if=/dev/hda2 of=/dev/hdb2

then this will fail as hda2 is bigger than hdb2. I guess I could add conv=noerror but how do I guarantee that I'll get all the files off hda2. The total space used should be less than the size of the new partition, but is there the possibility that some files might be missed because they're located higher up the partition that the 10Gb point (remember that I've deleted all the images by this point so it's just important files left). Or is ext3 cleverer than this and will move all the files towards the start of the partition when I delete the images files. Or is there a totally different and better way to do this?
No, ext3 is not that clever, and "conv=noerror" won't make it work. dd is dumber than a post--it happily copies bytes from pt A to pt B until it runs out of room
 
Old 07-26-2007, 08:29 AM   #3
yod9999
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany
(Or are you trying to preserve the OS as well?)
yeah, i didn't specify that, sorry. i want to copy everything on to the bigger drive and then just boot from that. i don't want to have to go through reinstalling the os and all the apps. i could just dd the entire old drive on to the new drive and add a partition at the end, but i really wanted to reclaim the unused 30GB in the root partition. maybe it's just making it too complicated...

Quote:
Originally Posted by pixellany
No, ext3 is not that clever, and "conv=noerror" won't make it work. dd is dumber than a post--it happily copies bytes from pt A to pt B until it runs out of room
i thought as much - thanks for the confirmation
 
Old 07-26-2007, 12:16 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
You can certainly re-size any of your partitions--before or after cloning to the new disk. Best way is use something like the GPArted stand-alone bootable CD.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving and Resizing Partitions NetRAVEN5000 Linux - Hardware 5 02-18-2006 06:05 PM
Resizing and moving partitions linmix Linux - Software 16 04-09-2005 09:08 AM
resizing and moving partitions DAChristen29 Linux - Newbie 4 10-18-2004 09:48 PM
Moving and resizing partitions slyman Linux - General 2 07-04-2004 08:02 PM
Moving & Resizing partitions...? Nu-Bee Linux - General 2 01-02-2003 10:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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