Add new swap partitions to Linux

Source: Internet
Author: User
Tags hex code

Test scenario: VMware 11

Test system: Red Hat Enterprise Linux 7

We all know that the swap partitions in the Linux system are in separate partitions, so we're going to create a new swap partition:

[Email protected] ~]# fdisk/dev/SDA Welcome to use FDISK (Util-linux2.23.2). The changes will remain in memory until you decide to write the changes to disk. Think twice before you use the Write command. Command (enter M for help): N #创建新分区Partition type:p Primary (2Primary0Extended2  Free) e extendedselect (default p): P #创建一个主分区分区号 (3,4Default3):3#指定分区号起始 Sector (62914560-83886079, the default is62914560): #指定起始扇区将使用默认值62914560Last sector,+ Sector or +size{k,m,g} (62914560-83886079, the default is83886079): +1G #指定空间大小为1G分区3Set to Linux type, size set to1GiB #分区成功
1 command (enter M for help): T #调整分区类型2Partition code (1-3Default3): #指定要调整的分区号3 Hex Code (input l list all code): L #显示所有可用类型4 5  0Empty -NEC DOSBayiMinix/old Linu Bf Solaris6  1FAT12 -Hidden NTFS Win theLinux Interchange/So C1 drdos/sec (fat-7  2Xenix Root thePlan9           theLinux C4 drdos/sec (fat-8  3Xenix usr 3c PartitionMagic -os/2Hidden c:c6 drdos/sec (fat-9  4FAT16 <32m +Venix80286      -Linux Extensions C7 SyrinxTen  5Extended APPC PReP Boot theNTFS Volume set da non-file system data One  6FAT16 theSfs theNTFS Volume Set DB cp/m/CTOS/ . A  7Hpfs/ntfs/exfat 4d qnx4.x theLinux Plain text de Dell tools -  8AIX 4e qnx4.x Part 2nd 8e Linux LVMDFBootit -  9AIX Bootable 4f qnx4.x part 3rd theAmoeba E1 DOS Access theA os/2Startup Manager -Ontrack DM94Amoeba BBT E3 DOS r/O -b W95 FAT32WuyiOntrack DM6 Aux 9f bsd/OS e4 speedstor -C W95 FAT32 (LBA) thecp/M A0 IBM Thinkpad Hugh EB BeOS FS -E W95 FAT16 (LBA) -Ontrack DM6 Aux a5 FreeBSD ee GPT +F W95 Extension (LBA) WuOnTrackDM6 a6 OpenBSD ef EFI (fat- A/ -/ - TenOPUS -ez-drive A7 NeXTSTEP F0 linux/pa-RISC +  OneThe Hidden FAT12 AboutGolden Bow A8 Darwin UFS F1 SpeedStor A  ACompaq Diagnostics 5c Priam edisk A9 NetBSD f4 SpeedStor at  -Hidden FAT16 <3  ASpeedStor ab Darwin start F2 DOS minor -  -The Hidden FAT16 theGNU HURD or Sys af hfs/hfs+FB VMware VMFS -  -The Hidden hpfs/ntf -Novell Netware B7 BSDI FS FC VMware Vmkcore -  -AST Smart Sleep $Novell Netware b8 BSDI swap fd Linux RAID Auto -1b Hidden W95 FAT3 -disksecure Multiple start bb Boot Wizard hidden fe lanstep -1c HIDDEN W95 FAT3 thepc/IX be Solaris startup ff BBT in1e Hidden W95 FAT1 theOld Minix -Hex code (input L lists all code): the#指定类型
31 changed the type of Partition "Linux" to "Linux Swap/solaris"
command (enter M for help): P #查看并确认分区情况磁盘/DEV/SDA:42.9GB,42949672960Bytes83886080a Sector units= Sector of1* += +bytes Sector size (logical/physical): +bytes +byte i/o Size (min/Best): +bytes +byte disk label type: DOS disk identifier:0X000B85BBdevice Boot Start End Blocks Id System/DEV/SDA1 *2048     1026047      512000    theLinux/dev/sda21026048    62914559    309442568e Linux LVM/dev/sda362914560    65011711     1048576    theLinux Swap/Solaris Command (enter M for help):W#保存修改并退出The partition table has been altered!calling IOCTL () to re-read partition table. Warning:re-reading the partition table failed with error -: The device or resource is busy. The kernel still uses the old table. The new table is being used atthe next reboot or after you run Partprobe (8) or Kpartx (8) is synchronizing the disk. 
[Email protected] ~]# partprobe     #内核重读分区表
1[Email protected] ~]# Free-h #修改前的swap大小2Total used Freeshared buffers Cached3mem:990m 345M 645M7.0M       1.6M99M4-/+ buffers/cache:244m 745M5Swap:2.0G 0B2. 0G6 7 8[Email protected] ~]# swapon/dev/Sda3 #启用新建的swap分区9[Email protected] ~]# Free-h #查看当前swap分区TenTotal used Freeshared buffers Cached Onemem:990m 346M 644M7.0M       1.6M99M A-/+ buffers/cache:245m 744M -Swap:3.0G 0B3. 0G -[Email protected] ~]#

Add a new swap partition to Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.