5.3.1.4 磁盘管理 : 分区管理 : 分区/删除/修改/添加/格式化操作

5.3.1.4 磁盘管理 : 分区管理 : 分区/删除/修改/添加/格式化操作

分区/删除/修改/添加/格式化操作
命令式:fdisk
gui式:cfdisk

                                             cfdisk (util-linux 2.23.2)

                                                Disk Drive: /dev/sda
                                          Size: 68719476736 bytes, 68.7 GB
                                Heads: 255   Sectors per Track: 63   Cylinders: 8354

     Name              Flags           Part Type       FS Type                 [Label]              Size (MB)
 -----------------------------------------------------------------------------------------------------------------
                                        Pri/Log        Free Space                                        1.05      
     sda1              Boot             Primary        ext4                                            524.29    
     sda2                               Primary        LVM2_member                                   68194.15    



       [   Help   ]  [   New    ]  [  Print   ]  [   Quit   ]  [  Units   ]  [  Write   ]


                                        Create new partition from free space

                                             cfdisk (util-linux 2.23.2)

                                                Disk Drive: /dev/sda
                                          Size: 68719476736 bytes, 68.7 GB
                                Heads: 255   Sectors per Track: 63   Cylinders: 8354

     Name              Flags           Part Type       FS Type                 [Label]              Size (MB)
 -----------------------------------------------------------------------------------------------------------------
                                       Pri/Log        Free Space                                        1.05      
     sda1              Boot             Primary        ext4                                            524.29      
     sda2                               Primary        LVM2_member                                   68194.15       



       [ Bootable ]  [  Delete  ]  [   Help   ]  [ Maximize ]  [  Print   ]  [   Quit   ]  [   Type   ]
       [  Units   ]  [  Write   ]

                                   Toggle bootable flag of the current partition


删除磁盘

>>fdisk /dev/db1
Command (m for help): d
No partition is defined yet!

应该为
>>fdisk /dev/db //去掉1
Command (m for help): d
No partition is defined yet!

新增磁盘步骤

  1. 查看磁盘(包括未分区)
fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0x000cd8ec

 Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    41943039    20970496   83  Linux

##未分配磁盘
Disk /dev/vdd: 32.2 GB, 32212254720 bytes, 62914560 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
  1. 磁盘分区
fdisk /dev/vdd
##查看命令
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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free) ##选择主分区
   e   extended  ##选择拓展分区
Select (default p): e
Partition number (1-4, default 1): 1
First sector (2048-62914559, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559): 62914559
Partition 1 of type Extended and of size 30 GiB is set

Command (m for help): w
The partition table has been altered!

结果
 Device Boot      Start         End      Blocks   Id  System
/dev/vdd1            2048    62914559    31456256   83  Linux

3. ##格式化分区

mkfs.ext4 /dev/sdb1

4. ##挂载

mount /dev/sdb1 /home/xx ##注意会丢失数据(可以通过解除挂载找到)

5. ##解除挂载

umount -l /mnt 强行解除挂载

注意:fdisk /dev/vdd1 是不对的!必须对磁盘进行操作 fdisk /dev/vdd


实现自动挂载

实现自动挂载
 vi /etc/fstab

添加如下内容:
<磁盘分区> <挂载目录> ext4 defaults 0 0

 /dev/vdb /mnt ext4 defaults 0 0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值