非互動式新增分割槽
方法一
新增/deb/sdb 下的分割槽,其實位置為1到1000m,第二個分割槽位置為1001至3000m,位置千萬不能指定錯誤
parted /dev/sdb mkpart primary 11000m
parted /dev/sdb mkpart primary 1001 3000m
方法二
(1)將你要在parted命令列輸入的命令實現寫入乙個文字檔案,比如叫做part.txt
(2)然後part.txt的內容類似於這樣
[root@local ~]# cat part.txtmkpart
part4
ext4
3073
4096
q
(3)然後用類似如下命令實現自動分割槽:
parted /dev/sdb < part.txt
首先來檢視/dev/sdb現有分割槽情況
[root@local ~]# fdisk -l /dev/sdbwarning: fdisk gpt support is currently new, and therefore in an experimental phase. use at your own discretion.
disk /dev/sdb: 5368 mb, 5368709120 bytes, 10485760 sectors
units = sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disk label type: gpt
# start end size type name
1 2048 2000895 976m microsoft basic part1
2 2001953 4000000 975.6m microsoft basic part2
接下來執行命令:
parted /dev/sdb < part.txt
[root@local ~]# parted /dev/sdb < part.txtgnu parted 3.1
using /dev/sdb
welcome to gnu parted! type 'help' to view a list of commands.
(parted) mkpart
partition name? ? part4
file system type? [ext2]? ext4
start? 3073
end? 4096
(parted) q
information: you may need to update /etc/fstab.
再來檢視分割槽情況
[root@local ~]# fdisk -l /dev/sdbwarning: fdisk gpt support is currently new, and therefore in an experimental phase. use at your own discretion.
disk /dev/sdb: 5368 mb, 5368709120 bytes, 10485760 sectors
units = sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disk label type: gpt
# start end size type name
1 2048 2000895 976m microsoft basic part1
2 2001953 4000000 975.6m microsoft basic part2
3 6002688 7999487 975m microsoft basic part4
方法三
類似方法二,不過使用gdisk命令
(1)寫乙個文字檔案gdisk.txt
(2)編輯分割槽用到的檔案
[root@local ~]# cat gdisk.txtn ##空行,但必須有
##空行,但必須有
+1g ##空行,但必須有
wy
(3)然後用類似如下命令實現自動分割槽:
gdisk /dev/sdb < gdisk.txt
首先來檢視/dev/sdc現有分割槽情況
[root@local ~]# gdisk -l /dev/sdcgpt fdisk (gdisk) version 0.8.6
partition table scan:
mbr: protective
bsd: not present
apm: not present
gpt: present
found valid gpt with protective mbr; using gpt.
disk /dev/sdc: 10485760 sectors, 5.0 gib
logical sector size: 512 bytes
disk identifier (guid): f227ec43-cb17-4248-9b1a-13a35cef8e92
partition table holds up to 128 entries
first usable sector is 34, last usable sector is 10485726
partitions will be aligned on 2048-sector boundaries
total free space is 6291389 sectors (3.0 gib)
number start (sector) end (sector) size code name
1 2048 4196351 2.0 gib 8300 linux filesystem
下來執行命令:
gdisk /dev/sdb < gdisk.txt
[root@local ~]# gdisk /dev/sdb < gdisk.txtgpt fdisk (gdisk) version 0.8.6
partition table scan:
mbr: protective
bsd: not present
apm: not present
gpt: present
found valid gpt with protective mbr; using gpt.
command (? for help): partition number (4-128, default 4):
first sector (34-10485726, default = 7999488) or size: last sector (7999488-10485726,
default = 10485726) or size: current type is 'linux filesystem'
hex code or guid (l to show codes, enter = 8300): changed type of partition to 'linux filesystem'
command (? for help):
final checks complete. about to write gpt data. this will overwrite existing
partitions!!
do you want to proceed? (y/n): ok; writing new guid partition table (gpt) to /dev/sdb.
the operation has completed successfully.
再來檢視分割槽情況
[root@local ~]# gdisk -l /dev/sdbgpt fdisk (gdisk) version 0.8.6
[……]
total free space is 2394845 sectors (1.1 gib)
number start (sector) end (sector) size code name
1 2048 2000895 976.0 mib 0700 part1
2 2001953 4000000 975.6 mib 0700 part2
3 6002688 7999487 975.0 mib 0700 part4
4 7999488 10096639 1024.0 mib 8300 linux filesystem
可以看到已經新增成功
fdisk也可以通過這種方法實現非互動是分割槽
互動式 非互動式,登入式 非登入式Shell
互動式shell和非互動式shell 互動式模式 在終端上執行,shell等待你的輸入,並且立即執行你提交的命令。這種模式被稱作互動式是因為shell與使用者進行互動。這種模式也是大多數使用者非常熟悉的 登入 執行一些命令 退出。當你退出後,shell也終止了。非互動式模式 以shell scrip...
互動式 vs 非互動式 登入式 vs 非登入式
方式 區別區分方法 互動式與使用者互動 echo 返回值有i 非互動式 與script互動 echo 返回值沒有i 方式 登入區別 退出區別 區分方法 登入式需要username pwd logout exit echo 0 返回是 bash 非登入式 無需要username pwd exit ec...
git互動式新增
互動式新增提供友好的介面去操作 git 索引 index 同時亦提供了視覺化索引的能力。只需簡單鍵入git add i,即可使用此功能。git 會列出所有修改過的檔案及它們的狀態。git add i staged unstaged path 1 unchanged 4 0 assets styles...