LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-16-2012, 12:32 AM   #1
ppmoore
LQ Newbie
 
Registered: Sep 2006
Posts: 23

Rep: Reputation: 0
Post Problems copying/resizing hard disk with mixed ext3/xfs partitions


I want to replace the hard disk of my NAS driver with a bigger disk (1TB -> 2TB). The linux OS resides on the first 2GB, and the user shares on the rest. The user partition is XFS-formatted. I copied the contents of the old to the new disk using the dd command, and now need to resize the user partition, and hopefully also realign all partitions to match the new disk's 4096B sector size, since the old disk uses 512B sectors.

Here's the new disk's partition map, as reported by parted:
Model: ATA ST2000DL003-9VT1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos

Number Start End Size Type File system Flags
1 32.3kB 2056MB 2056MB extended
5 64.5kB 263MB 263MB logical linux-swap(v1)
6 263MB 271MB 8193kB logical
7 271MB 280MB 8193kB logical ext3
8 280MB 1152MB 872MB logical ext3
9 1152MB 2048MB 897MB logical ext3
10 2048MB 2056MB 8193kB logical
2 2056MB 1000GB 998GB primary xfs

The same disk as reported by fdisk:
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0004e029

Device Boot Start End Blocks Id System
/dev/sda1 63 4016249 2008093+ 5 Extended
Partition 1 does not start on physical sector boundary.
/dev/sda2 4024320 1953529855 974752768 83 Linux
/dev/sda5 126 514079 256977 82 Linux swap / Solaris
Partition 5 does not start on physical sector boundary.
/dev/sda6 514143 530144 8001 83 Linux
Partition 6 does not start on physical sector boundary.
/dev/sda7 530208 546209 8001 83 Linux
/dev/sda8 546273 2249099 851413+ 83 Linux
Partition 8 does not start on physical sector boundary.
/dev/sda9 2249163 4000184 875511 83 Linux
Partition 9 does not start on physical sector boundary.
/dev/sda10 4000248 4016249 8001 83 Linux

I tried resizing the user partition 2 using gparted, but that failed (the resized disk wouldn't boot) so searching this forum I discovered xfs_growfs. Reading some posts here, I didn't understand how to use this. It seems I have to resize the partition first, and then regrow the filesystem inside the partition?

I would then like to realign both partitions 1 and 2 to the new disk's 4096 sector size. I supposre I should first move the user partition 2 a few MB to realign it while resizing it, and then realign the linux partition 1?

Many ideas?
 
Old 11-16-2012, 03:21 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Quote:
Originally Posted by ppmoore View Post
... I copied the contents of the old to the new disk using the dd command,
IMHO, this is an extremely poor decision. "dd" is a stupid tool - very useful, but stupid; it does what you ask of it, which is usually not what is intended/hoped for.

In a situation like this, I recommend you preallocate the target partitions the way you want (alignment/size/filesystem), and use a filesystem-aware tool (rsync, cp, whatever) to copy the data. This way you will find out immediately if there are any errors in the source - something dd is unlikely to tell you about.

Quote:
... so searching this forum I discovered xfs_growfs. Reading some posts here, I didn't understand how to use this. It seems I have to resize the partition first, and then regrow the filesystem inside the partition?
True for (almost) all filesystem tools - they deal with the filesystem (and hence data) resident in the partition, not the partition itself.
 
Old 11-16-2012, 06:43 AM   #3
ppmoore
LQ Newbie
 
Registered: Sep 2006
Posts: 23

Original Poster
Rep: Reputation: 0
Thanks Syg00,

You mean something like the following:

1. Copy the first (63?) sectors containing the MBR using dd
2. Make the first extended partition starting on the first MiB boundary using parted, to solve the 4096B sector size problem
3. Create the internal logical partitions inside this partition using parted.
4. Create the XFS partition afer the first extended partition. How do I do this?
5. Copy the contents of each individual partition

I was thinking, is there an easier way to do this? Is there a way to copy the contents of a partition to another disk, such that an offset on the destination disk can be specified?

Last edited by ppmoore; 11-16-2012 at 06:45 AM.
 
Old 11-16-2012, 07:14 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,354

Rep: Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042Reputation: 1042
Any current distro (hint, you haven't told us yours), or probably better, liveCD will allocate new partitions properly aligned for you using any of the basic tools - parted included I would expect.
Tools like mondorescue or clonezilla will likely do the lot for you.

To your specific q's:
1) *NO* - this is almost never needed; would also copy the partition table anyway. You don't want that. Reinstall the boot-loader from a install/liveCD after everything else is done.
2) let parted handle the alignment.
3) yep
4) parted (maybe think of rearranging - why not the xfs as a logical as well ?)
5) yep
 
Old 11-16-2012, 09:27 AM   #5
ppmoore
LQ Newbie
 
Registered: Sep 2006
Posts: 23

Original Poster
Rep: Reputation: 0
Many thanks,

I'll look at both Clonezilla and MondoRescue.
 
  


Reply

Tags
partition, resize, xfs


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problems with an USB hard disk (ext3) - sdb reappeared as sdc cabrilo Linux - Hardware 6 02-18-2011 04:44 AM
Resizing Linux EXT3 partitions? linux_linux Linux - Newbie 6 03-15-2008 08:55 PM
Resizing ext3 partitions (/usr) [file system management] xxx_anuj_xxx Red Hat 5 11-29-2005 03:35 AM
Resizing ext3 partitions! alur3n Linux - General 3 10-03-2005 07:29 PM
Resizing ext3 partitions on RAID5 array greenhornet Linux - General 2 04-09-2002 08:22 AM


All times are GMT -5. The time now is 11:18 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration