LinuxQuestions.org
Help answer threads with 0 replies.
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 10-29-2021, 02:14 PM   #1
virilo
LQ Newbie
 
Registered: Oct 2021
Posts: 1

Rep: Reputation: Disabled
xfs - Can't have a partition outside the disk


My hard drive crashed and a restoration company was able to copy everything to another new drive.

I think they used dd or similar.

It had two xfs partitions. But, now I can only mount the first one.

If I try to view the partitions with gparted it says:

Quote:
Can't have a partition outside the disk
It seems that the new disk was a little smaller than the original (different models):

Quote:
fdisk -l -u=sectors

Disk /dev/sdd: 9,1 TiB, 10000797794304 bytes, 19532808192 sectors
Disk model: Elements 25A3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt

Device Start End Sectors Size Type
/dev/sdd1 2048 9766436863 9766434816 4,6T Linux filesystem
/dev/sdd2 9766436864 19532871679 9766434816 4,6T Linux filesystem
But the numbers doesn't match!:

Quote:
19532808192-9766434816-9766434816-2048 = -63488
How can I update the partition table and xfs file system to fit the current hard drive?
 
Old 10-29-2021, 02:43 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
There are several possibilities.

You can attempt automatic repair with TestDisk.

Or do it manually with fdisk.

Other options include GParted and Boot-Repair.
 
Old 10-29-2021, 02:56 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,973

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
There is also a partition repair that hasn't been updated in a long time but may still work.
Ranish.

I'd make a dd copy of the drive before I started any repair.
 
Old 10-29-2021, 06:29 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by virilo View Post
Code:
fdisk -l -u=sectors

Disk /dev/sdd: 9,1 TiB, 10000797794304 bytes, 19532808192 sectors
Disk model: Elements 25A3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt

Device Start End Sectors Size Type
/dev/sdd1 2048 9766436863 9766434816 4,6T Linux filesystem
/dev/sdd2 9766436864 19532871679 9766434816 4,6T Linux filesystem
Simpler arithmetic, same result: (19532871679+1) - 19532808192 = 63488

It's fairly straightforward to make an empty file of size 63488*512 and use dmsetup to create a virtual drive appending that file to the end of /dev/sdd2. That virtual drive could then be checked, mounted, and even shrunk to fit in the available space on the physical disk. The problem here with that is that xfs probably won't let you mount the drive without first running xfsrepair, that repair operation has the potential to cause unrecoverable data loss, and an xfs filesystem cannot be shrunk in place.

Should you want to try it anyway:
Code:
truncate --size=$((63488*512)) /var/tmp/padfile
losetup -vf /var/tmp/padfile
echo -e "0 9766434816 /dev/sdd2 0 \n 9766434816 63488 /dev/loop0 0" | dmsetup create padded
If the device returned by losetup is other than "/dev/loop0", use that instead in the echo command. You can now use "/dev/mapper/padded" as the device name in mount, xfsrepair, etc. commands.

To unwind:
Code:
dmsetup remove padded
losetup -d /dev/loop0
rm /var/tmp/padfile
But, you really shouldn't be attempting that repair on your only copy of the data. If you're going to need a new drive with sufficient capacity to hold that data, you might as well just get a drive at least as large as the original and just "dd" this slightly-too-small drive to it. Way simpler, a lot safer.
 
  


Reply


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
[SOLVED] Gparted -- Error: Can't have a partition outside the disk! 1veedo Linux - Hardware 2 12-23-2012 02:41 AM
KVM on Redhat 5.7: KVM can ping outside network, outside network can't ping KVM svandyk Linux - Networking 1 09-23-2011 06:45 AM
sudo parted /dev/sda print Error: Can't have a partition outside the disk! MichaelSTL77 Ubuntu 1 02-28-2011 09:42 PM
Can't have a partition outside the disk? drchoi Fedora 3 07-20-2007 07:16 PM
My clients "can browse" outside but "can't ping" outside mrnoe Linux - Networking 1 09-05-2003 02:55 PM

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

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