Problems copying/resizing hard disk with mixed ext3/xfs partitions
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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?
... 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.
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?
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.