One.G
unread,Sep 21, 2008, 12:21:11 PM9/21/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to GZUC-Linux
1. 手工挂载
在Linux中也可以读取Windows分区,包括fat32格式的和ntfs格式的。首先你得知道Linux下对硬盘分区的称呼。比如
Windows下的C盘通常是hda1,D盘是hda5,E盘是hda6,等等。详细情形请看相关文档。
要挂载Windows分区,首先得确定你所用的Linux系统的locale(这个locale包括了系统使用的语言和字符的编码等信息)。中文
Linux 常用的locale是zh_CN.gb2312,zh_CN.gbk,zh_CN.gb18030 和 zh_CN.UTF-8 。
在默认安装中,Debian Linux和Mandriva Linux的locale是zh_CN.gb2312,而Ubuntu Linux和
Fedora Linux的locale是zh_CN.UTF-8 。最好不要随便更改locale,否则会出现很多乱码的情形。要查看系统的
locale,可以在终端下输入下面的命令查看:
echo $LANG
其次,你得知道你的windows分区的格式,这个在windows的分区的属性中可以看到,一般是fat32和ntfs格式的。
假设你的locale是zh_CN.UTF-8,要挂载一个/dev/hda1的fat32格式的windows分区到/mnt/C目录(若这个目
录不存在手工新建一个),可以在终端下输入以下命令(在Ubuntu里还需要在这行命令前加上sudo):
mount -t vfat /dev/hda1 /mnt/C -o iocharset=utf8
如果你的locale不是zh_CN.UTF-8,把上面命令的utf8改为gb2312;如果这个windows分区是ntfs格式的,将上面命
令的vfat改为ntfs。
这样挂载的ntfs格式的分区,只有root能读取,如果需要让普通用户也能读取,需要再加上umask=022选项,如下:
mount -t ntfs /dev/hda1 /mnt/C -o iocharset=utf8,umask=022
类似地,如果要让挂载的分区允许所有用户读取和修改,可以将上面的umask=022,改为umask=0就可以了。
卸载分区就简单多了:
umount /dev/hda1
有时候卸载分区时提示分区繁忙(device is busy),可以先用下面的命令看看哪个进程在使用此分区:
fuser -cu /dev/hda1
假如屏幕的输出为
/dev/hda1: 8463m(cck)
则可以用此命令看这个进程对应的程序名字:
ps 8463
然后可以用此命令结束此进程:
kill -9 8463
这样就可以正常卸载分区了。
2. 自动挂载
要让Linux系统启动时自动挂载windows分区,可以把上述的命令写入 /etc/fstab 文件中,下面是一个例子:
# /etc/fstab: static file system information.
#
#[file system] [mount point] [type] [options] [dump] [pass]
proc /proc proc defaults 0 0
/dev/hda9 / ext3 defaults 0 1
/dev/hda13 none swap sw 0 0
/dev/hdc /media/cdrom iso9660 ro,user,noauto 0 0
/dev/fd0 /media/floppy auto rw,user,noauto 0 0
/dev/hda10 /mnt/debian ext3 defaults 0 0
/dev/hda1 /mnt/C ntfs utf8,umask=022 0 0
/dev/hda5 /mnt/D vfat utf8,umask=0 0 0