FreeBSD disk Mount

Source: Internet
Author: User
Tags ide hard drive dmesg

Recommendations before Operation:

Just put out the system, want to let FreeBSD csh like bash press TAB to list the candidate files can not be filled, add the following in the/ETC/CSH.CSHRC, and then log off the login again:

#vi/ETC/CSH.CSHRC

Set Autolist

Blog Environment:

System version: Freebsd8.2-64bit

Kernel parameters:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/DE/wKiom1WrwE-R287lAACqoSkpToM837.jpg "title=" Kernel 0719.png "alt=" Wkiom1wrwe-r287laacqoskptom837.jpg "/>

1. First check whether the newly added disk is recognized by the system:


DMESG | grep "Sector" | awk ' {print $1,$2} '

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/DE/wKiom1WrwRaA7OHvAACs0EXftL4497.jpg "title=" Dmesg0719.png "alt=" Wkiom1wrwraa7ohvaacs0exftl4497.jpg "/>

The first column represents the hard drive identified by the system, and the second column represents the disk size; I have three plates here: da0, da1, da2;

DA1 and Da2 is I just hung up the plate, no partition, can be gpart show command to view, the blog will be a brief introduction of the basic concept of the FreeBSD disk partition;

The current default file system type is visible: Freebsd-ufs

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/DE/wKiom1WrwgzD3hg3AAEvu0UwkDE054.jpg "style=" float: none; "title=" Ufs0719.png "alt=" Wkiom1wrwgzd3hg3aaevu0uwkde054.jpg "/>

Now you need to mount the hard drive da1, the current mount situation is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/DE/wKiom1Wrwg2SThnvAADU55kiKRk931.jpg "style=" float: none; "title=" Df0719.png "alt=" Wkiom1wrwg2sthnvaadu55kikrk931.jpg "/>


2, FreeBSD recommended disk partitioning method is provided with Sysinstall menu options, in addition, in the BSD system, you can also use the Fdisk command to divide the slice partition (can understand the main partition), Disklabel/bsdlabel to partition the extended partition;

2.1, the following is carried out with Sysinstall:

#sysinstall

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/DE/wKiom1WrwrPhEyiyAANJNAVwiFs345.jpg "style=" float: none; "title=" Sysinstall0719.png "alt=" Wkiom1wrwrpheyiyaanjnavwifs345.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/DE/wKiom1WrwrWB9u2kAANHFSJoHug176.jpg "style=" float: none; "title=" Fdisk0719.png "alt=" Wkiom1wrwrwb9u2kaanhfsjohug176.jpg "/>

Select the disks you want to partition:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/DB/wKioL1WrxJfBHlXzAAIvOJynnCc217.jpg "style=" float: none; "title=" Disk0719.png "alt=" Wkiol1wrxjfbhlxzaaivojynncc217.jpg "/>

A use the entire disk C to create the slice partition D Delete W to write the changes formally to the disk:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/DE/wKiom1Wrwrjxhny-AAHo_obCbc8977.jpg "style=" float: none; "title=" Slice0719.png "alt=" Wkiom1wrwrjxhny-aaho_obcbc8977.jpg "/>

Use a to select the entire disk; I'm going to put the da1 in two. Mount to/data1 and/data2 two directories respectively;

Press disk C to enter the partition size:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/DB/wKioL1WrxYvwnh7kAAJa1YRnyY4584.jpg "style=" float: none; "title=" Dsize0719.png "alt=" Wkiol1wrxyvwnh7kaaja1yrnyy4584.jpg "/>

Select the partition type, default 165 is slice,131 to ext2fs,130 for swap;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/DE/wKiom1Wrw6yT32nKAAKn6_17bUE962.jpg "style=" float: none; "title=" Dtype0719.png "alt=" Wkiom1wrw6yt32nkaakn6_17bue962.jpg "/>

Two slice partitions are built as follows, then W writes, select Yes:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6F/DB/wKioL1WrxhXgr_SrAAHo_obCbc8703.jpg "title=" Slice0719.png "alt=" Wkiol1wrxhxgr_sraaho_obcbc8703.jpg "/>

Install the bootloader here Optional none is not installed because the first disk has already been installed:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/DE/wKiom1Wrw63TmgVQAAKtToM5Kio210.jpg "style=" float: none; "title=" None0719.png "alt=" Wkiom1wrw63tmgvqaakttom5kio210.jpg "/>

OK after see write successfully 100% is successful, q back to the previous Fdisk interface, select the Edit disk label:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/DE/wKiom1WrxUTBoxhlAAMxw5ZHq7c817.jpg "style=" float: none; "title=" Lable0719.png "alt=" Wkiom1wrxutboxhlaamxw5zhq7c817.jpg "/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/DB/wKioL1Wrx46C68C0AAHkeNECWC0041.jpg "title=" Da10719.png "alt=" Wkiol1wrx46c68c0aahkenecwc0041.jpg "/>

On the previously built 2 slice partitions, c new extension, partition type file system, and specify mount point (Mount directory/data1 and/data2 have been built in advance)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/DE/wKiom1WrxUbzflsrAAKXgdNbBI8551.jpg "style=" float: none; "title=" Fs.png "alt=" Wkiom1wrxubzflsraakxgdnbbi8551.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/DB/wKioL1Wrxyfiv-dzAAIYhcwk7rE091.jpg "style=" float: none; "title=" Data20719.png "alt=" Wkiol1wrxyfiv-dzaaiyhcwk7re091.jpg "/>

Exit after completion, df-h view mount Status:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/DE/wKiom1WrxUfjyTKoAAEiRnu1XLw090.jpg "style=" float: none; "title=" Dfh0719.png "alt=" Wkiom1wrxufjytkoaaeirnu1xlw090.jpg "/>

You can also see the newly created partition with Gpart show:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6F/DB/wKioL1WryC_x9AqZAAIMgVMpvw4282.jpg "title=" Gt0719.png "alt=" Wkiol1wryc_x9aqzaaimgvmpvw4282.jpg "/>


3, edit Fatab file, realize the boot mount, reboot verify:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6F/DB/wKioL1WryHDSiQw_AAEjZT7jrG8762.jpg "title=" Fatab0719.png "alt=" Wkiol1wryhdsiqw_aaejzt7jrg8762.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6F/DB/wKioL1WryJTgITjHAAEbITsyvEE046.jpg "title=" Dh0719.png "alt=" Wkiol1wryjtgitjhaaebitsyvee046.jpg "/>



The following excerpt from the Red Alliance Linux Forum: http://www.linuxdiyf.com/bbs/thread-79059-1-1.html


First, the basic concept.
The operating system installed on all PC architectures can only be divided into four partitions. These four partitions are different in different operating systems, in Windows and Linux, often referred to as primary partitions (primary partition), and in BSD-style UNIX and Solaris systems known as Slice (English is originally intended to be small fragments, Do not know whether there is a good translation to express). Slice and the primary partition are the same concept, the operating system installed on the PC can recognize such a primary partition based on the partition table in the MBR. In Windows and Linux, a hard disk can be divided into four primary partitions, one of which can be used as an extended partition, and a logical partition in the extended partition, while the other three primary partitions can only be used as the smallest partition units. That is, you can select only one extended partition and then divide the logical partition in the extended partition. The number of logical partitions included in the extended partition can be many, check the data, a statement is up to 64, has not been specifically verified, but anyway this number is larger, you can divide the hard disk thin enough.
FreeBSD, however, can be divided into smaller partition units in each slice, in the slice of the hard disk in FreeBSD, this smaller partition unit is called partition, and its concept is similar to the concept of logical partitioning in Windows and Linux. This smaller partition unit is represented by a lowercase letter, a-h, with 8, but the C partition has a special meaning, and the C partition represents the entire slice (primary partition) where the partition resides. As in Solaris/DEV/DSK/C0T0D0C2 partitions, C0T0D0C2 represents the entire disk in the Solaris system of the SPARC system, because there are no other device names in Solaris that represent the entire disk. Conceptually, the/dev/ad0s1c in FreeBSD equates to/dev/ad0s1.
Therefore, in FreeBSD, a hard disk can be divided (8-1) x4 = 28 partitions. The original FreeBSD system, logical partition D also has a special purpose, that is, in the old version of the FreeBSD system, each hard disk can be divided (8-2) X4 = 24 partitions, but now the D partition's special use has been diluted, Although Sysinstall will try to avoid using the D partition when partitioning the logical partition with Sysinstall, the D partition identifier can also be identified as a normal data storage partition today through experimental validation. Therefore, take the IDE hard drive as an example the partition number that is normally available for the first hard drive in FreeBSD is:/dev/ad0s1a/dev/ad0s2a/dev/ad0s3a/dev/ad0s4a/dev/ad0s1b/dev/ad0s2b/dev /ad0s3b/dev/ad0s4b/dev/ad0s1d/dev/ad0s2d/dev/ad0s3d/dev/ad0s4d/dev/ad0s1e/dev/ad0s2e/dev/ad0s3e/dev/ad0s4e/dev /ad0s1f/dev/ad0s2f/dev/ad0s3f/dev/ad0s4f/dev/ad0s1g/dev/ad0s2g/dev/ad0s3g/dev/ad0s4g/dev/ad0s1h/dev/ad0s2h/dev /ad0s3h/dev/ad0s4h
Second, the use of the partition tool under FreeBSD.
The most convenient partitioning method under FreeBSD is to use the menu options provided by Sysinstall to complete the partitioning of partition (slice) and sub-logical partitions (Partiton) according to the prompts. This method is relatively simple and easy to learn.
Today I mainly learned about the use of command-line tools Fdisk and Disklabel (aka Bsdlabel).
First, Fdisk is used to divide the primary partition, that is, to divide the slice, which is very different from the Linux system.
General usage: DD if=/dev/zero of=/dev/ad0 bs=1k count=1 #目的是先清除硬盘上原有的分区表, new hard drive can skip this step.
FDISK-BI/DEV/AD0 creates a primary partition (slice) on a #在硬盘/dev/ad0.
Looking at the man document of fdisk, parameter B indicates that a standard boot record is written to the MBR of the hard disk. The I option means that the entire hard disk is divided into a slice. That is, the command line partition tool, Fdisk can only partition a primary partition on a hard disk, you should use the-f parameter plus the configuration file can be defined and divided into four primary partitions, but the light with the parameters provided by Fdisk, it seems that only one can be divided. At this point, the FreeBSD command-line partitioning tool is not human-friendly, or it is easier to partition using the interface provided by Sysinstall.
Use of Disklabel/bsdlabel:
Disklabel-b-w/dev/ad0s1 Auto Disklabel-e/dev/ad0s1
The Bsdlabel man document is viewed, and parameter b indicates that the bootstrapper is written to the primary partition. According to Handbook's description of the FreeBSD boot process, the B parameter of FDISK indicates that boot0 (512 bytes) is written to the MBR of the hard disk, whereas the B parameter in Bsdlabel indicates that the primary partition is written to the boot record (not the master boot record) in the primary partition. That is, BOOT1 (512 bytes, written in the first sector of the primary partition) and Boot2 (about 8K, written in a specific area of the partition, not in the file system). The parameter w is write, which means that it is written and can also be read with the R parameter.
[Auto] means that a logical partition is automatically partitioned in the primary partition, somewhat similar to the I parameter in Fdisk. If you do not add auto parameters, then use DISKLABEL-E/DEV/AD0S1 to partition the logical partition, Disklabel will automatically open an editor, let you manually enter the logical partition size, offset, and so on, and then save the information you edit to partition the logical partitions. The information required to manually write a logical partition requires knowledge of the hard disk, but the benefit is that it is free to arrange information such as the starting position, size, and partition name of the logical partition, and more than 7 available partitions and a special C partition can be made more easily according to FreeBSD rules. The advantage of automatically dividing a logical partition with auto parameter numbers is that there is no need to have a deeper end to the hard disk, and the disadvantage is that only one logical partition can be divided.
The DISKLABEL-E/dev/ad0s1 command is used to write information such as the starting position of the logical partition in the primary partition (slice).
After the execution of this command, in the/dev/directory will automatically generate device files ad0s1a and ad0s1c, if it is to manually edit the logical partition information generated multiple partitions,/dev will have a corresponding device file generation, with Newfs to create the file system can be used to partition the logical.
The above commands are described in Handbook, but not in such detail, today, according to the experimental and man documents, as well as their own understanding, write down these memo records, the above understanding should be correct.
In summary, the Fdisk tool is used to divide the primary partition (slice), his operand is the first sector (MBR) of the hard disk, the standard bootstrapper (BOOT0) is written in the MBR, and the partition information of the primary partition. The Disklabel/bsdlabel is used to divide the logical partition in the primary partition, his operation object is the first sector of the primary partition of the hard disk, and some special areas, used to write to the boot program of the second, The third step (BOOT1 and Boot2) and the partition information and identification number of the logical partition that is located in the primary partition.
In general, it is not convenient or intuitive to partition with Fdisk and Disklabel/bsdlabel, Sysinstall should be a quick and intuitive choice.
By reading the relevant documents and experiments and comparing with other operating system partitioning methods and concepts, we have a clearer understanding of the concept of the partition of FreeBSD and the use of partitioning tools.
Three, a group of interesting experiments
In the course of the experiment, we found an interesting phenomenon, that is, in FreeBSD, whether the entire hard disk/dev/ad0 the entire primary partition/DEV/AD0S1 or the logical partition in the primary partition/DEV/AD0S1A
You can use NEWFS to create the file system directly and then hang it in a directory.
First, I do the following for a hard disk that does not have any partitions: newfs/dev/ad0 mount/dev/ad0/mnt
Found that there is no error and warning message, the hard disk without partition directly can be used, actually tested, and indeed correct.
The disk is then divided into four primary partitions, and then the file system is created on four primary partitions:
NEWFS/DEV/AD0S1 newfs/dev/ad0s2 newfs/dev/ad0s3 NEWFS/DEV/AD0S4
MOUNT/DEV/AD0S1/MNT/1 MOUNT/DEV/AD0S2/MNT/2 MOUNT/DEV/AD0S3/MNT/3 MOUNT/DEV/AD0S4/MNT/4
There are also no errors and warnings, and these primary partitions can be used directly after the file system is created without further partitioning of the logical partition.
Finally, a few logical partitions are divided into four primary partitions, which can be used after the file system is created, which is the default way to use the hard disk in FreeBSD.
I even created the file system on the C logical partition representing the entire primary partition: Newfs/dev/ad0s1c mount/dev/ad0s1c/mnt can also be used, of course, if other logical partitions are broken, this usage destroys other logical partitions, This usage and: newfs/dev/ad0s1 mount/dev/ad0s1/mnt should be consistent.
The experiment concludes: In FreeBSD, the hard disk does not need partition, can create file system directly and use the hard disk.
The benefit of creating partitions is that you can coexist on a hard disk with other operating systems.
After the above experiment was done on the FreeBSD system, I thought I could also use the whole hard disk without partitioning the partition on Linux.
An instant experiment confirmed that my idea was correct, except that the Linux create File System command, MKFS.EXT3, would warn you to create a file system and mount it to the system directly on a hard drive without partitions, just by answering yes.
The command is as follows: Mkfs.ext3/dev/sdb mke2fs 1.32 (09-nov-2002)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) Y
Mount/dev/sdb/mnt
The above experiment shows that in the operating system, hard disk partitioning is not required, partitioning is for better management of files and coexistence with other systems.
Excerpt of the Code:
DD If=/dev/zero of=/dev/ad0 bs=1k count=1 #目的是先清除硬盘上原有的分区表
Fdisk-bi/dev/ad0 Creating a primary partition (slice) on a #在硬盘/dev/ad0
Disklabel-b-w/dev/ad0s1 Auto Disklabel-e/dev/ad0s1
For i in ' egrep ' ^ (ad|aacd|mlxd|mlyd|amrd|idad|twed|da|ar|ips|) [0-9]: "/var/run/dmesg.boot | Cut-d ': '-f1 | Sort | Uniq '
Do
Ln= "' Cat/var/run/dmesg.boot | grep ^ $i | grep MB ' ">/dev/null
Echo ${ln}
Fdisk/dev/${i} >/tmp/${i}
found= "1"
Done
#!/bin/sh
#Get our Device Name
Device=${1}
#Erase any existing bootloader
DD If=/dev/zero Of=/dev/${device} count=1024
Sleep 2
Fdisk-i-b/dev/${device}
# Install New Partition Setup
Fdisk-f/tmp/fdiskconfig/dev/${device}
Sleep 1

This article is from the "Jx_ Trench" blog, please be sure to keep this source http://xujunxian.blog.51cto.com/8614409/1676207

FreeBSD disk Mount

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.