Linux系统磁盘管理详解(6)

#创建分区/dev/sdb1 [root@cobbler-node1 ~]# fdisk -cu /dev/sdb Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +1G Command (m for help): p Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders, total 4194304 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: 0x000a3ee6 Device Boot Start End Blocks Id System /dev/sdb1 2048 2099199 1048576 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. #格式化分区类型为swap [root@cobbler-node1 ~]# mkswap /dev/sdb1 Setting up swapspace version 1, size = 1048572 KiB no label, UUID=546425d3-0a71-4f5b-9295-10dccee357da [root@cobbler-node1 ~]# free -m total used free shared buffers cached Mem: 474 94 380 0 10 30 -/+ buffers/cache: 52 422 Swap: 1023 0 1023 #启用用于分页和交换的设备和文件 [root@cobbler-node1 ~]# swapon /dev/sdb1 [root@cobbler-node1 ~]# free -m total used free shared buffers cached Mem: 474 94 380 0 10 30 -/+ buffers/cache: 53 421 Swap: 2047 0 2047 #追加到/etc/fstab开机随系统启动 [root@cobbler-node1 ~]# echo "/dev/sdb1 swap swap defaults 0 0" >> /etc/fstab #显示正在使用的虚拟交换空间 [root@cobbler-node1 ~]# swapon -s Filename Type Size Used Priority /dev/sda2 partition 1048568 0 -1 /dev/sdb1 partition 1048568 0 -2

6.2 使用文件构建swap

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12101.html