Linux_利用fdisk建立swap分区
来源:互联网 发布:seo学徒招聘 编辑:程序博客网 时间:2024/06/05 07:19
这种情况可以针对没有建立swap或者swap空间比较小。
1、对硬盘进行分区。
#fdisk
Command (m for help): p
Disk /dev/sda: 69.7 GB, 69793218560 bytes
255 heads, 63 sectors/track, 8485 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1
/dev/sda2
/dev/sda3
Partition table entries are not in disk order
Command (m for help): n
Command action
p
Selected partition 4
First cylinder (1828-8485, default 1828): 5222
Last cylinder or +size or +sizeM or +sizeK (5222-8485, default 8485): 7309
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 82
Changed system type of partition 4 to 82 (Linux swap / Solaris)
Command (m for help): p
Disk /dev/sda: 69.7 GB, 69793218560 bytes
255 heads, 63 sectors/track, 8485 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1
/dev/sda2
/dev/sda3
/dev/sda4
Partition table entries are not in disk order
Command (m for help): m
Command action
Command (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 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@ENGtest sbin]# df -k
Filesystem
/dev/sda1
/dev/sda3
/dev/sda2
tmpfs
/dev/sdb
/dev/sdc
/dev/sdd
[root@ENGtest sbin]# fdisk -l /dev/sda
Disk /dev/sda: 69.7 GB, 69793218560 bytes
255 heads, 63 sectors/track, 8485 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1
/dev/sda2
/dev/sda3
/dev/sda4
Partition table entries are not in disk order
2、建立swap分区,并且进行加载。
[root@ENGtest /]#
[root@ENGtest /]# fdisk -l /dev/sda
Disk /dev/sda: 69.7 GB, 69793218560 bytes
255 heads, 63 sectors/track, 8485 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1
/dev/sda2
/dev/sda3
/dev/sda4
Partition table entries are not in disk order
[root@ENGtest /]# ls -l
total 392
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x 100 root
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwx------
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
dr-xr-xr-x 150 root
drwxr-x---
drwxr-xr-x
-rw-r--r--
drwxr-xr-x
drwxr-xr-x