CentOS新增硬盘 新增 VMWare(ESX)硬盘

本文发布时间: 2019-Mar-22
当你的 CentOS 安装在虚拟主机 vmware 环境下,如果想新增一颗硬碟该怎么做呢?我们来聊聊处理的方法!!首先,你必须先在 vmware 的环境里,增加一颗磁碟给 CentOS (传统就是在主机上多插一颗硬碟)然后,在到 CentOS 找到并将这颗磁碟给 mount 起来。S1:想在 vmware 的环境里增加一颗磁碟,你可以在 Guest OS 的名称上点滑鼠右键,然后选「Edit Settings」进行环境设定S2:在硬体页签里「Add」磁碟 Hard DiskS3:这个步骤可以让你选新增一颗磁碟,或是去挂载 mount 已存在的磁碟S4:设定磁碟大小及选择 Data Provisioning 的方式S5:对应的 device Node,这项不用改他,系统会依序的增加,所以直接下一步S6:最后确认各项设定是否如你所想设定「Finish」后重新启动 Guest OS 让他去抓到这个新硬体,然后开始进入『CentOS 怎么新增硬碟』的步骤步骤我用底下列点的方式呈现,至于完整的画面,就请大家看更底下方框中的执行过程。dmesg | grep sdb // 先察看开机过程有没找到新的硬碟(因为是第2颗所以是 sdb) sudo blkid //察看目前挂载硬碟的UUID,blkid: command-line utility to locate/print block device attributes sudo fdisk -l // 列出目前抓到的硬碟资讯 sudo fdisk /dev/sdb //开始对 sdb 硬碟做 fdisk 初始化 sudo mkfs.ext4 -L data200G /dev/sdb1 //对sdb 硬碟做格式化 sudo blkid // 再观察刚刚加进来的 sdb 是否加入了 sudo mkdir /home/www //建立 mount point 目录 sudo vi /etc/fstab //修改 fstab 档案 sudo mount -a // 全部挂载 fstab 里有记载的 partition df -h // 观察磁碟空间 设定「Finish」后重新启动 Guest OS 让他去抓到这个新硬体,然后开始进入『CentOS 怎么新增硬碟』的步骤步骤我用底下列点的方式呈现,至于完整的画面,就请大家看更底下方框中的执行过程。[[email protected] ~]$ more /etc/fstab # /etc/fstab# Created by anaconda on Fri Apr 19 15:09:58 2013## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=e1b0ddc7-94c0-4600-86c0-0759c8ed3732 / ext4 defaults 1 1UUID=723260b1-a847-4324-8756-374024dc0431 swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0[[email protected] ~]$ man blkid[[email protected] ~]$ sudo blkid/dev/sda2: UUID="e1b0ddc7-94c0-4600-86c0-0759c8ed3732" TYPE="ext4" /dev/sda1: UUID="723260b1-a847-4324-8756-374024dc0431" TYPE="swap" [[email protected] ~]$ dmesg | grep sdbsd 2:0:1:0: [sdb] 419430400 512-byte logical blocks: (214 GB/200 GiB)sd 2:0:1:0: [sdb] Write Protect is offsd 2:0:1:0: [sdb] Mode Sense: 61 00 00 00sd 2:0:1:0: [sdb] Cache data unavailablesd 2:0:1:0: [sdb] Assuming drive cache: write throughsd 2:0:1:0: [sdb] Cache data unavailablesd 2:0:1:0: [sdb] Assuming drive cache: write through sdb: unknown partition tablesd 2:0:1:0: [sdb] Cache data unavailablesd 2:0:1:0: [sdb] Assuming drive cache: write throughsd 2:0:1:0: [sdb] Attached SCSI disk [[email protected] ~]$ sudo fdisk -lDisk /dev/sda: 55.8 GB, 55834574848 bytes64 heads, 32 sectors/track, 53248 cylindersUnits = cylinders of 2048 * 512 = 1048576 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000a8759Device Boot Start End Blocks Id System/dev/sda1 2 2001 2048000 82 Linux swap / SolarisPartition 1 does not end on cylinder boundary./dev/sda2 * 2002 53248 52476928 83 LinuxPartition 2 does not end on cylinder boundary.Disk /dev/sdb: 214.7 GB, 214748364800 bytes255 heads, 63 sectors/track, 26108 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000[[email protected] ~]$ sudo fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x06d9f3c4.Changes will remain in memory only, until you decide to write them.After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-26108, default 1): Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): EnterUsing default value 26108Command (m for help): pDisk /dev/sdb: 214.7 GB, 214748364800 bytes255 heads, 63 sectors/track, 26108 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x06d9f3c4 Device Boot Start End Blocks Id System/dev/sdb1 1 26108 209712478+ 83 LinuxCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[[email protected] ~]$ cat /proc/partitionsmajor minor #blocks name 8 0 54525952 sda 8 1 2048000 sda1 8 2 52476928 sda2 8 16 209715200 sdb 8 17 209712478 sdb1[[email protected] ~]$ sudo mkfs.ext4 -L data200G /dev/sdb1mke2fs 1.41.12 (17-May-2010)Filesystem label=data200GOS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks13107200 inodes, 52428119 blocks2621405 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=42949672961600 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[[email protected] ~]$ sudo blkid/dev/sda2: UUID="e1b0ddc7-94c0-4600-86c0-0759c8ed3732" TYPE="ext4" /dev/sda1: UUID="723260b1-a847-4324-8756-374024dc0431" TYPE="swap" /dev/sdb1: LABEL="data200G" UUID="89a79c32-7914-48ca-ba50-b2c67ae9dfb7" TYPE="ext4" [[email protected] ~]$ sudo mkdir /home/www/[[email protected] ~]$ sudo vi /etc/fstab //注1*[[email protected] ~]$ sudo mount -a[[email protected] ~]$ df -h档案系统 Size Used Avail Use% 挂载点/dev/sda2 50G 3.7G 44G 8% /tmpfs 1.9G 228K 1.9G 1% /dev/shm/dev/sdb1 197G 188M 187G 1% /home/www//注1* CentOS 挂载磁碟的 fstab 有三种写法#1 使用 UUID,这个 UUID 千万别抄我的阿,要看你的 blkid 执行出来的结果UUID="89a79c32-7914-48ca-ba50-b2c67ae9dfb7" /home/www ext4 defaults 1 2#2 使用 Device Name/dev/sdb1 /home/www ext4 defaults 1 2#3 使用 partition Label Name 也就是前面的 data200G,前面格式化若没指定 -L 那就不要用这个方法啰!反正 Label 在 unix 里也不太重要。LABEL=data200G /home/www ext4 defaults 1 2


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2019-May-25 12:57pm
栏目列表