分区挂载
介绍配置分区挂载的操作步骤。
说明:
- 如果实际规划中只设置一个RAID组,则不需要关注本节内容。
- 如果系统需要两个RAID组,请参照如下操作步骤,将第二个RAID组的分区/dev/sdb1挂载到/share/voice路径下。
- 以root用户登录操作系统。
- 在桌面空白处单击右键,在弹出的快捷菜单中选择“Open in Terminal”。
系统显示“Terminal”界面。
- 执行fdisk -l命令查看存储设备,记录存储设备的设备名和磁盘大小,注意不是服务器的本地硬盘。
系统显示信息如下:
Disk /dev/sdb: 1.359 TB, 1389564975705 bytes 255 heads, 63 sectors/track, 109053 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table //显示此信息说明/dev/sdb分区未创建。 Disk /dev/sda: 146.0 GB, 145999527936 bytes 255 heads, 63 sectors/track, 17750 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0001371f Device Boot Start End Blocks Id System /dev/sda1 1 1566 12578863+ 82 Linux swap / Solaris /dev/sda2 * 1567 2871 10482412+ 83 Linux /dev/sda3 2872 5481 20964825 83 Linux /dev/sda4 5482 17750 98550742+ f W95 Ext'd (LBA) /dev/sda5 5482 6133 5237158+ 83 Linux /dev/sda6 6134 7177 8385898+ 83 Linux /dev/sda7 7178 7829 5237158+ 83 Linux /dev/sda8 7830 10439 20964793+ 83 Linux /dev/sda9 10440 16966 52428096 83 Linux
- 执行mkdir -p /share/voice命令,在/share路径下创建voice文件夹。
说明:此处以 /dev/sdb1 挂载到 /share/voice为例创建分区,请您根据实际情况操作。
- 执行fdisk /dev/sdb命令创建分区,将第二个RAID组的所有磁盘空间划分为一个分区。
系统显示信息如下:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x7f0fbc21. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 109053. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help):m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n //输入n,创建新分区。 Command action e extended p primary partition (1-4) p //输入p,创建一个主分区。 artition number (1-4): 1 //输入1作为分区号。 First cylinder (1-109053, default 1): //按Enter使用默认值作为分区起始点。 Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-109053, default 109053): //按Enter使用默认值作为分区终止点。 Using default value 109053 Command (m for help): t //输入t修改分区类型 Selected partition 1 Hex code (type L to list codes): 8e //输入8e设置分区类型为“Linux LVM”。 Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): p //输入p检查配置是否正确。显示的信息中如果System项为“Linux LVM”,表明配置正确。 Disk /dev/sdb: 1.359 TB, 1389564975705 bytes 255 heads, 63 sectors/track, 109393 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x09b4cb6e Device Boot Start End Blocks Id System /dev/sdb1 1 109393 1389564975705 8e Linux LVM Command (m for help): w //输入w保存数据。 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
说明:说明:如果创建错误或重新创建,请输入 fdisk /dev/sdb,在提示输入命令时,输入 d删除已有分区,然后输入 w保存设置,然后再重新创建分区即可。 - 执行fdisk -l命令查看到新生成的分区列表。
如果在显示信息中,查看到如下信息,表示分区成功。
Disk /dev/sdb: 1.359 TB, 1389564975705 bytes 255 heads, 63 sectors/track, 109053 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x7f0fbc21 Device Boot Start End Blocks Id System /dev/sdb1 1 109393 1389564975705 8e Linux LVM
- 执行mkfs.ext3 /dev/sdb1命令将新生成的分区创建文件系统。
创建ext3文件系统的时间较长,具体时间由创建文件系统的大小决定,请耐心等待。创建完成,显示信息如下:
mke2fs 1.41.9 (22-Aug-2009) Filesystem label= OS type:Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 54755328 inodes, 218992047 blocks 10949602 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 6684 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 20 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
- 修改配置文件。
为了保证服务器重新启动后仍能挂载分区,进行如下操作。
- 执行vi /etc/fstab命令。
- 在/etc/fstab文件中,按“i”,开始编辑文件。
- 在“/etc/fstab文件”界面中红色方框的位置添加如下语句:/dev/sdb1/share/voice ext3 defaults 0 0
输入语句完成,如图1所示。
- 按“Esc”,退出编辑。
- 输入“:wq”,保存修改并退出文件。
- 执行mount /dev/sdb1命令,将/dev/sdb1挂载到/share/voice路径下。
- 挂载完毕后,通过df -h命令查看挂载是否成功。
Filesystem Size Used Avail Use% Mounted on /dev/sda2 9.9G 382M 9.5G 4% / devtmpfs 3.9G 144K 3.9G 1% /dev tmpfs 3.9G 968K 3.9G 1% /dev/shm /dev/sda7 20G 173M 20G 1% /home /dev/sda3 20G 295M 20G 2% /opt /dev/sda8 50G 180M 50G 1% /share /dev/sda6 5.0G 139M 4.8G 3% /tmp /dev/sda4 7.9G 7.1G 899M 83% /usr /dev/sda5 7.9G 261M 7.7G 4% /var /dev/sr1 2.9G 2.9G 0 100% /media/SLES-11-SP1-DVD-x86_64.0432..001 /dev/sdb1 1.359T 201M 1.359T 1% /share/voice
显示/dev/sdb1分区并且成功挂载到/share/voice路径下,说明挂载成功。