建立一個普通的linux分區(主分區、邏輯分區均可)
fdisk /dev/sdb
command (m for help): p
disk /dev/sdb: 8589 mb, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
units = sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disk identifier: 0x740e36e3
device boot start end blocks id system
/dev/sdb1 63 4194367 2097152+ 83 linux
/dev/sdb2 4194368 16777215 6291424 5 extended
/dev/sdb5 4194431 8388735 2097152+ 83 linux
/dev/sdb6 8388799 16777215 4194208+ 83 linux以sdb6為例,可以看到分區的十六進制編碼是83,即普通的linux分區。
修改分區類型的十六進制編碼
//t命令:改寫分區十六進制編碼
command (m for help): t
partition number (1-6): 6
//l命令可以查看不同分區的十六進制編碼,交換分區為82
hex code (type l to list codes): 82
changed system type of partition 6 to 82 (linux swap / solaris)
command (m for help): p
disk /dev/sdb: 8589 mb, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
units = sectors of 1 * 512 = 512 bytes
sector size (logical/physical): 512 bytes / 512 bytes
i/o size (minimum/optimal): 512 bytes / 512 bytes
disk identifier: 0x740e36e3
device boot start end blocks id system
/dev/sdb1 63 4194367 2097152+ 83 linux
/dev/sdb2 4194368 16777215 6291424 5 extended
/dev/sdb5 4194431 8388735 2097152+ 83 linux
/dev/sdb6 8388799 16777215 4194208+ 82 linux swap / solaris
//分區表寫入磁盤并退出
command (m for help): w
the partition table has been altered!
calling ioctl() to re-read partition table.
syncing disks.格式化交換分區
mkswap /dev/sdb6
setting up swapspace version 1, size = 4194204 kib
no label, uuid=40eff2c0-3f6b-440e-bc2a-f71d3d5581a7啟用交換分區
swapon /dev/sdb6
查看交換分區加載狀態
free
total used free shared buffers cached
mem: 1030108 160768 869340 264 12040 56188
-/+ buffers/cache: 92540 937568
swap: 6291352 0 6291352停用交換分區
swapoff /dev/sdb6
p.s.
不能直接使用mount命令掛載swap分區,因為swap分區是沒有掛載點的。
直接修改/etc/fstab配置文件,使系統啟動時自動掛載:
/dev/sdb6 swap swap defaults 0 0
//查看交換分區
swapon -s
filename type size used priority
/dev/sda2 partition 2097148 0 -1
/dev/sdb6 partition 4194204 0 -2
主機托管和云服務器哪個好云服務器便宜文檔介紹內容麻煩幫忙看一下系統的域名也打不開Surface Book/Pro 4更新并未解決睡眠問題:微軟表示正在努力修復2022最新服務器數據備份方式方法匯總域名交易如何劃算?域名交易有何技巧?工信部副部長辛國斌:建設好工業互聯網大數據中心云資源服務器租賃費