Lxn-Chan!

(~ ̄▽ ̄)→))* ̄▽ ̄*)o

基于Ubuntu操作系统使用fdisk进行大容量硬盘的初始化和挂载操作。

  1. 查看硬盘信息
    首先使用fdisk -l看一下硬盘信息。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    root@lxnchan-tester:~# fdisk -l
    Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectors
    Disk model: VMware Virtual S
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: C8BCDF0E-512A-4B85-9666-73B794FB8112

    Device Start End Sectors Size Type
    /dev/sda1 2048 4095 2048 1M BIOS boot
    /dev/sda2 4096 134215679 134211584 64G Linux filesystem


    Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
    Disk model: VMware Virtual S
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    这里面/dev/sdb就是待用的新硬盘,这里假设刚刚挂载。
  2. 输入fdisk /dev/sdb进入命令行模式。
  3. 输入m查看帮助。
  4. 输入g将硬盘转换为GPT格式。

    MBR 是 Master Boot Record 的缩写,是一种较旧的磁盘类型,于1983年首次在IBM PC DOS 2.0中引入。由于MBR年代久远,MBR只适用于最大容量为2TB的硬盘,如果是更大容量的硬盘使用MBR,那么多出来的部分将无法被识别。

  5. 输入n新建分区:
    这时会询问三个问题,分别是:“分区号”、“第一个扇区”、“最后一个扇区(或大小)”。
    分区号和第一个扇区保持默认即可;如果不把一整块盘作为一个分区的话,则第三个参数填写最后一个扇区的扇区号或填分区大小即可。

    1
    2
    3
    4
    5
    Partition number (1-128, default 1): 
    First sector (2048-10737418206, default 2048):
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10737418206, default 10737418206):

    Created a new partition 1 of type 'Linux filesystem' and of size 5 TiB.
  6. 格式化分区
    输入fdisk -l查看刚新建的分区,我这里是/dev/sdb1
    使用mkfs工具格式化分区;-t指定分区格式,这里以xfs格式为例;-U指定UUID。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    root@lxnchan-tester:~# mkfs -t xfs /dev/sdb1
    meta-data=/dev/sdb1 isize=512 agcount=5, agsize=268435455 blks
    = sectsz=512 attr=2, projid32bit=1
    = crc=1 finobt=1, sparse=1, rmapbt=0
    = reflink=1
    data = bsize=4096 blocks=1342177019, imaxpct=5
    = sunit=0 swidth=0 blks
    naming =version 2 bsize=4096 ascii-ci=0, ftype=1
    log =internal log bsize=4096 blocks=521728, version=2
    = sectsz=512 sunit=0 blks, lazy-count=1
    realtime =none extsz=4096 blocks=0, rtextents=0
  7. 挂载分区
    1. 首先新建文件夹
      1
      mkdir userdata0
    2. 挂载分区
      1
      mount /dev/sdb1 ~/userdata0
    3. 查看挂载结果
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      root@lxnchan-iscsi:~# df -h
      Filesystem Size Used Avail Use% Mounted on
      udev 3.9G 0 3.9G 0% /dev
      tmpfs 793M 1.5M 792M 1% /run
      /dev/sda2 63G 6.2G 54G 11% /
      tmpfs 3.9G 0 3.9G 0% /dev/shm
      tmpfs 5.0M 0 5.0M 0% /run/lock
      tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
      tmpfs 793M 0 793M 0% /run/user/0
      /dev/sdb1 5.0T 36G 5.0T 1% /root/userdata0

 简单说两句



联系站长 | 服务状态 | 友情链接

备案号:辽ICP备19013963号

中国互联网违法和不良信息举报中心

架构版本号:8.1.5 | 本站已全面支持IPv6

本站由又拍云提供CDN加速服务和存储服务

正在载入运行数据(1/2)请稍后...
正在载入运行数据(2/2)请稍后...

Copyright 2024 LingXuanNing, All rights reserved.