Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2397617
  • 博文数量: 328
  • 博客积分: 4302
  • 博客等级: 上校
  • 技术积分: 5486
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 11:14
个人简介

悲剧,绝对的悲剧,悲剧中的悲剧。

文章分类

全部博文(328)

文章存档

2017年(6)

2016年(18)

2015年(28)

2014年(73)

2013年(62)

2012年(58)

2011年(55)

2010年(28)

分类:

2011-02-24 17:26:22


fdisk –l查看dos/win/ext2分区(partiton,不是slice,slice是solaris分区)
[root@localhost etc]# /sbin/fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1                      991     7960176    W95 FAT32
/dev/hda2             992        1629     5124735   83  Linux
/dev/hda3            1630        8070    51737332+   W95 Ext'd (LBA)
/dev/hda4   *        8071        9730    13327776   bf  Solaris
   这个是主分区,MBR(启动记录扇区)的所在

/dev/hda5            1630        1695      530113+  82  Linux swap / Solaris
/dev/hda6            1696        8070    51207156    W95 FAT32
linux 下把DOS扩展分区和逻辑分区都按hda1,2,3,4,5,6排列。扩展分区必须在1-4内,逻辑分区必须>4

 
   fdisk 用法
[root@vm /]# fdisk

Usage: fdisk [-l] [-b SSZ] [-u] device
E.g.: fdisk /dev/hda  (for the first IDE disk)
  or: fdisk /dev/sdc  (for the third SCSI disk)
  or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
  or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
 ...

mount无参数------显示当前mount上的设备

    df -h  常用于代替mount和/sbin/fdisk –l,来看当前mount情况,因为它不显示“虚mount设备”
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda2             4.8G  2.9G  1.7G  65% /
/dev/shm               93M      93M   0% /dev/shm
而mount显示的虚mount太多
[root@localhost etc]# mount
/dev/hda2 on / type ext2 (rw)

/dev/proc on /proc type proc (rw)  
automount(pid1622) on /misc type autofs (rw,fd=4,pgrp=1622,minproto=2,maxproto=4)
automount(pid1672) on /net type autofs (rw,fd=4,pgrp=1672,minproto=2,maxproto=4)
 这几个都是虚mount

/dev/hda1 on /mnt/c type vfat (rw) 


    linux 下设备名
IDE设备
/dev/hda1
   尾字母hda,hdb表示不同的硬盘
   尾数字hda1,hda2,hda3表示不同的分区
SCSI Device
/dev/sd2
光驱
/dev/cdrom
磁带
/dev/rmt/0                               (常用于tar)
软驱
/dev/fd    或 /dev/fd0


    注意,安装linux后,不要随便换硬盘的总线,或硬盘的master/slave,因为hda,hdb,都是自动生成的,换总线后或 master/slave后,会造成/dev 设备文件和fstab内容不匹配

    为什么/var都建议单独一个分区?
    /var分区是存放logfile以及系统变动文件的文件系统(/var/tmp和/var/lib/mysql之类的都很大)
    所以不要把/var文件系统包括再root分区里,以免有恶意程序恶意扩大日志文件来dos根分区


   为什么建议/home也单独一个分区?
一来也是为了保护/分区
二来单独分区可以单独处理,比如在其他系统下mount,tar等


    /etc/fstab-------开机自动mount windows分区
vi /etc/fstab

/dev/hda4    /mnt/wind    vfat    defaults,iocharset=utf8,umask=000 0 0
文件系统    mount point   分区格式            mount参数
                                     umask=000指定加载后的目录的权限问题,
                                     都是0,向所有用户开放读写权限

                               
     mount [option]  filesystem [mount-point]
-t vfat or ext2    -t :Type
  ext2    linux分区
  vfat    dos/win分区
  不设-t,缺省mount认为是vfat
-o utf8    utf8是编码格式,否则中文会有问题


    cat /proc/filesystems       --------获得系统支持的文件系统类型
[root@localhost dev]# cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   binfmt_misc
nodev   debugfs
nodev   usbfs
nodev   pipefs
nodev   futexfs
nodev   tmpfs
nodev   eventpollfs
nodev   devpts
        ext2                Linux用的文件系统
nodev   ramfs
nodev   hugetlbfs
        iso9660            光盘片用的文件系统
nodev   mqueue
nodev   selinuxfs
nodev   rpc_pipefs
nodev   autofs            autofs 光盘、软盘的自动加载

        vfat               Win95/98/2000文件系统
 
Solaris 的/proc下没有filesystems,全是进程文件


    最简单的mount "dos/win分区"步骤
1. Fdisk -l
[root@localhost macg]# /sbin/fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1                      991     7960176    W95 FAT32
/dev/hda2             992        1629     5124735   83  Linux
/dev/hda3            1630        8070    51737332+   W95 Ext'd (LBA)
/dev/hda4         8071        9730    13327776   bf  Solaris
Partition 4 does not end on cylinder boundary.
/dev/hda5            1630        1695      530113+  82  Linux swap / Solaris
/dev/hda6            1696        8070    51207156    W95 FAT32
2. mount
[root@localhost macg]# mount -t vfat /dev/hda6 /mnt/d
D盘为什么是6,因为是扩展分区上的逻辑分区 ,逻辑分区都大于4
[root@localhost macg]# ls /mnt/d
avi                   game                 military          temp
CloneCD.v5.2.1.1.rar  ghostmp3cdmaker.rar  Nero_6.6.1.4.zip  The.Hot.the.Cool.&_.the.Vicious.1976.dvdrip.cd2.avi
Diablo II             image.ccd            nero.rar          treat1
Drivers               image.img            Recycled          UltraISO_8.2.0.1665.zip
dvdoutput             image.sub            short             yao



    umount卸载的参数要针对文件系统(filesystem),而不是mount point
umount   /dev/hda6       


    mount 软盘
#mount -t ext2 /dev/fd0 /mnt/fd
注意在取出软盘之前要unmount /mnt    否则会导致信息丢失


   注意mount光驱,不能用-t vfat/ext2,要用-t iso9660
# mount -t ext2 /dev/cdrom /mnt/c
mount: block device /dev/cdrom is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/cdrom,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
# mount -t vfat /dev/cdrom /mnt/c
mount: block device /dev/cdrom is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/cdrom,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
# mount -t iso9660 /dev/cdrom /mnt/c
mount: block device /dev/cdrom is write-protected, mounting read-only
# ls /mnt/c
stuck  



   redhat下,真正的光驱设备文件是设备文件,其他的都是链接
# ls -l
crw-------  1 root root  10, 134 Feb  2007 apm_bios
crw-------  1 root root  14,   4 Feb  2007 audio
lrwxrwxrwx  1 root root        3 Feb  2007 cdrom -> hdb
lrwxrwxrwx  1 root root        3 Feb  2007 cdwriter -> hdb
crw-rw----  1 root root   5,   1 Feb  2007 console
lrwxrwxrwx  1 root root        3 Feb  2007 dvd -> hdb
lrwxrwxrwx  1 root root        3 Feb  2007 dvdwriter -> hdb
brw-r-----  1 root disk   3,   9 Feb  2007 hda9
brw-rw----  1 root disk   3,  64 Feb  2007 hdb
看dmesg
[root@localhost dev]# dmesg
hdb: ATAPI 48X DVD-ROM DVD-R CD-R/RW drive, 2048kB Cache



    写保护错误write-protected,但仍旧mount上(read-only)
[root@localhost xinetd.d]# mount -t iso9660 /dev/cdrom /mnt/c
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost xinetd.d]# mount -t iso9660 /dev/dvdwriter /mnt/c
mount: block device /dev/dvdwriter is write-protected, mounting read-only

mount: /dev/dvdwriter already mounted or /mnt/c busy
mount: according to mtab, /dev/hdb is already mounted on /mnt/c
[root@localhost xinetd.d]# ls /mnt/c
autorun   images                RELEASE-NOTES       RPM-GPG-KEY-fedora-rawhide
eula.txt  isolinux              RPM-GPG-KEY         RPM-GPG-KEY-fedora-test
GPL       README-Accessibility  RPM-GPG-KEY-fedora  TRANS.TBL


    linux 下没什么虚拟光驱的操作,直接mount iso 文件即可
[root@localhost ymp]# mount -o loop RHEL4-U4-i386-AS-disc1.iso /mnt/d/disk1
[root@localhost ymp]# ls /mnt/d/disk1
autorun            RELEASE-NOTES-bn.html     RELEASE-NOTES-U1-it.html     RELEASE-NOTES-U2-ta.html     RELEASE-NOTES-U4-en.html
EULA               RELEASE-NOTES-de.html     RELEASE-NOTES-U1-ja.html     RELEASE-NOTES-U2-zh_CN.html  RELEASE-NOTES-U4-es.html
GPL  


    mount iso 文件,必须加 -o loop参数
[root@localhost mnt]# mount /mnt/d/ymp/RHEL4-U4-i386-AS-disc1.iso /mnt/cd
mount: /mnt/d/ymp/RHEL4-U4-i386-AS-disc1.iso is not a block device (maybe try `-o loop'?)


    mount 后的iso文件和光盘一样,也是只读
[root@localhost cd]# chmod +w isolinux/isolinux.bin
chmod: changing permissions of `isolinux/isolinux.bin': Read-only file system
mount U盘
 

    USB U盘和USB硬盘的对应设备文件和scsi 设备重名                                
都是/dev/sda /dev/sdb /dev/sdc


    新redhat,插上U盘后,linux自动找到USB设备,可以通过fdisk -l查到
[root@mail home]# /sbin/fdisk -l

Disk /dev/hda: 10.0 GB, 10005037568 bytes
255 heads, 63 sectors/track, 1216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1                    13      104391   83  Linux
/dev/hda2              14        1216     9663097+  8e  Linux LVM

Disk /dev/dm-0: 9294 MB, 9294577664 bytes
255 heads, 63 sectors/track, 1130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/sda: 128 MB, 128974336 bytes
16 heads, 32 sectors/track, 491 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1                   492      125928+   FAT16
Partition 1 has different physical/logical endings:
     phys=(499, 15, 32) logical=(491, 15, 32)
虽然设备自动找到了,但mount还必须手工
把 fdisk -l 查到的U盘设备mount到目录中
[root@mail sbin]# mkdir /mnt/usb
[root@mail sbin]# mount /dev/sda1 /mnt/usb
[root@mail sbin]# ls /mnt/usb
10.wma  16.wma    5293.mp3  7406.mp3    am2-bach.wma     beethoven4.wma  do12.wma     kisin3.mp3 11.wma  17.wma    5706.mp3  7.wma       am4-bach.wma     beethoven5.wma  do15.wma     mozart570.wma kisin25.mp3


solaris 如何使用usb设备
cd /dev/dsk
ls -l 查看usb设备
mount -F pcfs /dev/dsk/设备名字  /mountpoint

跟linux不同,linux缺省类型是vfat,所以可以不设-t vfat
solaris缺省类型是ufs,所以必须显示设置-F pcfs


转载自:http://blog.sina.com.cn/s/blog_6151984a0100fp4u.html






阅读(4068) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-06 14:20:05

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com

chinaunix网友2011-03-06 14:20:05

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com