linux创建交换分区 开机自动生肖,centos创建交换分区并自动挂载

一.先创建一个分区

[root@magedu ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x30783445.

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

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-261, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): +1G

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 82

Changed system type of partition 1 to 82 (Linux swap / Solaris)

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

好了,现在已经创建出了一个交换分区,最好重启电脑一下。如果不重启,则输入命令;

[root@magedu ~]# partprobe

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.

Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.

让内核重新读取分区表

二:

[root@magedu ~]# mkswap /dev/sdb1

Setting up swapspace version 1, size = 1060252 KiB

no label, UUID=11c8dda0-d607-4aec-81f6-43edff562ec8

获得/dev/sdb1的UUID ,

三:实现自动挂载:

[root@magedu ~]# echo " UUID=11c8dda0-d607-4aec-81f6- 43edff562ec8 swap swap defaults 0 0" >> /etc/fstab

[root@magedu ~]# swapon -a

[root@magedu ~]# swapon -s

FilenameTypeSizeUsedPriority

/dev/sda3 partition10485680-1

/dev/sdb1 partition10602480-2

好了,已经实现了自动挂载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值