取消Ubuntu自动挂载Windows系统磁盘分区


由于工作需要,需要取消掉在Ubuntu下,通过“位置”菜单去挂载Windows系统分区,折腾了半天,尝试了各种方法,最后终于找到了比较合适的方法了。现把具体过程做以总结。

首先要知道Windows分区的卷标,注意:通过fdisk -l 命令显示的"/dev/sda5",类似的不是卷标,而是设备号。过程如下:

1) 安装mtools 软件包

sudo apt-get install mtools 2) 通过fdisk -l查看本机硬盘各个分区的设备号:

sudo fdisk -l    显示结果:

Disk /dev/sda: 160.0 GB, 160041885696 bytes

255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x15d355a0
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       10325    82935531    7  HPFS/NTFS
/dev/sda2           10326       19305    72131850    f  W95 Ext'd (LBA)
/dev/sda4           19306       19457     1220940   12  Compaq diagnostics
/dev/sda5           10326       16699    51199123+   c  W95 FAT32 (LBA)
/dev/sda6           16700       18668    15815961    c  W95 FAT32 (LBA)
显示信息中”/dev/sda5” 即为对应的一个分区的设备号。

3) 复制”/etc”目录下mtools.conf文件为新文件"~/.mtoolsrc"

cp /etc/mtools.conf ~/.mtoolsrc 4) 编辑刚复制的”~/.mtoolsrc”文件,在最后一行加入如下命令行:

drive f: file="/dev/sda4"
drive g: file="/dev/sda5"
drive j: file="/dev/sda6"
5) 更改命令提示符路径到上面所设的”f:, g: ,j: ”分区,如到"g:"分区

sudo mcd g:    注意:由于g所对应的分区有50多G,http://ubuntuone.cn在执行上面命令是会报如下错误:

Total number of sectors (102383934) not a multiple of sectors per track (63)!
Add mtools_skip_check=1 to your .mtoolsrc file to skip this test  解决办法很简单,根据提示,在上面的~/.mtoolsrc文件中添加“mtools_skip_check=1”便可。

6) 查看”g:”当前的卷标

sudo mlabel -s g:     可能会显示没有卷标名。

7) 添加“g:”分区卷标或更改”g:”分区原始卷标为你喜欢的新卷标名:

sudo mlabel g:winD8) 检查更改是否成功

sudo mlabel -s g:

卷标修改好后,下来可以去修改一个关键的配置文件了。执行如下命令:

 

sudo gedit /usr/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi在如下字段的后面添加需要取消掉自动挂载的windows分区。

 <!-- Here follow volumes we specifically want to ignore - it is the -->
      <!-- responsibility of software higher in the stack (e.g. gnome-vfs) -->
      <!-- amd mount programs (e.g. Mount() on HAL) to respect volume.ignore -->
      <merge key="volume.ignore" type="bool">false</merge>
      <!-- Should always ignore Apple Bootstrap partitions (it would be -->
      <!-- a security hole to mount it) - TODO: should use the bootable -->
      <!-- flag from the Mac partition table instead -->

      <!-- ignore winD, winE disk -->
      <match key="volume.fstype" string="vfat">
 <match key="volume.label" string="winE">
          <merge key="volume.ignore" type="bool">true</merge>
 </match>
      </match>
      <match key="volume.fstype" string="vfat">
 <match key="volume.label" string="winD">
          <merge key="volume.ignore" type="bool">true</merge>
 </match>
      </match>
      <!-- -->

至此,所有工作完成,重启电脑可以看看了,在“位置”菜单中看不到Windows分区了,在“计算机”菜单中也看不到了。

相关内容