使用parted进行

1. 停用swap

alexis@Smilodon:~$ sudo swapoff /dev/sda8
alexis@Smilodon:~$ free
             total       used       free     shared    buffers     cached
Mem:       4121288    2880356    1240932          0     412184     801568
-/+ buffers/cache:    1666604    2454684
Swap:            0          0          0

2. 删除sda8

alexis@Smilodon:~$ sudo parted /dev/sda rm 8
Information: You may need to update /etc/fstab.  

3. 创建新的swap

alexis@Smilodon:~$ sudo parted /dev/sda mkpart logical linux-swap 319.8G 320G
Information: You may need to update /etc/fstab.

4. 启用swap

alexis@Smilodon:~$ sudo swapon /dev/sda8
alexis@Smilodon:~$ free
             total       used       free     shared    buffers     cached
Mem:       4121288    2896220    1225068          0     412492     801732
-/+ buffers/cache:    1681996    2439292
Swap:       266236          0     266236

5. 修改/etc/fstab

获取swap的uuid并修改fstab文件里的swap的uuid

alexis@Smilodon:~$ sudo blkid
/dev/loop0: UUID="8569e038-5c7f-4a6c-995c-9d17fb6159f8" TYPE="ext4" 
/dev/sda1: LABEL="System Reserved" UUID="E8A0B48FA0B465AA" TYPE="ntfs" 
/dev/sda2: LABEL="System" UUID="4C3CC8203CC806C4" TYPE="ntfs" 
/dev/sda3: LABEL="Software" UUID="728862218861E457" TYPE="ntfs" 
/dev/sda5: LABEL="Work" UUID="8C9499F69499E2CE" TYPE="ntfs" 
/dev/sda6: LABEL="Entertainment" UUID="EE00B65A00B62A0B" TYPE="ntfs" 
/dev/sda7: LABEL="Sabretooth" UUID="8cdba6ad-fe73-4f87-8026-c5c8336b97df" TYPE="ext4" 
/dev/sda8: UUID="935637ec-2f43-4dd9-b7df-3a38dcb040fe" TYPE="swap"
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda7 during installation
UUID=8cdba6ad-fe73-4f87-8026-c5c8336b97df /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda8 during installation
UUID=935637ec-2f43-4dd9-b7df-3a38dcb040fe none            swap    sw 

 

如果仅仅是增大swap,也可以用下列方法进行

dd if=/dev/zero of=/home/alexis/swapdev bs=1M count=128 #生成大文件

mkswap /home/alexis/swapdev  #格式化成swap

swapon /home/alexis/swapdev  #启动swap

 

posted on 2013-01-20 16:20  ZimZz  阅读(2085)  评论(0编辑  收藏  举报