Mount hibernated Windows partition

5

1

I am trying to mount my Windows partition at boot. It works fine when Windows is in shutdown, but when Windows is hibernated, it can't be mounted as read/write, and I am sent to the root shell at boot. I tried to solve this by adding errors=remount-ro to my fstab, to mount it read-only if it can't be mounted as read/write when it is hibernated, but it doesn't work, and I still get an error at boot.

Is there a way to work around this and boot the partition as read/write when possible, but as read-only when it is hibernated?

# <file system> <dir>   <type>  <options>   <dump>  <pass>
UUID=1f026730-1640-42fa-b5f6-eca9749b3a98 /boot ext4 defaults 0 2
UUID=2b5c372b-d6d5-4c27-9c3f-5e26ca84d3a7 /home ext4 defaults 0 2
UUID=2c154114-4898-45e6-8455-575e910d8382 / ext4 defaults 0 1
UUID=92041326-03a7-4fdc-9211-c060e83d662e swap swap defaults 0 0
UUID=A28034F38034CF91 /media/win7 ntfs defaults,user,exec,dev,suid,errors=remount-ro 0 0

BrtH

Posted 2013-04-08T16:46:01.633

Reputation: 166

Answers

3

I ended up removing the line from /etc/fstab. I now mount the Windows partition in ~/.xinitrc, by using the return code from mount:

# Mount windows
sudo mount -o defaults,user,exec,dev,suid /dev/sda1 /media/win7
if [ $? -eq 14 ]
then
  sudo mount -o defaults,user,exec,dev,suid,ro /dev/sda1 /media/win7
fi

To be warned/informed about the way the partition is mounted, I also added the following to my Conky configuration:

/dev/sda1 (Windows) is mounted:
${if_match "${exec mount | grep /dev/sda1 | grep -Eo [^a-z]ro[^a-z] | grep -o ro}" == "ro"}${font bold}${alignc}READ-ONLY: WATCH OUT!!!
${else}${alignc}R/W (normal)
${endif}

BrtH

Posted 2013-04-08T16:46:01.633

Reputation: 166

1

Is ntfs-3g installed? The man page says:

Unlike in case of read-only mount, the read-write mount is denied if the NTFS volume is hibernated. One needs either to resume Windows and shutdown it properly, or use this option which will remove the Windows hibernation file. Please note, this means that the saved Windows session will be completely lost. Use this option under your own responsibility.

So if you want to mount with read-write ability you have to remove the hibernate file with remove_hiberfile. I also remember using the force option to mount that partition anyway.

Shabgard

Posted 2013-04-08T16:46:01.633

Reputation: 11

Yes, I know I have to remove the hiber file to mount it rw, I said that in the question. But I am looking for a solution where I don't have to remove it, and where it is mounted r/w when possible, but r/o when it is hibernated. – BrtH – 2013-04-19T15:21:42.597

But I didn't know about the remove_hiberfile option, so if nothing else comes up I'm afraid I'll have to use that. – BrtH – 2013-04-19T15:31:12.287

If it's an microsoft ntfs drive, you have to play by their rules! – Shabgard – 2013-04-19T21:26:50.957

I don't think you want to use the remove_hiberfile option. I'm fairly certain that using it left my drive in an unsafe state and lead to an irrecoverably damaged Win7 installation. There wasn't any other change that I can remember before it happened that could have been blamed, but I can be 100% sure. – Tyler – 2014-04-03T14:50:05.317

0

It is the ntfs-3g driver that is refusing to mount the partition in write mode, unless one removes the hibernation file.

Without discussing whether it is a good idea to circumvent it, you could try to use another driver, such as the free Paragon NTFS&HFS for Linux 8.5 Express (registration required).

You might need to uninstall or disable ntfs-3g for this to work, but uninstallation is not guaranteed to work (or be easy to reinstall again). Better do the testing on a Linux system that can be restored in case of error.

harrymc

Posted 2013-04-08T16:46:01.633

Reputation: 306 093