0

UPDATE AT BOTTOM

My Ubuntu partition was running low on free space, so I decided to shrink the Windows partition down to 190GiB from about 400GiB. After shrinking there was still about half of it which was not used.

After shrinking (with Gparted) the Windows 10 partition (on /dev/sda4) Windows Boot Manager (on /dev/sda2) did not work. I also added the "boot" flag.

I have no clue what is wrong. If any information is needed, please answer how to get that information.

I think the Windows partition was efi before the shrink, but i am not sure.

BootInfo file of boot-repair with recommended options:

http://paste2.org/AfadHKG1

File gparted_details:

GParted 0.25.0 --enable-libparted-dmraid --enable-online-resize

Libparted 3.2

Shrink /dev/sda4 from 393.45 GiB to 190.43 GiB  00:05:05    ( SUCCESS )

calibrate /dev/sda4  00:00:03    ( SUCCESS )

path: /dev/sda4 (partition)
start: 1900544
end: 827034367
size: 825133824 (393.45 GiB)
check file system on /dev/sda4 for errors and (if possible) fix them  00:00:33    ( SUCCESS )

ntfsresize -i -f -v /dev/sda4  00:00:33    ( SUCCESS )

ntfsresize v2015.3.14AR.1 (libntfs-3g)
Device name : /dev/sda4
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 422468514304 bytes (422469 MB)
Current device size: 422468517888 bytes (422469 MB)
Checking for bad sectors ...
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 100204 MB (23,7%)
Collecting resizing constraints ...
Estimating smallest shrunken size supported ...
File feature Last used at By inode
Multi-Record : 247041 MB 560736
$MFTMirr : 1 MB 1
Compressed : 251592 MB 526808
Sparse : 137684 MB 35
Ordinary : 251593 MB 25298
You might resize at 100203016192 bytes or 100204 MB (freeing 322265 MB).
Please make a test run using both the -n and -s options before real resizing!
shrink file system  00:04:18    ( SUCCESS )

run simulation  00:00:35    ( SUCCESS )

ntfsresize --force --force -s 204474417152 --no-action /dev/sda4  00:00:35    ( SUCCESS )

ntfsresize v2015.3.14AR.1 (libntfs-3g)
Device name : /dev/sda4
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 422468514304 bytes (422469 MB)
Current device size: 422468517888 bytes (422469 MB)
New volume size : 204474413568 bytes (204475 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 100204 MB (23,7%)
Collecting resizing constraints ...
Needed relocations : 1918076 (7857 MB)
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
The read-only test run ended successfully.
real resize  00:03:43    ( SUCCESS )

ntfsresize --force --force -s 204474417152 /dev/sda4  00:03:43    ( SUCCESS )

ntfsresize v2015.3.14AR.1 (libntfs-3g)
Device name : /dev/sda4
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 422468514304 bytes (422469 MB)
Current device size: 422468517888 bytes (422469 MB)
New volume size : 204474413568 bytes (204475 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 100204 MB (23,7%)
Collecting resizing constraints ...
Needed relocations : 1918076 (7857 MB)
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Relocating needed data ...
100.00 percent completed
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/sda4'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
1) create it at the same disk sector (use sector as the unit!)
2) create it with the same partition type (usually 7, HPFS/NTFS)
3) do not make it smaller than the new NTFS filesystem size
4) set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.
shrink partition from 393.45 GiB to 190.43 GiB  00:00:11    ( SUCCESS )

old start: 1900544
old end: 827034367
old size: 825133824 (393.45 GiB)
new start: 1900544
new end: 401264639
new size: 399364096 (190.43 GiB)
========================================

Output of sudo mount /dev/sda2:

mount: /dev/sda2 is already mounted or /boot/efi busy
/dev/sda2 is already mounted on /boot/efi

Output of `sudo mount /dev/sda4

mount: can't find /dev/sda4 in /etc/fstab

Output of sudo parted -l:

Model: ATA HGST HTS545050A7 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size    File system     Name                          Flags
 1      1049kB  524MB  523MB   ntfs            Basic data partition          hidden, diag
 2      524MB   839MB  315MB   fat32           EFI system partition          boot, esp
 3      839MB   973MB  134MB                   Microsoft reserved partition  msftres
 4      973MB   205GB  204GB   ntfs            Basic data partition          boot, esp
 8      423GB   472GB  48,6GB  ext4
 9      472GB   476GB  3847MB  linux-swap(v1)
 5      476GB   476GB  489MB   ntfs                                          hidden, diag
 6      476GB   499GB  22,7GB  ntfs            Basic data partition          hidden, diag
 7      499GB   500GB  1074MB  fat32           Basic data partition          hidden, diag

UPDATE:

I have used boot-repair (comment from s1ns3nt) and Windows Boot Manager now works, but trying to boot Windows 10 (from Windows Boot Manager) returns me to grub! My boot order is:

BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0000,0002
Boot0000* Windows Boot Manager
Boot0001* ubuntu
Boot0002* ubuntu

I am not sure what Boot0002* ubuntu is. I am also not sure what the star (*) means.

PyotrK
  • 45
  • Can you add a Gparted screenshot or the output of the following command: sudo parted -l. It can be useful to understand better your issue. – Danibix Aug 24 '16 at 17:34
  • Added the output of sudo parted -l – PyotrK Aug 24 '16 at 17:45
  • Are you getting messages about the partition being "unclean" when you try to mount it in Ubuntu?

    If yes, did you remember to turn off the Fast Boot and Hibernate options in Windows before shrinking the drive? If those are on, Windows 8+ don't really shut down, they snapshot the OS and do a kind of hybrid hibernate.

    See the "REPAIRING THE BOOT" part of the guide here: http://askubuntu.com/questions/221835/installing-ubuntu-on-a-pre-installed-windows-10-with-uefi .

    Boot repair hasn't worked for me so far, but I already know that I have a motherboard that doesn't always play nice...

    – s1ns3nt Aug 24 '16 at 17:58
  • Did you shrink it from start of partition ? – Vivek Ji Aug 24 '16 at 18:02
  • Dont know, saved the " gparted_details.htm" – PyotrK Aug 24 '16 at 18:08
  • @s1ns3nt Added the mount output. I am not sure when it hibernates, but i think it was enabled. – PyotrK Aug 24 '16 at 18:09
  • Do 2 things 1. run sudo update grub 2. When windows boots (if) let it check file system. – Vivek Ji Aug 24 '16 at 18:18
  • update is not a command, did you mean something else. I anyways dont think grub is the issue, but Windows Boot Manager. And if possible, can you provide information on how to add Windows directly to grub instead of having to boot it from Windows Boot Manager. The Windows partition might be the issue anyways. – PyotrK Aug 24 '16 at 18:23
  • You show both gpt partitioning & ESP - efi system partition. Boot flag must only be on the ESP, and not on any other partition. Also generally best to use Windows own tools to shrink its NTFS partition and reboot immediately so it can do chkdsk. – oldfred Aug 24 '16 at 18:23
  • I think the Windows partition was efi before the shrink, but i am not sure. Will try removing the "boot" flag. – PyotrK Aug 24 '16 at 18:28
  • @oldfred Removing the "boot" flag removes the "esp" flag, and adds the "msftdata" flag. – PyotrK Aug 24 '16 at 18:45
  • @s1ns3nt Forgot to mention: I was trying to shrink the partition, but i could not because it was hibernated and i had no access to the partition. After booting into windows and closing all programs (I expected them to close when i turned off the computer the first time), i could then shrink the partition. – PyotrK Aug 24 '16 at 18:57
  • Only the ESP can have the boot flag. And if dual booting you must have the fast start or always on hibernation off in Windows. Or else you further corrupt it and then even Windows chkdsk may not work.http://askubuntu.com/questions/145902/unable-to-mount-windows-ntfs-filesystem-due-to-hibernation – oldfred Aug 24 '16 at 19:56
  • @s1ns3nt Ran boot-repair. You can see the BootInfo at http://paste2.org/AfadHKG1 – PyotrK Aug 25 '16 at 14:21
  • The * is that it is active. See man efibootmgr. You still show Windows fast start up on (hibernation). Grub will not boot hibernated Windows. You should be able to boot Windows directly from UEFI, but we cannot see BCD and what entries you have in it. Or if directly booting UEFI Windows entry and get grub, you may have copied shim over Windows .efi boot file bootmgfw.efi. – oldfred Aug 25 '16 at 17:11
  • grub has more options after running boot-repair. Not sure what they mean, might upload a screenshot. – PyotrK Aug 25 '16 at 17:54

1 Answers1

0

Installing and running boot-repair and making sure that there is no "boot" flag (in gparted) fixed it. Everything boots correctly.

PyotrK
  • 45