1. 程式人生 > >實現swap分割槽

實現swap分割槽

實驗:實現swap分割槽

swap 相當於虛擬記憶體,交換分割槽
本實驗為增加swap分割槽大小

#新建一個分割槽
[[email protected] ~]#fdisk /dev/sdb                新增硬碟sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command '
u'). Command (m for help): n #新建分割槽 Command action e extended p primary partition (1-4) p #e為邏輯分割槽,p為主分割槽 Partition number (1-4): 2 #設定分割槽編號 First cylinder (6529-26108, default 6529): #回車 Using default value 6529 Last cylinder, +cylinders or +size{
K,M,G} (6529-26108, default 26108): +4G #分割槽大小為4G Command (m for help): p Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7972ac2c Device Boot Start End Blocks Id System /dev/sdb1 1 6528 52436128+ 83 Linux /dev/sdb2 6529 7051 4200997+ 83 Linux Command (
m for help): t #修改分割槽資訊 Partition number (1-4): 2 Hex code (type L to list codes): 82 #改為swap分割槽 Changed system type of partition 2 to 82 (Linux swap / Solaris) Command (m for help): p Disk /dev/sdb: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7972ac2c Device Boot Start End Blocks Id System /dev/sdb1 1 6528 52436128+ 83 Linux /dev/sdb2 6529 7051 4200997+ 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: Device or resource busy. 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. 分割槽已建立好 swapon /dev/sdb2 vim /etc/fstab #在其中寫入以下資訊 UUID=f2350b40-9169-4ef7-a4d7-c389217e192f swap swap pri=10 0 0 # 其中pri=10為取代原來的swap的優先順序,原swap優先順序為-1 swapoff #禁用swap swapon -a #啟用swap cat /proc/swaps swapon -s free -h #可以看到swap 又原來的2G變為了6G