How to automatically mount hibernated NTFS to read-only?

First of all, you'll need to find the device id using:

sudo fdisk -l

Look for the one that's formatted as NTFS under System, and remember the device id (Should look something like /dev/sda2). Then create the mount directory and mount it.

mkdir Windows
sudo mount -o ro /dev/sdaX Windows

(Replace X with your device id)


I've found a way to mount a hibernated windows partition in read-only mode when any error occurs

I hope it would work for you too. I'm describing below how to do it.

  • Open /etc/rc.local file with root privileges in any editor.

    sudo gedit /etc/rc.local
    
  • Now add following lines at last:

    sudo mount /dev/sda7 /media/Dane
    if [ $? -eq 14 ]
    then
      sudo mount -o ro /dev/sda7 /media/Dane
    fi
    exit 0
    

    If exit 0 is already written then delete the duplicate. Be sure that /etc/sda7 is your windows partition that you're going to mount when error occurs and also there is already a directory, named Dane created in /media. If not then change /dev/sdaX accordingly and crate the directory.

  • Now update using following command:

    sudo update-rc.d -f /etc/rc.local
    

    I'm not sure whether this command is needed or not, but just execute it what every message it gives.

  • Now finally restart your system when Windows is hibernated.

A little description:

The command written in file /etc/rc.local actually executes before and after system boots, thus acts as a startup. The first command in script will try to mount the partition and get the error code it returns. so $? is 14 when any error occurs. $? is 16 when partition is already mounted and trying to mount it again...

Reply if something goes wrong. I'll be waiting for your reply..