How to disable access to Win7 disk partition(Dual Boot)

Use disks to hide the partition in Ubuntu

You want to remove the Windows 7 partition from the left left pane in Nautilus, where it can be mounted even when it's not in /etc/fstab. You want to hide the partition so they don't appear in Nautilus or elsewhere through Ubuntu.

Start Dash the first option on the Launcher

Type Disks and you will see the application Disks appear. Click on it.

A screen similar to this appears:

Open Disks

Left click on a Disk. Then left click on the Partition you want to hide.

Right click on the gear (follows the Left Arrow and -) and select Edit Mount Options and this screen appears:

enter image description here

Uncheck the option Show in User Interface.

Click OK and enter password to apply changes. After the next reboot Nautilus won't show the partition. Note that this doesn't erase the partition or delete any data on it.


Grub entries only will not show Windows bootable partitions in grub menu. If you do not want to see the NTFS partitions in Nautilus or be able to use them from Linux you actually have to mount them with fstab.

Hide mount template examples with noauto, you have to make the mount points yourself first and use your UUID in place of example's

sudo blkid -o list
sudo mkdir /mnt/win7
UUID=80A02B83A02B7F32 /mnt/win7 ntfs defaults,noauto,umask=777 0 0

The noauto prevents default mounting and 777 is no permissions at all.


There are two ways of doing this:

1) by removing (or commenting) following similar strings from file /boot/grub/grub.cfg:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (loader) (su /dev/sda4)' --class windows --class os $menuentry_id_option 'osprober-chain-CEDABB32DABB1625' {
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos4'
    if [ x$feature_platform_search_hint = xy ]; then
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos4 --hint-efi=hd0,msdos4 --hint-baremetal=ahci0,msdos4  CEDABB32DABB1625
    else
        search --no-floppy --fs-uuid --set=root CEDABB32DABB1625
    fi
    parttool ${root} hidden-
    chainloader +1
}
### END /etc/grub.d/30_os-prober ###

Command to modify the file:

sudo nano /boot/grub/grub.cfg

(You can use CTRL+K to cut strings in nano editor)

NB: by using this method, on next update-grub (for example on next kernel upgrade), Windows will appear again in bootable OS list screen (GRUB) on startup.

2) by moving the os-prober file from /etc/grub.d/ in a subfolder (I would call it /etc/grub.d/bak/) so update-grub will not read that file.

Then you have to call an update-grub to update file /boot/grub/grub.cfg.

Commands to execute are:

sudo mkdir /etc/grub.d/bak

sudo mv /etc/grub.d/30_os-prober /etc/grub.d/bak

sudo update-grub

NB: This method will hide every non-linux system on your HDD.

UNDOING PROCESS:

1) for the first method you just need to make a update-grub.

2) for the second one you have to move back the file you moved away from /etc/grub.d/ directory in its original path.

Commands to execute are:

sudo mv /etc/grub.d/bak/30_os-prober /etc/grub.d/

sudo update-grub

==========

If you don't want to see Windows partition while using Ubuntu you just need to remove the string associated with that partition:

Use this command to show wich number has your Windows partition:

sudo blkid -o list | grep ntfs

Then use the /dev/sdXY like string in the following command: (X = letter, Y = number)

enter image description here

sudo echo 'KERNEL=="sdXY", ENV{UDISKS_IGNORE}="1"' > /etc/udev/rules.d/hide-windows.rules

NB: Use your "XY"; the command will looks like the following:

sudo echo 'KERNEL=="sda4", ENV{UDISKS_IGNORE}="1"' > /etc/udev/rules.d/hide-windows.rules

UNDOING PROCESS:

Just remove the created file:

sudo rm /etc/udev/rules.d/hide-windows.rules