脚本create_swap.sh

编写脚本  creat_swap.sh 要求:

**执行脚本后系统会自动建立新swap

**这个自动建立的swap分区需要开机自动激活


[root@localhost ~]# vim /bin/create_swap.sh

 

 

[root@localhost ~]# chmod +x /bin/create_swap.sh     ###加可执行权限

测试:

[root@localhost ~]# create_swap.sh /dev/vdb  p +100M

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

 

Command (m for help): Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): Partition 1 of type Linux and of size 100 MiB is set

 

Command (m for help): Selected partition 1

Hex code (type L to list all codes): Changed type of partition 'Linux' to 'Linux swap / Solaris'

 

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

 

Calling ioctl() to re-read partition table.

Syncing disks.


 

#include "lib_prot_pd.h" #include "mod_input_output.h" #include "mod_display.h" #include "mod_queue.h" #include "app_typec_deal.h" #include "app_init.h" #include "lib_multi_protocol.h" uint8_t typeca_ufp= 0; void typeca_hard_reset_cb(void) { static uint8_t b_typec_hard_reset_lock= RESET; if(h_pd.output.b_source_read_hard|| \ h_pd.output.b_sink_read_hard) { if(b_typec_hard_reset_lock== RESET) { b_typec_hard_reset_lock= SET; mod_queue_send(PLUG_CA_RST_P); } }else { if(b_typec_hard_reset_lock) { b_typec_hard_reset_lock= RESET; mod_queue_send(PLUG_CA_RST_N); } } } void typecb_hard_reset_cb(void) { static uint8_t b_typec_hard_reset_lock= RESET; if(h_pd.output.b_source_read_hard|| \ h_pd.output.b_sink_read_hard) { if(b_typec_hard_reset_lock== RESET) { b_typec_hard_reset_lock= SET; mod_queue_send(PLUG_CB_RST_P); } }else { if(b_typec_hard_reset_lock) { b_typec_hard_reset_lock= RESET; mod_queue_send(PLUG_CB_RST_N); } } } void typeca_pr_swap_cb(void) { static uint8_t b_pd_power_role_swap_lock; if(h_pd.output.b_pr_swap_en) { if(h_pd.output.b_source_read_pr_swap) { b_pd_power_role_swap_lock= SET; /*用户代码*/ //关 VBus }else if(h_pd.output.b_sink_read_pr_swap) { /*用户代码*/ //DC-DC 进入放电状态,升压,打开 VBus } }else { b_pd_power_role_swap_lock= RESET; } } void typecb_pr_swap_cb(void) { static uint8_t b_pd_power_role_swap_lock; if(h_pd.output.b_pr_swap_en) { if(h_pd.output.b_source_read_pr_swap) { b_pd_power_role_swap_lock= SET; /*用户代码*/ //关 VBus }else if(h_pd.output.b_sink_read_pr_swap) { /*用户代码*/ //DC-DC 进入放电状态,升压,打开 VBus } }else { b_pd_power_role_swap_lock= RESET; } } bool typeca_vbus_exist_cb(void) { //判断一下0.8V VBus电压 return mod_io_typeca_acin(); } bool typecb_vbus_exist_cb(void) { //判断一下0.8V VBus电压 return mod_io_typecb_acin(); } void typeca_attached_src_cb(void) { /** * !!! * 兼容性测试需要 */ mod_io_a1d_out(); mod_queue_send(PLUG_CAD_IN); } void typecb_attached_src_cb(void) { mod_io_a1d_out(); mod_queue_send(PLUG_CBD_IN); } void typeca_attached_snk_cb(void) { mod_queue_send(PLUG_CAC_IN); typeca_ufp = 1; } void typecb_attached_snk_cb(void) { mod_queue_send(PLUG_CBC_IN); typeca_ufp = 1; } void typeca_unattached_cb(void) { mod_queue_send(PLUG_CAX_OUT); typeca_ufp = 0; } void typecb_unattached_cb(void) { mod_queue_send(PLUG_CBX_OUT); }
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值