1

I have Win10 / Ubuntu 18.04 dual boot, and something messed up my partitions. I did try to resize the Win10 partition in order to enlarge my Ubuntu partition, but that didn't work so I resized back and the Ubuntu OS worked fine after that.

The Ubuntu OS started booting into emergency mode, after I commented out 2 lines in /etc/fstab it boots OK (without access to these 2 partitions) and the fstab file looks like:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda7 during installation
UUID=0c6086f3-8854-4a14-a4f2-d5836d1e63fa /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda3 during installation
UUID=4e3c7655-e09c-40ff-ab56-7e9a2697d0ad /boot           ext4    defaults        0       2
# swap was on /dev/sda5 during installation
#UUID=882b5e35-082f-4b8f-8fcf-5caef75083f4 none            swap    sw              0       0
# (identifier)  (location, eg sda5)   (format, eg ext3 or ext4)      (some settings) 
#UUID=60d8bff6-4bbb-4b72-aa4b-6f89737ad238   /home        ext4    defaults       0       2

Currently, /boot is on sda3 but / is on sda5 and not sda7 as written in the fstab (I don't know if it matters). I had to comment out the swap and home lines, which refer to UUIDs which are not present.

The output of blkid shows 2 partitions (sda1 and sda2) which belong to the Win10 installation, and 2 partitions (sda3 and sda5) which belong to Ubunto. But sda4, where my /home was on, is not showing. when I try file -s /dev/sda4 I get

/dev/sda4: DOS/MBR boot sector; partition 1 : ID=0x83, start-CHS (0x0,0,2), end-CHS (0x3ff,254,63), startsector 1, 39366656 sectors; partition 2 : ID=0x5, start-CHS (0x3ff,254,63), end-CHS (0x3ff,254,63), startsector 39366594, 31998015 sectors, extended partition table

and fdisk -l /dev/sda gives

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048   3074047   3072000   1.5G  7 HPFS/NTFS/exFAT
/dev/sda2         3084480 244380779 241296300 115.1G  7 HPFS/NTFS/exFAT
/dev/sda3       244381696 248381439   3999744   1.9G 83 Linux
/dev/sda4       248383487 488396799 240013313 114.5G  f W95 Ext'd (LBA)
/dev/sda5       248383488 287750143  39366656  18.8G 83 Linux

So for some reason this partition is shown as W95. Also, fdisk -l /dev/sda4 shows

Failed to read extended partition table (offset=39366594): Invalid argument
Disk /dev/sda4: 1 KiB, 1024 bytes, 2 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device      Boot    Start      End  Sectors  Size Id Type
/dev/sda4p1             1 39366656 39366656 18.8G 83 Linux
/dev/sda4p2      39366594 71364608 31998015 15.3G  5 Extended

Any advice how to recover that lost sda4 partition? EDIT Is it safe to try and change the partition type using cfdisk?

EDIT2 maybe this helps to understand, from cfdisk. That free space device at the end shouldn't be there, that's the space where /home was.

    Device                Boot                     Start               End           Sectors           Size         Id Type
>>  /dev/sda1             *                         2048           3074047           3072000           1.5G          7 HPFS/NTFS/exFAT        
    Free space                                   3074048           3084479             10432           5.1M
    /dev/sda2                                    3084480         244380779         241296300         115.1G          7 HPFS/NTFS/exFAT
    /dev/sda3                                  244381696         248381439           3999744           1.9G         83 Linux
    /dev/sda4                                  248383487         488396799         240013313         114.5G          f W95 Ext'd (LBA)
    ├─/dev/sda5                                248383488         287750143          39366656          18.8G         83 Linux
    └─Free space                               287752192         488396799         200644608          95.7G

EDIT3 Output of blkid:

/dev/sda3: UUID="4e3c7655-e09c-40ff-ab56-7e9a2697d0ad" TYPE="ext4" PARTUUID="8f76ec72-03"
/dev/sda3: UUID="4e3c7655-e09c-40ff-ab56-7e9a2697d0ad" TYPE="ext4" PARTUUID="8f76ec72-03"
/dev/sda4: PTTYPE="dos" PARTUUID="8f76ec72-04"
/dev/sda5: UUID="0c6086f3-8854-4a14-a4f2-d5836d1e63fa" TYPE="ext4" PARTUUID="8f76ec72-05"```
  • 1
    I'll add it in the question. I have some important data on it so I prefer not to format it unless there's no other option – Itamar Katz Jan 12 at 11:06
  • Not sure what you changed. And labels in fstab are what partitions were when installed, not necessarily after changes. And changes with Windows can create issues. Only use Windows tools to shrink NTFS and always have a backup of partition table with sudo sfdisk -d /dev/sda > PT_sda.txt The extended partition cannot have data, it is just a container for logical partitions. Note that sda4 starts at same sector as sda5. But you have unallocated space in the extended partition. Is that another logical partition with data? ubuntuforums.org/showthread.php?t=2288988 – oldfred Jan 12 at 15:18
  • The unallocated space has the lost /home partition which had its own logical partition. I am currently using a partition recovery tool from within windows, and it identified the 2 partitions on the unallocated space (there was also a swap partition there). – Itamar Katz Jan 13 at 10:01
  • Btw, how can I restore a partition table that was saved using sfdisk you suggested? – Itamar Katz Jan 13 at 10:02
  • More info on sfdisk. ubuntuforums.org/showthread.php?t=1192598 See also man sfdisk Old versions did not support gpt, new versions now support gpt and text file structure is different. So be sure to use same version of sfdisk. Parted rescue seems easier than testdisk askubuntu.com/questions/665445/… – oldfred Jan 13 at 17:34
1

I post this as answer since it solved my problem:

  1. The problem reason was (probably) resizing the Win10 partition from within Win10, that messed up the Linux partition table for some reason.
  2. Using testdisk from Ubuntu live-cd, I recovered the lost partition
  3. I had to edit /etc/fstab manually to set my home folder back to the lost partition.
  4. I learned my lesson regarding the importance of backups :)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.