Linux - 磁盘分区

34 篇文章 0 订阅

查看磁盘

前几天买的服务器,突然发现买的60G数据盘没有。

先用fdisk -l(记得用root 或者 sudo) 查看下所有磁盘。

root@VM-154-45-ubuntu:/media# fdisk -l

Disk /dev/vda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 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: 0x000e8237

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    16775167     8386560   83  Linux

Disk /dev/vdb: 64.4 GB, 64424509440 bytes
16 heads, 63 sectors/track, 124830 cylinders, total 125829120 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: 0x00000000

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

Disk /dev/vdc: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders, total 4194304 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: 0x00000000

我们发现这句话:Disk /dev/vdb doesn't contain a valid partition table

说明/dev/vdb这个磁盘没有格式化。

格式化磁盘

先输入命令:fdisk /dev/vdb

root@VM-154-45-ubuntu:/media# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xe09449b2.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m // 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
   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 // 这里用n 创建新分区
Partition type: 
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p //主分区
Partition number (1-4, default 1): //不填 默认
Using default value 1
First sector (2048-125829119, default 2048): //不填 默认
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-125829119, default 125829119): +40G //这里填写空间大小 用+号可以直接写要多大空间,不填就默认所有空间都用上。

然后

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

Calling ioctl() to re-read partition table.
Syncing disks.

格式化磁盘

现在磁盘分区结束之后,格式化磁盘就好了。

mkfs.ext3 /dev/vdb1 //后面这个是刚分区的。不知道可以fdisk -l查看

这样就可以了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值