当前位置:   article > 正文

linux添加硬盘分区挂载教程

invalid fragment size

基本步骤:分区——格式化——挂载——写入文件

1、首先用fdisk -l命令查看添加的硬盘名称,可以看到sdb为新增的硬盘

  1. [root@oracle ~]# fdisk -l
  2. Disk /dev/sdb: 21.5 GB, 21474836480 bytes
  3. 255 heads, 63 sectors/track, 2610 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x00000000
  8. Disk /dev/sda: 21.5 GB, 21474836480 bytes
  9. 255 heads, 63 sectors/track, 2610 cylinders
  10. Units = cylinders of 16065 * 512 = 8225280 bytes
  11. Sector size (logical/physical): 512 bytes / 512 bytes
  12. I/O size (minimum/optimal): 512 bytes / 512 bytes
  13. Disk identifier: 0x0006b59c
  14. Device Boot Start End Blocks Id System
  15. /dev/sda1 * 1 39 307200 83 Linux
  16. Partition 1 does not end on cylinder boundary.
  17. /dev/sda2 39 2358 18631680 83 Linux
  18. /dev/sda3 2358 2611 2031616 82 Linux swap / Solaris

 2、进行分区,输入m查看提示

  1. [root@oracle ~]# fdisk /dev/sdb
  2. Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
  3. Building a new DOS disklabel with disk identifier 0x09f38795.
  4. Changes will remain in memory only, until you decide to write them.
  5. After that, of course, the previous content won't be recoverable.
  6. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
  7. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
  8. switch off the mode (command 'c') and change display units to
  9. sectors (command 'u').
  10. Command (m for help): m
  11. Command action
  12. a toggle a bootable flag
  13. b edit bsd disklabel
  14. c toggle the dos compatibility flag
  15. d delete a partition
  16. l list known partition types
  17. m print this menu
  18. n add a new partition
  19. o create a new empty DOS partition table
  20. p print the partition table
  21. q quit without saving changes
  22. s create a new empty Sun disklabel
  23. t change a partition's system id
  24. u change display/entry units
  25. v verify the partition table
  26. w write table to disk and exit
  27. x extra functionality (experts only)

 分析:主要参数的解析

  1. 输入 m 显示所有命令列示。

  2. 输入 p 显示硬盘分割情形,打印分区表。

  3. 输入 a 设定硬盘启动区。

  4. 输入 n 创建新的硬盘分割区。

    4.1. 输入 e 硬盘为[延伸]分割区(extend)。

    4.2. 输入 p 硬盘为[主要]分割区(primary)。

  5. 输入 t 改变硬盘分割区属性。          

       t:分区系统id号
         L:82:linux swap
         83:linux
        86:NTFS window分区

  6. 输入 d 删除硬盘分割区属性。

  7. 输入 q 结束不存入硬盘分割区属性。

  8. 输入 w 结束并写入硬盘分割区属性

 3、输入n创建新的硬盘分区——输入p创建主分区——输入1设置一个分区——回车——回车(默认全部空间)

  1. Command (m for help): n
  2. Command action
  3. e extended ···扩展分区
  4. p primary partition (1-4) ···主分区
  5. p
  6. Partition number (1-4): 1
  7. First cylinder (1-2610, default 1):
  8. Using default value 1
  9. Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
  10. Using default value 2610

 4、输入p查看分区情况——输入w保存退出(一定要w保存不然无效)

  1. Command (m for help): p
  2. Disk /dev/sdb: 21.5 GB, 21474836480 bytes
  3. 255 heads, 63 sectors/track, 2610 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x09f38795
  8. Device Boot Start End Blocks Id System
  9. /dev/sdb1 1 2610 20964793+ 83 Linux
  10. Command (m for help): w
  11. The partition table has been altered!
  12. Calling ioctl() to re-read partition table.
  13. Syncing disks.

 5、mkfs命令格式化磁盘

  1. [root@oracle ~]# mkfs.ext4 /dev/sdb1
  2. mkfs.ext4: invalid fragment size - /dev/sdb1

 6、mount命令挂载分区

  1. [root@oracle ~]# mount /dev/sdb1 /oracle/
  2. You have new mail in /var/spool/mail/root
  3. [root@oracle ~]# df -TH
  4. Filesystem Type Size Used Avail Use% Mounted on
  5. /dev/sda2 ext4 19G 11G 7.3G 60% /
  6. tmpfs tmpfs 2.1G 74k 2.1G 1% /dev/shm
  7. /dev/sda1 ext4 297M 29M 253M 11% /boot
  8. /dev/sdb1 ext4 22G 47M 20G 1% /oracle

 7、添加到/etc/fstab文件下保存退出否则重启后硬盘消失

/dev/sdb1        /oracle          ext4   defaults,noatime        0 0

 

转载于:https://www.cnblogs.com/Dev0ps/p/8807939.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/660684
推荐阅读
相关标签
  

闽ICP备14008679号