• ubuntu-硬盘分区、格式化、自动挂载配置


    最近公司的项目较多,我的ubuntu系统的disk空间不够用了,所以在京东上买了一个1T的希捷disk扩充容量。下面是对新disk分区、格式化、自动挂载配置的过程。

    首先我使用的是ubuntu10.04版系统。

    一、disk分区。

    1、显示disk及所属分区的情况。

    sudo  fdisk  -lu  显示如下:

    Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00079ebb

       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048  1908545535   954271744   83  Linux
    /dev/sda2      1908547582  1953523711    22488065    5  Extended
    /dev/sda5      1908547584  1953523711    22488064   82  Linux swap / Solaris

    Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors

    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disk identifier: 0x00000000

    Disk /dev/sdb doesn't contain a valid partition table

    2、对disk进行分区。

    sudo fdisk /dev/sdb  根据提示command(m for help),输入m 为打印帮组menu;输入n,执行add a new partion指令给disk增加一个新的分区;输入e,指定分区为扩展分区(extended);出现partion number(1-4),输入1表示只分一个区;输入p显示分区表;输入w,保存分区表。最后系统提示:The partition table has been altered!

    此时输入:sudo fdisk -lu   系统识别了/dev/sdb/分区。

    二、 格式化 Hard disk

    1、显示Hard disk及所属分区情况。

    输入:sudo mkfs -t ext4 /dev/sdb  (-t ext4 表示将分区格式化成ext4文件系统类型)

    格式化完成后,系统提示:

    This filesystem will be automatically checked every 28 mounts or 180 days,whichever comes first。use tune2fs -c or -i override。(为了保证文件系统的完整,每次加载28次或每隔180天就要完整地检查文件系统,可以使用命令tune2fs -c 或 tune2fs -i 来调整默认值)。

    三、挂载硬盘分区(mount hard disk partition)

    1、sudo df -l  显示挂载的硬盘分区。

    2、sudo mount -t ext4 /dev/sdb /mnt (指定硬盘分区文件系统类型为ext4,同时将/dev/sdb分区挂载到目录/mnt下。第一次我将该分区挂载到/home下,最终导致之前的用户被覆盖了,不能使用之前的用户进入系统,系统提示错误:can't update ICEauthority file /home/zrh/.IcEauthority)

    3、sudo df -l 显示新硬盘已经挂载

    zhouruheng@zhouruheng-desktop:~$ sudo df -l
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1            939297600 772270788 119313228  87% /
    none                   3833912       300   3833612   1% /dev
    none                   3838440      1196   3837244   1% /dev/shm
    none                   3838440       120   3838320   1% /var/run
    none                   3838440         0   3838440   0% /var/lock
    none                   3838440         0   3838440   0% /lib/init/rw
    /dev/sdb             961434656  76622768 835973760   9% /mnt

    4、 配置硬盘在系统启动自动挂载。

    sudo vim /etc/fstab  (添加第6行即可)

      1 proc            /proc         proc    nodev,noexec,nosuid 0       0
      2 UUID=6c1709cf-f15e-4064-bbd8-f7b67238e535 /               ext4    errors=remount-ro 0       1
      3 UUID=5e397286-e140-4dc2-aeb1-a073cdbf4422 none            swap    sw              0       0
      4 /dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0
      5
      6 UUID=03c7f6a4-a806-496b-b1a5-0f3238876b6e /mnt               ext4    defaults 0      2

    到此为止。

  • 相关阅读:
    include包含文件查找的顺序
    cookie知多少
    关于“异步可插协议”(About Asynchronous Pluggable Protocols(APPs))
    win7+vs2010下编译chrome
    chrome命令行参数
    头文件预编译
    IBindStatusCallback 状态码
    DEP相关
    调试子进程
    windbg 调试
  • 原文地址:https://www.cnblogs.com/zhou2011/p/3298139.html
Copyright © 2020-2023  润新知