LinuxQuestions.org
Review your favorite Linux distribution.
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 10-08-2013, 10:27 AM   #1
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Rep: Reputation: Disabled
Can a xfs partition be recovered after being partitioned to etx4?


Can a xfs partition be recovered after being partitioned to etx4, and if yes how? The partition has not been used since.
 
Old 10-08-2013, 11:52 AM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,505

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
have you written the ext4 to the partition table? then unless you are going to spend a lot of money to bit by bit recover, i doubt your data is there. thus the note from fdisk, by performing this task all data will be destroyed...
 
Old 10-08-2013, 01:44 PM   #3
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,725

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
You can try using testdisk to see what, if anything, is recoverable from the disk.
 
Old 10-08-2013, 02:39 PM   #4
edorig
Member
 
Registered: Apr 2013
Location: France
Distribution: Slackware; Scientific Linux
Posts: 106

Rep: Reputation: Disabled
Can you explain precisely what you have done ? Have you simply changed the type of the partition from XFS
to ext4 in fdisk without doing mkfs -t ext4 on the partition ? Have you left the partition unmounted after that ?
Then you might have a chance to save your partition using dd if=/dev/sd??? of=... (where /dev/sd??? is
your original partition, ... a free partition of the same size on a different disk or a file on a sufficiently
large device that you can mount with the loopback option of mount). You could also try to use fdisk to turn
the type of the partition back to XFS and then mount it, but it is better to backup your partition first if you
can.

If you have done something more drastic, such as resizing the partition before/after changing it to ext4,
formatting it with mkfs or mounting it in the filesystem, there is not much hope. XFS partitions do not tolerate
being shrunk, must be increased in size with the proper tool, and mkfs erases all metadata. You can always try
the dd trick, but you will need an XFS guru to recover your data.
 
Old 10-08-2013, 04:48 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,408

Rep: Reputation: 594Reputation: 594Reputation: 594Reputation: 594Reputation: 594Reputation: 594
As there is no such thing as an "ext4" partition type in fdisk (closest would be type 83, "Linux"), I fear the worst.
 
Old 10-08-2013, 10:24 PM   #6
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by edorig View Post
Can you explain precisely what you have done ? Have you simply changed the type of the partition from XFS
to ext4 in fdisk without doing mkfs -t ext4 on the partition ? Have you left the partition unmounted after that ?
Then you might have a chance to save your partition using dd if=/dev/sd??? of=... (where /dev/sd??? is
your original partition, ... a free partition of the same size on a different disk or a file on a sufficiently
large device that you can mount with the loopback option of mount). You could also try to use fdisk to turn
the type of the partition back to XFS and then mount it, but it is better to backup your partition first if you
can.

If you have done something more drastic, such as resizing the partition before/after changing it to ext4,
formatting it with mkfs or mounting it in the filesystem, there is not much hope. XFS partitions do not tolerate
being shrunk, must be increased in size with the proper tool, and mkfs erases all metadata. You can always try
the dd trick, but you will need an XFS guru to recover your data.
What I have done is selecting the wrong partition type by mistake for an existing xfs partition during the installation of Ubuntu. I have left the partition unmonted after releasing the problem, it went through on boot cycle.

Last edited by Yaze; 10-08-2013 at 11:28 PM.
 
Old 10-09-2013, 08:43 AM   #7
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,725

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
Why did you select ANY partition type during re-installation???

Selecting a partition type is only needed if you're telling the installer to reformat the partition. You should not have selected to reformat the partition at all, but instead to just leave it alone. From the sound of it, you would have lost your data regardless of what partition type you selected, since you told the installer to reformat the partition.

Last edited by suicidaleggroll; 10-09-2013 at 09:11 AM.
 
Old 10-09-2013, 10:42 AM   #8
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
Why did you select ANY partition type during re-installation???

Selecting a partition type is only needed if you're telling the installer to reformat the partition. You should not have selected to reformat the partition at all, but instead to just leave it alone. From the sound of it, you would have lost your data regardless of what partition type you selected, since you told the installer to reformat the partition.
I always select my partitions manually during installation, and NO, I did not choose to reformat the xfs partition, I just wrongly selected ext4 (which is the default) instead of xfs. I assume that the installer did reformat the partition, but did it, or it just changed the drive type. I'm not sure.

Last edited by Yaze; 10-09-2013 at 10:44 AM.
 
Old 10-09-2013, 11:10 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,408

Rep: Reputation: 594Reputation: 594Reputation: 594Reputation: 594Reputation: 594Reputation: 594
You can run "file -s /dev/sdxx" (where "xx" is the drive and partition number) to see what filesystem is there now. You could also try mounting it read-only (mount -o ro /dev/sdxx /some/where) and see what type gets mounted.

And again, there is no such thing as an "ext4 drive type." The only thing that makes a partition or LV "ext4" is if it has an ext4 filesystem formatted on it (specifically, that it has the magic number for an ext4 super block at the appropriate location).

Last edited by rknichols; 10-09-2013 at 11:14 AM.
 
Old 10-09-2013, 11:31 AM   #10
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
You can run "file -s /dev/sdxx" (where "xx" is the drive and partition number) to see what filesystem is there now. You could also try mounting it read-only (mount -o ro /dev/sdxx /some/where) and see what type gets mounted.

And again, there is no such thing as an "ext4 drive type." The only thing that makes a partition or LV "ext4" is if it has an ext4 filesystem formatted on it (specifically, that it has the magic number for an ext4 super block at the appropriate location).
Thanks for your input. Ubuntu's installer indeed does select ext4 as the manual partition type when one chooses to manually select the partitions. Is it possible that the installer as changed the partition type but not reformatted the partition? I just don't know. I'll run different checks later, someone also mentioned trying testdisk on the whole drive, I'll see if that helps me in any way.
 
Old 10-09-2013, 12:44 PM   #11
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,725

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
Quote:
Originally Posted by Yaze View Post
Thanks for your input. Ubuntu's installer indeed does select ext4 as the manual partition type when one chooses to manually select the partitions. Is it possible that the installer as changed the partition type but not reformatted the partition? I just don't know. I'll run different checks later, someone also mentioned trying testdisk on the whole drive, I'll see if that helps me in any way.
As far as I remember (it's been a long time since I installed Ubuntu), there is a special option in the installer to NOT reformat the drive, its own unique check box. If you select that option, there is no filesystem type dialog. If you were able to select a filesystem type, then you must have NOT selected the "do not reformat this partition" option, which means it was most likely reformatted.
 
Old 10-09-2013, 01:09 PM   #12
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
As far as I remember (it's been a long time since I installed Ubuntu), there is a special option in the installer to NOT reformat the drive, its own unique check box. If you select that option, there is no filesystem type dialog. If you were able to select a filesystem type, then you must have NOT selected the "do not reformat this partition" option, which means it was most likely reformatted.
This is a bit outside of my original question, but in the Ubuntu installer one can choose to manually select the partitioning scheme "You can create or resize partitions yourself, or choose multiple partitions for Ubuntu.". Then you can create new partitions or select existing ones. I've done this so many time that my mistake is an oversight. I always select one partition to be the root / choose to have it reformatted, then another existing one to be /home (I don't choose to have this one reformatted), then on another drive, I select an existing xfs partition, then change the default partition type "use as" from the proposed ext4 to xfs, give it the proper "Mount point" /Whatever, do not select the "Format the partition" checkbox, and I'm good to go. This time I just kept by mistake the partition type of ext4, but still did not check the "Format the partition" checkbox.
 
Old 10-09-2013, 02:03 PM   #13
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,725

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
Quote:
Originally Posted by Yaze View Post
This is a bit outside of my original question
Not really, we're trying to establish what the installer actually did, so we can see if the partition will be recoverable.


I'm VERY curious what on earth this option in the installer
Quote:
Originally Posted by Yaze View Post
change the default partition type "use as" from the proposed ext4 to xfs
actually does if you're not reformatting the partition, if anything. Is it possible that all this option does is populate the 3rd column in /etc/fstab? I've never seen that option in any installer from any other distro...mostly because it makes no sense.

Last edited by suicidaleggroll; 10-09-2013 at 02:12 PM.
 
Old 10-09-2013, 07:34 PM   #14
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
Not really, we're trying to establish what the installer actually did, so we can see if the partition will be recoverable.


I'm VERY curious what on earth this option in the installer

actually does if you're not reformatting the partition, if anything. Is it possible that all this option does is populate the 3rd column in /etc/fstab? I've never seen that option in any installer from any other distro...mostly because it makes no sense.
I'm not sure what this option in the installer actually is in Ubuntu, but it's been there for many versions and I've been using it during installations as explained. I'll be trying testdisk on the dd copy tomorrow, I'll post if I have any successful results.
 
Old 10-12-2013, 07:51 PM   #15
Yaze
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Testdisk couldn't do anything. I was able to use photorec to restore the data, music files mostly, and using Musicbrainz Picard I was able to then rename the restored file automatically.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
While using Testdisk, I think I recovered the incorrect partition psychmike23 Linux - Newbie 1 01-26-2012 05:02 PM
Can existing ext3 partition be without partitioned again dh2k Slackware 4 08-11-2008 08:00 PM
xfs partitioned disk unmountable (superblock errors) - any hope of rescuing data? mattp52 Linux - Hardware 9 03-17-2008 03:25 PM
Need to know the command which shows all non-partitioned & partitioned hard drive saidul Linux - Newbie 2 12-04-2007 04:02 PM
testdisk stuff with adding a recovered reiserfs partition wini_g Linux - Software 2 11-07-2003 07:45 PM


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