标签:parted
Parted是一个磁盘分区管理工具,它比fdisk更加灵活,功能也更丰富。
[root@WebServer ~]# parted /dev/sdb 分区
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
(parted) help #打印帮助信息
align-check TYPE N check partition N for TYPE(min|opt)
alignment
check NUMBER do a simple check on the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another
partition
help [COMMAND] print general help, or help on
COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition
table)
mkfs NUMBER FS-TYPE make a FS-TYPE file system on
(parted) mklabel gpt #要把整个磁盘转换为gpt格式才可以用parted分区
(parted) mkpart primary 0 500 #分一个主分区大小为500M,0-500是序号
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore #忽略
(parted) p #打印分区表
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 500MB 500MB primary
(parted) mkpart logical 501 1000 #分逻辑分区大小500M
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 500MB 500MB primary
2 501MB 1000MB 499MB logical
(parted) quit #分区好退出直接保存了
Information: You may need to update /etc/fstab.
[root@WebServer ~]# mkfs -t ext4 /dev/sdb #格式化
[root@WebServer ~]# mount /dev/sdb /tmp #挂载
[root@WebServer ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 886M 17G 5% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 97M 27M 66M 29% /boot
/dev/sda2 1008M 34M 924M 4% /swap
/dev/sdb 1008M 34M 924M 4% /tmp
---------------------------------------------------
[root@WebServer ~]# mkfs -t ext4 /dev/sdb1 #重新格式,提示一个错误
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux……………
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@WebServer ~]# tune2fs -c -1 /dev/sdb1 #需要用提示的命令处理一下
[root@WebServer ~]# mount /dev/sdb1 /tmp #重新挂载
[root@WebServer ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 886M 17G 5% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 97M 27M 66M 29% /boot
/dev/sda2 1008M 34M 924M 4% /swap
/dev/sdb1 462M 11M 428M 3% /tmp
本文出自 “比尔linux运维笔记” 博客,请务必保留此出处http://chenshoubiao.blog.51cto.com/6159058/1881333
标签:parted
原文地址:http://chenshoubiao.blog.51cto.com/6159058/1881333