设备 Boot StartEnd Blocks Id System /dev/sda1 2048838881274194304083 Linux /dev/sda2 838881281677742074194304083 Linux /dev/sda3 1677742082516602874194304083 Linux /dev/sda4 2516602883355463674194304083 Linux
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. 欢迎使用 fdisk (util-linux2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。
命令(输入 m 获取帮助):m 命令操作 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) 命令(输入 m 获取帮助):
m 显示帮助 p 显示已有分区 d 删除分区,只有1个分区时,会自动删除已有分区,不用选择 n 创建新的分区 w 保存分区 q 退出不保存
[root@chobonmnt]# parted -l Model: ATA ST500LM021-1KJ15 (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags:
Number StartEnd Size Type File system 标志 11049kB 43.0GB 42.9GB primary ext3 243.0GB 85.9GB 42.9GB primary ext3 385.9GB 129GB 42.9GB primary 4129GB 172GB 42.9GB primary
Model: ATA Crucial_CT250MX2 (scsi) Disk /dev/sdb: 250GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags:
Number StartEnd Size File system Name 标志 11049kB 211MB 210MB fat16 EFI System Partition 启动 2211MB 1285MB 1074MB xfs 31285MB 250GB 249GB lvm
Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/centos-home: 187GB Sector size (logical/physical): 512B/4096B Partition Table: loop Disk Flags:
Number StartEnd Size File system 标志 10.00B 187GB 187GB xfs
Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/centos-swap: 8389MB Sector size (logical/physical): 512B/4096B Partition Table: loop Disk Flags:
Number StartEnd Size File system 标志 10.00B 8389MB 8389MB linux-swap(v1)
Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/centos-root: 53.7GB Sector size (logical/physical): 512B/4096B Partition Table: loop Disk Flags:
Number StartEnd Size File system 标志 10.00B 53.7GB 53.7GB xfs
mkfs
该命令用来在特定的分区创建linux文件系统,常见的文件系统有ext2,ext3,vfat等
mkfs的使用示例
mkfs -t文件系统存储设备
把该设备格式化成xfs文件系统
mkfs.xfs -f /dev/sda
把该设备格式化成ext3文件系统
mkfs.ext3 /dev/sda
把该设备格式化成ext3文件系统
mke2fs -j /dev/sda
格式化成reiserfs文件系统
mkfs.reiserfs /dev/sda
格式化成fat32文件系统
mkfs.vfat /dev/sda
格式化成fat16文件系统,msdos就是fat16
mkfs.msdos /dev/sda
格式化成msdos文件系统
mkdosfs /dev/sda
mount
挂载磁盘
mount /dev/sda /data
卸载磁盘
umount /dev/sda
磁盘管理
创建分区
输入fdisk /dev/sda回车,进入硬盘分区
1 2 3 4 5 6 7 8 9 10 11 12
[root@chobonmnt]# fdisk /dev/sda
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. 欢迎使用 fdisk (util-linux2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。
命令(输入 m 获取帮助):
输入n回车新建分区,
1 2 3 4 5
命令(输入 m 获取帮助):n Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e):
设备 Boot StartEnd Blocks Id System /dev/sda1 2048838881274194304083 Linux /dev/sda2 838881281677742074194304083 Linux /dev/sda3 1677742082516602874194304083 Linux
命令(输入 m 获取帮助):
对刚建好得分区格式化
1
[root@chobonmnt]# mkfs.xfs -f /dev/sda3
删除分区
输入fdisk /dev/sda回车,进入硬盘分区
1 2 3 4 5 6 7 8 9 10 11 12
[root@chobonmnt]# fdisk /dev/sda
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. 欢迎使用 fdisk (util-linux2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。
命令(输入 m 获取帮助):
删除分区,输入d回车,选择要删除得分区序号4回车
1 2 3
命令(输入 m 获取帮助):d 分区号 (1-4,默认 4):4 分区 4 已删除
输入w保存操作
1 2 3 4 5
命令(输入 m 获取帮助):w The partition table has been altered!
Calling ioctl() to re-read partition table. 正在同步磁盘。