1、mkfs.ext4后down机
Azure上新建的vm。准备安装oracle数据库,可是挂载的磁盘,初始化后,直接down机了。例如以下图。失去连接,xshell窗体直接断开退出了。看以下图片
021.png
尝试过一下办法:
(1) azure管理界面。重新启动vm。再来一遍。还是down机。
(2) 删除这台vm,重建一台新的vm。还是一样仅仅要运行mkfs.ext4 /dev/sdc直接down机。
(3) 在别的区建vm。不在东区建在北区建。还是一样。
2、问题分析
曾经附加的磁盘,直接mkfs.ext4 /dev/sdc就能够了。如今为啥不行?去fdisk看磁盘信息:
(1)如今的fdisk –l中的/dev/sdc信息: Disk /dev/sdc: 1098.4 GB, 1098437885952 bytes 255 heads, 63 sectors/track, 133544 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes (2)曾经的fdisk –l中的/dev/sdc信息: Disk /dev/sdd: 1073.7 GB, 1073741824000 bytes 255 heads, 63 sectors/track, 130541 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 看到多了“Disk identifier: 0x00000000”信息,正式由于多了这个Disk identifier。才干直接进行mkfs.ext4了。 |
经过google之后,发现Disk identifier须要先分好区才会有。所以新的/dev/sdc磁盘不能直接mkfs.ext4的原因是还没有分好区,要用fdisk分好区之后。再能进行初始化操作。
3、fdisk磁盘分区
用fdisk进行磁盘分区:
[root@pldb2 ~]# fdisk /dev/sdc Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xd788cc0a. 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): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-133544, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-133544, default 133544): Using default value 133544 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): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@pldb2 ~]# |
再次查看,会有Disk identifier信息了。也有了新的分区/dev/sdc1,例如以下:
[root@pldb2 ~]# fdisk -l Disk /dev/sda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c23d3 Device Boot Start End Blocks Id System /dev/sda1 * 1 3789 30432256 83 Linux /dev/sda2 3789 3917 1024000 82 Linux swap / Solaris Disk /dev/sdb: 240.5 GB, 240518168576 bytes 255 heads, 63 sectors/track, 29241 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x40a7f99c Device Boot Start End Blocks Id System /dev/sdb1 1 29242 234879936 83 Linux Disk /dev/sdc: 1098.4 GB, 1098437885952 bytes 255 heads, 63 sectors/track, 133544 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xd788cc0a Device Boot Start End Blocks Id System /dev/sdc1 1 133544 1072692148+ 83 Linux |
4、mkfs.ext4进行分区初始化
# 使用 mkfs.ext4 命令格式化磁盘成格式化成ext4各式的文件系统。
[root@pldb2 ~]# mkfs.ext4 /dev/sdc1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 67043328 inodes, 268173037 blocks 13408651 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 8184 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 27 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@pldb2 ~]# |
例如以下图所看到的:
22.png
5、挂载磁盘加入启动载入
(1)開始挂载新的分区磁盘到/oracle [root@pldb2 ~]# mkdir /oracle [root@pldb2 ~]# mount /dev/sdc1 /oracle [root@pldb2 ~]# (2)开机启动挂载配置 [root@pldb2 ~]# vim /etc/fstab You have new mail in /var/spool/mail/root [root@pldb2 ~]# more /etc/fstab # # /etc/fstab # Created by anaconda on Wed Jan 15 04:45:47 2014 # # 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=6d089360-3e14-401d-91d0-378f3fd09332 / ext4 defaults 1 1 /dev/sdc1 /oracle ext4 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 [root@pldb2 ~]# |
OK。磁盘已经准备好了,能够正常安装oracle数据库了。