Linux parted命令格式化2T以上硬盘脚本
2016-06-12 10:10
525 查看
关于parted命令网上有资料,这里简单的介绍下使用。
用法:parted [选项]... [设备 [命令 [参数]...]...]
将带有“参数”的命令,则以命令模式运行。如果没有给出“命令”,则以交互模式运行。
命令模式运行:parted /dev/sda mklabel gpt
交互模式运行:parted /dev/sda
格式化脚本如下,运行./*.sh /dev/sda 挂载路径 硬盘大小(G为单位)
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
if [ $# != 3 ] ;then
echo "error opeion:"
echo "sample: ${0} /dev/sda /mnt/hdisk0 3000"
exit 0
fi
echo "DISK DEVPATH: $1"
echo "DISK MOUNTPATH: $2"
echo "DISK TOTALSIZE: $3"
csize=0
msize=0
psize=0
asize=$3
COUNTER=0
umount $2
parted $1 mklabel gpt <<STEP1
ignore
yes
STEP1
while [ $asize -gt 0 ]
do
COUNTER=`expr $COUNTER + 1`
if [ $asize -le 2000 ];then
psize=$asize
else
psize=2000
fi
msize=`expr $csize + $psize`
echo "the $COUNTER partion , ${csize}GB from ${msize}GB"
parted $1 mkpart primary ext2 ${csize}GB ${msize}GB <<EOF
ignore
EOF
asize=`expr $asize - $psize`
csize=$msize
done
关于parted命令中出现一些提示操作出现的情况:
分区挂载中硬盘:
parted /dev/sda mklabel gpt
Warning: Partition(s) on /dev/sda are being used.
Ignore/Cancel? i
i
Warning: The existing disk label on /dev/sda will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
y
Information: You may need to update /etc/fstab.
分区已分区硬盘:
[root@(none) sl_onvif]# parted /dev/sda mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? yes
用法:parted [选项]... [设备 [命令 [参数]...]...]
将带有“参数”的命令,则以命令模式运行。如果没有给出“命令”,则以交互模式运行。
命令模式运行:parted /dev/sda mklabel gpt
交互模式运行:parted /dev/sda
格式化脚本如下,运行./*.sh /dev/sda 挂载路径 硬盘大小(G为单位)
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
if [ $# != 3 ] ;then
echo "error opeion:"
echo "sample: ${0} /dev/sda /mnt/hdisk0 3000"
exit 0
fi
echo "DISK DEVPATH: $1"
echo "DISK MOUNTPATH: $2"
echo "DISK TOTALSIZE: $3"
csize=0
msize=0
psize=0
asize=$3
COUNTER=0
umount $2
parted $1 mklabel gpt <<STEP1
ignore
yes
STEP1
while [ $asize -gt 0 ]
do
COUNTER=`expr $COUNTER + 1`
if [ $asize -le 2000 ];then
psize=$asize
else
psize=2000
fi
msize=`expr $csize + $psize`
echo "the $COUNTER partion , ${csize}GB from ${msize}GB"
parted $1 mkpart primary ext2 ${csize}GB ${msize}GB <<EOF
ignore
EOF
asize=`expr $asize - $psize`
csize=$msize
done
关于parted命令中出现一些提示操作出现的情况:
分区挂载中硬盘:
parted /dev/sda mklabel gpt
Warning: Partition(s) on /dev/sda are being used.
Ignore/Cancel? i
i
Warning: The existing disk label on /dev/sda will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
y
Information: You may need to update /etc/fstab.
分区已分区硬盘:
[root@(none) sl_onvif]# parted /dev/sda mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? yes
相关文章推荐
- centos7 开机启动某些程序的方法
- Linux用extundelete恢复误删文件
- 使用谷歌身份验证器增强SSH安全
- Linux下中文文件名乱码问题的详解
- linux系统下怎么安装.deb文件?
- ssh:Network error:connection refused的排查
- linux权限管理_ACL权限
- linux iminor imajor dev_t
- linux下umask的使用讲解
- TFTP在linux上使用
- lenky的个人站点 ----LINUX 内核进程
- Linux线程-互斥锁pthread_mutex_t
- Linux字符设备驱动
- 每天一个Linux命令(45)lsof命令
- Linux中的文件类型
- LINUX命令随记
- linux file search
- 欢迎使用CSDN-markdown编辑器
- Linux服务器集群LVS
- zabbix