Linux下磁盘分区命令fdisk的使用方法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Linux下磁盘分区命令fdisk的使用方法
fdisk是linux下一个很实用的分区命令:
查看所有磁盘分区情况
[root@erpdevdb /]# fdisk -l
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
Disk /dev/sdb: 1198.8 GB, 1198899855360 bytes
255 heads, 63 sectors/track, 145757 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 37349 300005811 83 Linux
从以上输出我们可以看到,目前磁盘是/dev/sda和/dev/sdb两块,当然这里看到的不是物理盘数,一般是做过raid后重新划分好的。其中/dev/sda已经有了1到6共6个分区,而/dev/sdb只有一个分区。还可以看到起始位置、块数、分区类型等信息。
下面我们填加一个新的LVM分区:
[root@erpdevdb /]# fdisk /dev/sda
The number of cylinders for this disk is set to 127482.
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)
Command (m for help): p
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
Command (m for help): n
First cylinder (20401-127482, default 20401):
Using default value 20401
Last cylinder or +size or +sizeM or +sizeK (20401-127482, default 127482): +102400M
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 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@erpdevdb /]# fdisk -l
Disk /dev/sda: 1048.5 GB, 1048576000000 bytes
255 heads, 63 sectors/track, 127482 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 2676 20972857+ 8e Linux LVM
/dev/sda3 2677 5287 20972857+ 8e Linux LVM
/dev/sda4 5288 127482 981531337+ 5 Extended
/dev/sda5 5288 7898 20972826 8e Linux LVM
/dev/sda6 7899 20400 100422283+ 8e Linux LVM
/dev/sda7 20401 32850 100004593+ 83 Linux