非交互式添加分区,swap分区添加

作者:计算机知识

 

非交互式增多分区,交互式加多分区

 

非交互式添加分区,swap分区添加。非交互式增加分区

方法一

增添/deb/sdb 下的分区,其实地点为一到一千M,第一个分区地方为十0一至三千M,地点千万不能够钦定错误

parted /dev/sdb mkpart primary 1 1000M
parted /dev/sdb     mkpart     primary 1001    3000M

 

方法二

(一)将您要在parted命令行输入的授命达成写入2个文本文件,举例叫做part.txt

(2)然后part.txt的从头到尾的经过周边于那般

    [[email protected] ~]# cat part.txt
    mkpart    
    part4    
    ext4        
    3073    
    4096    
    q      

(三)然后用接近如下命令完毕自动分区:

  parted /dev/sdb < part.txt

第一来查阅/dev/sdb现成分区情状

[[email protected] ~]# fdisk -l /dev/sdb
WARNING: 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

[[email protected] ~]# parted /dev/sdb < part.txt
GNU 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. 

再来查看分区景况

[[email protected] ~]# fdisk -l /dev/sdb
WARNING: 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

  

 

方法三

恍如措施2,然而使用gdisk命令

(一)写二个文书文件gdisk.txt

(二)编辑分区用到的文书

[[email protected] ~]# cat gdisk.txt
n
    ##空行,但必须有
    ##空行,但必须有
 1G
    ##空行,但必须有
w
y 

(叁)然后用接近如下命令完成自动分区:

gdisk /dev/sdb < gdisk.txt

第二来查阅/dev/sdc现存分区景况

[[email protected] ~]# gdisk -l /dev/sdc
GPT 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

[[email protected] ~]# gdisk /dev/sdb < gdisk.txt
GPT 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{KMGTP}: Last sector (7999488-10485726,
 default = 10485726) or { -}size{KMGTP}: 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. 

再来查看分区意况

[[email protected] ~]# gdisk -l /dev/sdb
GPT 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也足以由此这种方法达成非交互是分区

 

非交互式增添分区 方法一 增多/deb/sdb 下的分区,其实地方为1到一千M,第二个分区地方为拾01至2000M,位...

先是你需求选拔命令:dd 来成立2个swapfile,然后您供给运用mkswap命令在设备可能文件中开创1个Linux swap分区
a) 使用root用户登录
b) 使用上边包车型客车吩咐成立三个2G的 Swap 文件 (10二肆 * 2048MB = 2097152 block size):
# dd if=/dev/zero of=/data11/swapfile1 bs=1024 count=2097152
c) 成立二个Linux swap area:
# mkswap /data11/swapfile1
d) 登时激活 /swapfile壹 swap space :
# swapon /data11/swapfile1
e) 假如想要在Linux系统重启后,自动激活并启用/swapfile1,就须求编写制定文件:/etc/fstab,如下:
# vi /etc/fstab
累加底下一行命令:
/data11/swapfile1 swap swap defaults 0 0
依据上述手续操作完毕后,Linux系统下一次重启后,将会自动启用swap file
g) How do I verify swap is activated or not?
Simply use free command:
$ free -m
壹经想关闭虚拟内部存款和储蓄器大概想扩大, 要先disable
swapoff /data11/swapfile1

非交互式增多分区

方法一

增多/deb/sdb 下的分区,其实地点为一到一千M,第四个分区地方为十0一至3000M,地点千万无法钦点错误

parted /dev/sdb mkpart primary 1 1000M
parted /dev/sdb     mkpart     primary 1001    3000M

 

方法二

(一)将您要在parted命令行输入的一声令下跌成写入二个文本文件,举个例子叫做part.txt

(二)然后part.txt的开始和结果左近于这样

    [root@local ~]# cat part.txt
    mkpart    
    part4    
    ext4        
    3073    
    4096    
    q      

(三)然后用临近如下命令实现活动分区:

  parted /dev/sdb < part.txt

本文由bwin必赢发布,转载请注明来源

关键词: linux