免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2244 | 回复: 8
打印 上一主题 下一主题

如何自动分区 格盘 挂载呀用shell [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-23 23:20 |只看该作者 |倒序浏览
如何自动分区 格盘 挂载呀用shell

谢谢

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
2 [报告]
发表于 2010-06-23 23:40 |只看该作者
不用shell的话,你知道如何分区、格盘、挂载吗?
如果知道,把那些命令放到一个.sh文件里面就行啦。

论坛徽章:
0
3 [报告]
发表于 2010-06-24 09:00 |只看该作者
回复 2# Shell_HAT


    你试过吗?我觉得应该要用expect吧

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
4 [报告]
发表于 2010-06-24 09:19 |只看该作者
回复 3# where27


HP-UX上试过,不知道哪里需要expect。

论坛徽章:
0
5 [报告]
发表于 2010-06-24 09:26 |只看该作者
回复 4# Shell_HAT


    呵呵,感觉linux在分区的时候,很多地方都需要交互,比如选择盘符和设置分区大小什么的,不过我没用脚本试过,有空在虚拟机上试试

论坛徽章:
16
IT运维版块每日发帖之星
日期:2015-08-24 06:20:00综合交流区版块每日发帖之星
日期:2015-10-14 06:20:00IT运维版块每日发帖之星
日期:2015-10-25 06:20:00IT运维版块每日发帖之星
日期:2015-11-06 06:20:00IT运维版块每日发帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT运维版块每日发帖之星
日期:2016-04-15 06:20:00IT运维版块每日发帖之星
日期:2016-05-21 06:20:00综合交流区版块每日发帖之星
日期:2016-08-16 06:20:002015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-08-14 06:20:00
6 [报告]
发表于 2010-06-24 10:20 |只看该作者
就把命令写到一个文件里就可以了。

需要手动输一些东西。

哥用过这个。

论坛徽章:
0
7 [报告]
发表于 2010-06-24 13:58 |只看该作者
一局把我的分全没了,努力罐水,拿分搞球,下面是fdisk的测试,注意fdisk.txt文件,转换成脚本(结合mkfs.ext3,mount)后可自动分区与挂载的

[root@test0 tmp]# fdisk -l

Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         913     7333641   83  Linux
/dev/hda2             914        1044     1052257+  82  Linux swap / Solaris

Disk /dev/hdd: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
[root@test0 tmp]# fdisk /dev/hdd < fdisk.txt

The number of cylinders for this disk is set to 4161.
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): Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): First cylinder (1-4161, default 1): Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4161, default 4161):
Command (m for help): Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): First cylinder (1986-4161, default 1986): Using default value 1986
Last cylinder or +size or +sizeM or +sizeK (1986-4161, default 4161): Using default value 4161

Command (m for help): The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@test0 tmp]# more fdisk.txt
n
p
1

+1024M
n
p
2


w
[root@test0 tmp]# fdisk -l

Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1         913     7333641   83  Linux
/dev/hda2             914        1044     1052257+  82  Linux swap / Solaris

Disk /dev/hdd: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd1               1        1985     1000408+  83  Linux
/dev/hdd2            1986        4161     1096704   83  Linux
[root@test0 tmp]#

论坛徽章:
16
IT运维版块每日发帖之星
日期:2015-08-24 06:20:00综合交流区版块每日发帖之星
日期:2015-10-14 06:20:00IT运维版块每日发帖之星
日期:2015-10-25 06:20:00IT运维版块每日发帖之星
日期:2015-11-06 06:20:00IT运维版块每日发帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT运维版块每日发帖之星
日期:2016-04-15 06:20:00IT运维版块每日发帖之星
日期:2016-05-21 06:20:00综合交流区版块每日发帖之星
日期:2016-08-16 06:20:002015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-08-14 06:20:00
8 [报告]
发表于 2010-06-24 14:00 |只看该作者

论坛徽章:
0
9 [报告]
发表于 2010-06-24 14:53 |只看该作者
看看
sfdisk  , 也许有帮助
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP