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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
|
10-08-2013, 10:27 AM
|
#1
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Rep: 
|
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.
|
|
|
10-08-2013, 11:52 AM
|
#2
|
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,992
|
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...
|
|
|
10-08-2013, 01:44 PM
|
#3
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
You can try using testdisk to see what, if anything, is recoverable from the disk.
|
|
|
10-08-2013, 02:39 PM
|
#4
|
Member
Registered: Apr 2013
Location: France
Distribution: Slackware; Ubuntu
Posts: 136
Rep: 
|
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.
|
|
|
10-08-2013, 04:48 PM
|
#5
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,820
|
As there is no such thing as an "ext4" partition type in fdisk (closest would be type 83, "Linux"), I fear the worst.
|
|
|
10-08-2013, 10:24 PM
|
#6
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Original Poster
Rep: 
|
Quote:
Originally Posted by edorig
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.
|
|
|
10-09-2013, 08:43 AM
|
#7
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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.
|
|
|
10-09-2013, 10:42 AM
|
#8
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Original Poster
Rep: 
|
Quote:
Originally Posted by suicidaleggroll
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.
|
|
|
10-09-2013, 11:10 AM
|
#9
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,820
|
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.
|
|
|
10-09-2013, 11:31 AM
|
#10
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Original Poster
Rep: 
|
Quote:
Originally Posted by rknichols
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.
|
|
|
10-09-2013, 12:44 PM
|
#11
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
Quote:
Originally Posted by Yaze
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.
|
|
|
10-09-2013, 01:09 PM
|
#12
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Original Poster
Rep: 
|
Quote:
Originally Posted by suicidaleggroll
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.
|
|
|
10-09-2013, 02:03 PM
|
#13
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
Quote:
Originally Posted by Yaze
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
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.
|
|
|
10-09-2013, 07:34 PM
|
#14
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Original Poster
Rep: 
|
Quote:
Originally Posted by suicidaleggroll
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.
|
|
|
10-12-2013, 07:51 PM
|
#15
|
LQ Newbie
Registered: Oct 2013
Posts: 7
Original Poster
Rep: 
|
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.
|
|
|
All times are GMT -5. The time now is 05:42 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|