Linux磁盘分区-CentOS7

1. 磁盘查看的一些命令:

lsblk

lsblk  -o name,uuid,fstype,mountpoint

df -hT

fdisk -l

 

2. 分区挂载步骤:

2.1. 分区(后面具体讲)

fdisk /dev/vdb

2.2. 对分区进行格式化

xfs格式化:

        mkfs.xfs -f -n ftype=1 /dev/vdb3

ext4格式化:

        mkfs.ext4 /dev/vdb1

2.3. 挂载

mount /dev/vdb1 /mnt/disk1

mount /dev/vdb3 /var/lib/docker

2.4. 编辑/etc/fstab,加入下面内容

vi /etc/fstab

/dev/vdb1 /mnt/disk1 ext4 defaults 0 0

/dev/vdb3 /var/lib/docker xfs defaults,uquota,pquota 0 0

2.5. 重新挂载 /etc/fstab 里面的内容

mount -a

编辑fstab后先用mount -a  看看有没有报错,目标磁盘有没有挂载,正常后才可重启系统

"UUID=xxx"  等同 “/dev/vdb3”

 

3. 对vdb磁盘进行分区

[root@test4 ~]# fdisk /dev/vdb  
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 2597.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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 //创建一个新的空白DOS分区表
    p   print the partition table    //打印分区表
    q   quit without saving changes  //退出不保存设置
    s   create a new empty Sun disklabel
    t   change a partition's system id  //改变分区的ID
    u   change display/entry units    //改变显示的单位
    v   verify the partition table    //检查验证分区表
    w   write table to disk and exit  //保存分区表
    x   extra functionality (experts only)
Command (m for help):n     
Command action
   e   extended                 //e是扩展分区
   p   primary partition (1-4)  //p是主分区
p
Partition number (1-4): 1       //定义分区号   --主分区最多只能有四个
First cylinder (1-2597, default 1): 1  //分区开始柱面
Last cylinder or +size or +sizeM or +sizeK (1-2597, default 2597): +100G   //分区结束柱面,或者分区大小

Command (m for help): w          //保存刚才的配置信息。
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: 无效的参数.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值