Mount hibernated Windows partition
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
Solution 1:
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}
Solution 2:
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.