• Linux的磁盘分区(一)


    磁道:track

    扇区:sector

    磁头:head

    柱面:cylinder

    • 每个扇区,512字节

    • 每个磁道划分为63个扇区

    • 逻辑磁头(盘面)数设为255

    •   一个柱面的大小

    •   =255 * 63 * 512 = 8M

    • 硬盘或分区的容量

    • =柱面大小 * 柱面数

    [root@localhost ~]# fdisk -l ###fdisk查看磁盘列表 fdisk -l /dev/sdb 单独查看一块磁盘
    
    Disk /dev/sda: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          25      200781   83  Linux
    /dev/sda2              26         156     1052257+  82  Linux swap / Solaris
    /dev/sda3             157        5221    40684612+  83  Linux
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
    Disk /dev/sdb doesn't contain a valid partition table

     划分新的磁盘

    Command (m for help): m
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)

    常用的划分参数:n 增加新的分区 t 修改存在分区 w 保存退出 q 不保存退出 

    按照提示进行划分,分区大小直接 +xG 

    划分结束后:partprobe /dev/sdb 识别新的分区表

    [root@localhost ~]# fdisk -l /dev/sdb
    
    Disk /dev/sdb: 42.9 GB, 42949672960 bytes
    255 heads, 63 sectors/track, 5221 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        1217     9775521   83  Linux
    /dev/sdb2            1218        2434     9775552+  83  Linux
    /dev/sdb3            2435        5221    22386577+   5  Extended
    /dev/sdb5            2435        2557      987966   82  Linux swap / Solaris
    /dev/sdb6            2558        3166     4891761    b  W95 FAT32

     格式化分区

    mkfs make filesystem  mkfs -t ext3/vfat /dev/sdb1

    通过ls /sbin/mkfs* 可以查看可以格式化的文件类型

    挂载分区

    mount /dev/sdb1 /mnt/part1  

    umount /dev/sdb1  umount /mnt/part1

    格式化扩展分区

    mkswap /dev/sdb5

    启动/关闭扩展分区

    swapon /dev/sdb5 swapoff /dev/sdb5

    查看扩展分区

    swapon -s

    给分区起别名,挂在的时候可以使用mount -L/LABEL=alias /data/game

    e2label /dev/sdb1 "alias"   设置为空时 取消别名

    挂在ISO镜像文件

    mount -o loop /windows.iso /mnt

    目录挂在 隐藏真实的源路径

    mount --bind /usr/src/mp3 /media

    查看磁盘的uuid

    blkid /dev/sdb1

    开机自动挂在 /etc/fstab 推荐使用UUID进行挂在

    vim /etc/fstab

     开机自动挂在

    /etc/fstab 自动挂在的配置文件

    按需挂在  autofs服务

    /etc/auto.master  autofs的主配置文件  父目录(/data)  (对应的配置文件)/etc/auto.data

    /etc/auto.data 

      (子目录) sdb1  -fstype=ext3  :/dev/sdb1

    配置完成后 service autofs stop service autofs start

  • 相关阅读:
    CSS知识点:清除浮动
    CSS3的应用,你学会了吗?
    必须掌握的JavaScript基本知识
    一个搜索框的背后
    mybatis 中 foreach collection的三种用法
    基于Pipe的PureMVC FLEX框架的多核共享消息技术
    Flex与Java通信之HttpService
    python + eclipse + django + postgresql 开发网站(二)
    python + eclipse + django + postgresql 开发网站(一)
    [转]Python集合(set)类型的操作
  • 原文地址:https://www.cnblogs.com/yimiao/p/3841084.html
Copyright © 2020-2023  润新知