Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5204211
  • 博文数量: 553
  • 博客积分: 13864
  • 博客等级: 上将
  • 技术积分: 11041
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-28 21:25
个人简介

个人Blog: hhktony.com

文章分类

全部博文(553)

文章存档

2015年(1)

2014年(2)

2013年(12)

2012年(384)

2011年(154)

分类: LINUX

2011-12-02 10:12:54

有些笔记本在进行S4休眠的时候,需要SWAP分区的支持,否则是没办法进入S4的。可是,装系统的时候没想到这个问题,那么装完系统之后要怎么手动再分出来swap分区呢?尝试了一下,步骤如下,大家可以试试。
前提是你硬盘还有空间,swap分区大小要大于或者等于内存大小为宜。(关于swap分区大小的设定,请查阅相关资料,这里举例说明,就随便设置了4G的。并不是说swap分区越大越好的~)
 下面蓝色字体部分为我们要执行的命令。
[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 38913.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p(列出当前硬盘上面的分区情况)

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xfeda9a73

Device Boot Start End Blocks Id System
/dev/sda1 2613 3052 3534300 82 Linux swap / Solaris
/dev/sda2 * 1 2612 20980858+ 83 Linux
/dev/sda3 3053 4327 10241437+ 83 Linux
/dev/sda4 4328 38913 277812045 5 Extended
/dev/sda5 4328 5602 10241406 83 Linux
/dev/sda6 5603 7514 15358108+ 83 Linux

Partition table entries are not in disk order

Command (m for help): n(创建一个新的分区)
First cylinder (7515-38913, default 7515): (此处直接回车即可)
Using default value 7515
Last cylinder, +cylinders or +size{K,M,G} (7515-38913, default 38913): +4000M(设定SWAP分区的大小,视自己的情况而定~)

Command (m for help): p

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xfeda9a73

Device Boot Start End Blocks Id System
/dev/sda1 2613 3052 3534300 82 Linux swap / Solaris
/dev/sda2 * 1 2612 20980858+ 83 Linux
/dev/sda3 3053 4327 10241437+ 83 Linux
/dev/sda4 4328 38913 277812045 5 Extended
/dev/sda5 4328 5602 10241406 83 Linux
/dev/sda6 5603 7514 15358108+ 83 Linux
/dev/sda7 7515 8025 4104576 83 Linux

Partition table entries are not in disk order

Command (m for help): t(为新建的分区写入system id)
Partition number (1-7): 7 (选择分区号,我们想要写的就是我们刚才建的sda7,所以选择7。)

Hex code (type L to list codes): L(列出所有的可以设置的选项)

Hex code (type L to list codes): 82 (因为我们要设置成swap分区,所以,选择swap分区对应的ID号"82"。)
Changed system type of partition 7 to 82 (Linux swap / Solaris)

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: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]#reboot (为了让我们刚才添加分区的操作生效,需要重启一下系统)
[root@localhost ~]# fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xfeda9a73

Device Boot Start End Blocks Id System
/dev/sda1 2613 3052 3534300 82 Linux swap / Solaris
/dev/sda2 * 1 2612 20980858+ 83 Linux
/dev/sda3 3053 4327 10241437+ 83 Linux
/dev/sda4 4328 38913 277812045 5 Extended
/dev/sda5 4328 5602 10241406 83 Linux
/dev/sda6 5603 7514 15358108+ 83 Linux
/dev/sda7 7515 8025 4104576 82 Linux swap / Solaris

Partition table entries are not in disk order

[root@localhost ~]# mkswap /dev/sda7 (将刚才建立的sda7格式化成swap分区格式)
Setting up swapspace version 1, size = 4104572 KiB
no label, UUID=1ca56ded-0d5f-4d84-aca8-cb809f9affdc

[root@localhost ~]# swapon -a (让刚才的格式化动作生效。)


[root@localhost ~]# cat /etc/fstab (我们现在就可以去查看一下分区表喽,看看我们的设置成功了没~)

阅读(3109) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~