windows和linux分区脚本
来源:互联网 发布:php 类destroy 编辑:程序博客网 时间:2024/06/15 14:33
客户需求
- 对windows 7 磁盘未分区对部分,变成一块新分区挂在我的电脑上
解决方法
C:\Windows\System32\cmd.exe /C setlocal disabledelayedexpansion & >tempfile.bat echo (echo list disk)^|diskpart^|findstr "磁盘.[0-9]"^|find /c "磁盘" ^> diskAmount & >>tempfile.bat echo set /p str=^<diskAmount & >>tempfile.bat echo del /s /q diskAmount & >>tempfile.bat echo set /a diskNum=%str%-1 & >>tempfile.bat echo echo select disk %diskNum% ^>temp.f2c & >>tempfile.bat echo echo detail disk ^>^>temp.f2c & >>tempfile.bat echo diskpart /s temp.f2c^|findstr "没有卷"^|find /c "没有卷" ^> detailDisk & >>tempfile.bat echo set /p diskEmpty=^<detailDisk & >>tempfile.bat echo del /s /q detailDisk & >>tempfile.bat echo if %diskEmpty%==0 (exit) & >>tempfile.bat echo echo select disk %diskNum% ^>temp.f2c & >>tempfile.bat echo echo clean ^>^>temp.f2c & >>tempfile.bat echo echo convert gpt ^>^>temp.f2c & >>tempfile.bat echo echo create partition primary ^>^>temp.f2c & >>tempfile.bat echo echo format fs=ntfs quick ^>^>temp.f2c & >>tempfile.bat echo echo assign ^>^>temp.f2c & >>tempfile.bat echo diskpart /s temp.f2c ^>partitionResult.tmp
- 对Linux的新磁盘,添加到卷组里面,建立一个新的逻辑剧卷,mount在/data目录下
解决方法
#!/bin/bashfunction check_execution_result(){ if [[ ! -z $RETVAL ]]; then unset RETVAL fi RETVAL=$? if [[ $RETVAL -ne 0 ]]; then echo execution failed! exit $RETVAL else echo execution successfully! fi unset RETVAL}echo "- - -" >/sys/class/scsi_host/host0/scanecho "- - -" >/sys/class/scsi_host/host1/scanecho "- - -" >/sys/class/scsi_host/host2/scanONLINE_SCSI_DISK_NEWADD=$(lsblk --all | grep disk | grep -v fd | awk '{print $1}'|sed -n '$p'| sed 's/ //g')echo New Added SCSI Disk: $ONLINE_SCSI_DISK_NEWADDVG_Name=$(vgdisplay | grep 'VG Name' | awk '{print $NF}')ONLINE_SCSI_DISK_NEWADD_FILENAME="/dev/"$ONLINE_SCSI_DISK_NEWADDLVM_OPERATION_DISK_FILENAME=$ONLINE_SCSI_DISK_NEWADD_FILENAMEpvcreate $LVM_OPERATION_DISK_FILENAME >/dev/null 2>&1check_execution_resultvgextend $VG_Name $LVM_OPERATION_DISK_FILENAME >/dev/null 2>&1check_execution_resultlvcreate $VG_Name -l 100%FREE --name /dev/$VG_Name/lv_datacheck_execution_resultmkfs.ext4 /dev/$VG_Name/lv_datacheck_execution_resultif [ ! -d /data ];then mkdir /datafi check_execution_resultmount /dev/$VG_Name/lv_data /datacheck_execution_resultsed '8a /dev/mapper/'$VG_Name'-lv_data /data ext4 defaults 1 1' /etc/fstab sed -i '8a /dev/mapper/'$VG_Name'-lv_data /data ext4 defaults 1 1' /etc/fstab check_execution_resultdf -hlsblk --all
注意:
对bat脚本,win7验证成功。对sh脚本,centos和redhat验证成功。
阅读全文
0 0
- windows和linux分区脚本
- linux和windows的双系统分区
- windows 和linux混合装,分区
- windows和linux双系统调整分区大小
- Linux挂载Windows分区和共享文件
- windows和linux双系统调整分区大小
- windows和linux双系统调整分区大小
- 借Windows说明Linux分区和挂载点
- linux 和 windows 系统分区原理
- linux挂载windows分区
- Linux和Windows脚本中的延时操作
- 自动备份脚本(Windows和Linux)
- 在LINUX下挂载WINDOWS分区和听MP3的尝试
- Linux系统访问Windows分区FAT32和NTFS
- windows和linux双系统,重新分区后修复grub
- linux怎样挂载windows分区和U盘
- Linux系统下挂载Windows分区的方法和技巧
- Linux系统下挂载Windows分区的方法和技巧
- Python 练习实例18
- $(function 和 function的区别
- BaseWeb06-JSP
- sublime text3配置Python3.5开发环境
- HDOJ 1785 You Are All Excellent
- windows和linux分区脚本
- AI加速器相关论文1:《DianNao: A Small-Footprint High-Throughput Accelerator for Ubiquitous Machine-Learning》
- 【字节流,高效流】
- 二维码在线生成
- java 反射机制-学习笔记(9)
- 标签传播(阅读笔记)
- 文章标题
- 统计学附录,F分布和t分布表
- C语言基础与提高(变量的存储类型 、 指针)