linux 增加swap硬

[root@webtracevm ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1958.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-1958, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1958, default 1958):
Using default value 1958

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1-1958, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1958, default 1958):
Using default value 1958

Command (m for help): p

Disk /dev/sdd: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        1958    15727603+   5  Extended
/dev/sdd5               1        1958    15727572   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@webtracevm ~]# part
parted     partprobe  partx     
[root@webtracevm ~]# partprobe
[root@webtracevm ~]# mke2fs -j /dev/sdd5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1966080 inodes, 3931893 blocks
196594 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4026531840
120 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@webtracevm ~]# mount /dev/sdd5 /usr/swap/
[root@webtracevm ~]# vi /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
/dev/vgdb/lvdb          /u01                    ext3    defaults        1 2
/dev/sdd5               /usr/swap               ext3    defaults        1 2
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/fstab" 9L, 684C written
[root@webtracevm ~]# cd /usr/swap/
[root@webtracevm swap]# dd if=/dev/zero f=swapfile bs=1024 count=14000000
14000000+0 records in
14000000+0 records out
14336000000 bytes (14 GB) copied, 86.683 seconds, 165 MB/s
[root@webtracevm swap]# ls
lost+found  swapfile
[root@webtracevm swap]# mkswap swapfile
Setting up swapspace version 1, size = 14335995 kB
[root@webtracevm swap]# swapon swapfile
[root@webtracevm swap]# ls -l
总计 14013712
drwx------ 2 root root       16384 11-26 19:34 lost+found
-rw-r--r-- 1 root root 14336000000 11-26 19:39 swapfile
[root@webtracevm swap]# top

top - 19:40:07 up 8 min,  1 user,  load average: 1.32, 1.82, 0.86
Tasks:  95 total,   1 running,  94 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.8%us,  9.7%sy,  0.0%ni, 76.9%id, 11.2%wa,  0.1%hi,  0.4%si,  0.0%st
Mem:   8175332k total,  8059356k used,   115976k free,    24328k buffers
Swap: 16048268k total,        0k used, 16048268k free,  7657360k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                   
    1 root      15   0 10348  736  612 S  0.0  0.0   0:00.60 init                      
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0               
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0               
    4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.01 migration/1               
    5 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1               
    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 events/0                  
    7 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/1                  
    8 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 khelper                   
   81 root      13  -5     0    0    0 S  0.0  0.0   0:00.00 kthread                   
   86 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kblockd/0                 
   87 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kblockd/1                 
   88 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid                    
[root@webtracevm swap]# vi /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
/dev/vgdb/lvdb          /u01                    ext3    defaults        1 2
/dev/sdd5               /usr/swap               ext3    defaults        1 2
/usr/swap/swapfile         none swap sw,pri=300

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16111659/viewspace-680372/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16111659/viewspace-680372/

你可能感兴趣的:(操作系统)