Managing switching devices in FreeBSD

Source: Internet
Author: User
Tags file system

In the FreeBSD system, the switching device is very important, and it needs to leave enough swap space for the FreeBSD. When the system load is very large, the lack of swap space can also affect the system's execution process. You should usually set the system swap space to 1-2.5 times times the physical memory. Because swap space is used as a virtual memory and exchange data with physical memory, it should be set to a high speed hard drive, or the swap space may be distributed across multiple hard disks to balance the load. FreeBSD uses different swap partitions in a staggered manner, so if you distribute the swap partitions on different hard disks, you can improve the access speed of the switching device. Typically, FreeBSD uses Disklabel for B devices as a switching device that can be used to add swap devices to FreeBSD on other disks or use files for Exchange during the system's operation.

To increase the switching device, first create a new disklabel along the previous procedure, using B as the Disklabel for swap space. Then modify the/etc/fstab file and add a line to the description of the switching device. Or use Swapon to immediately make the allocated swap space effective.

If you want to use a file for swap space, first create a file in the system to be exchanged, and then change the/etc/rc.conf to point the Swapfile argument to the file.

# dd if=/dev/zero of=swapfile bs=10240 count=1024

In fact, the swap file is first mapped to a pseudo storage device VN before it can be installed in the system. Therefore, to use the swap file, the kernel is required to support the pseudo storage device vn, and the default kernel supports a VN device vn0. This pseudo storage device can be accessed directly, and the work of increasing the interchange file is done manually. The first thing to do is to associate the swap file with the pseudo device, and then handle the pseudo device as if it were a real device. You need to use the Vncon Fig command to associate files with a pseudo device.

# vnconfig /dev/vn0c swapfile
# vnconfig -u /dev/vn0c

You can use the vnconfig with the-u parameter again to detach from the existing file the pseudo storage device that is already associated with the file, first requiring that the pseudo device not be used by the system, such as vn0c is not used as a swap device or has been uninstalled from the system. By using the-e parameter in the Vnconfig command, you can join the exchange directly using Vnconfig without the need to use the Swapon command again:

# vnconfig -e /dev/vn0c swapfile swap

The use of pseudo storage devices is not only for exchanging files, but also for installing virtual file systems. It can therefore be used to manage the image files of floppy disks or optical discs.

# dd if=/dev/rfd0 of=imgfile
# vnconfig vn0c imgfile
# mount -t msdos /dev/vn0c /mnt

If it is not a mirror file generated from a floppy disk like the example above, but rather to re-establish the file system, the type of disk should be noted. Since the size of the pseudo device is determined by the generated file, the type of disk that corresponds to the pseudo device is clearly not a standard disk type, and the system obviously cannot detect disk types from the pseudo device, so you need to specify the disk types when generating the disklabel of the disk and Newfs formatting. Generally, because the size of the mirror file is not identical to the size of the standard disk data, it is necessary to generate the new disk type data in the/etc/disktab in order to take full advantage of the pseudo device size.

# vnconfig /dev/vn0c imgfile
# disklabel -r -w vn0 fd1440
# newfs -T fd1440 vn0c
# mount /dev/vn0c /mnt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.