Linux挂载新磁盘并进行分区 发表于 2018-01-26 | 分类于 Linux , Disk | | 本文总阅读量 次 由于业务需要,某台DB的磁盘使用满了。刚好使用的那台机子是虚拟机,就直接在ESXi上划了一块磁盘来用。之前没做过,跟着相关教程做一下。顺带将新挂载的盘作为禅道迁移的服务器。 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131# 查看现有的磁盘分区[root@KE_03 ~]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000f3a29 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 1332 10485760 83 Linux/dev/sda3 1332 2479 9216000 83 Linux/dev/sda4 2479 2611 1063936 5 Extended/dev/sda5 2479 2610 1048576 82 Linux swap / SolarisDisk /dev/sdb: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000[root@KE_03 ~]# cd /opt[root@KE_03 opt]# ls[root@KE_03 opt]# ll总用量 0# 查看分区文件[root@KE_03 opt]# ll /dev/disk/by-by-label/ by-path/ by-uuid/[root@KE_03 opt]# ll /dev/disk/by-path/总用量 0lrwxrwxrwx 1 root root 9 1月 18 22:19 pci-0000:00:07.1-scsi-1:0:0:0 -> ../../sr0lrwxrwxrwx 1 root root 9 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sdalrwxrwxrwx 1 root root 10 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1lrwxrwxrwx 1 root root 10 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2lrwxrwxrwx 1 root root 10 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:0:0-part3 -> ../../sda3lrwxrwxrwx 1 root root 10 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:0:0-part4 -> ../../sda4lrwxrwxrwx 1 root root 10 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:0:0-part5 -> ../../sda5lrwxrwxrwx 1 root root 9 1月 18 22:19 pci-0000:00:10.0-scsi-0:0:1:0 -> ../../sdb# 查看已有的磁盘分区[root@KE_03 opt]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 8.7G 1.2G 7.1G 15% /tmpfs 491M 0 491M 0% /dev/shm/dev/sda1 194M 27M 158M 15% /boot/dev/sda2 9.9G 151M 9.2G 2% /export# [root@KE_03 opt]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x7f800bb1.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-5221, default 1):Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221):Using default value 5221Command (m for help): pDisk /dev/sdb: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x7f800bb1 Device Boot Start End Blocks Id System/dev/sdb1 1 5221 41937651 83 LinuxCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.# [root@KE_03 opt]# mkfs.mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.ext4dev# [root@KE_03 opt]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)文件系统标签=操作系统:Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks2621440 inodes, 10484412 blocks524220 blocks (5.00%) reserved for the super user第一个数据块=0Maximum filesystem blocks=4294967296320 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正在写入inode表: 完成Creating journal (32768 blocks): 完成Writing superblocks and filesystem accounting information: 完成This filesystem will be automatically checked every 31 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@KE_03 opt]# mount /dev/sdbsdb sdb1[root@KE_03 opt]# mount /dev/sdb1 /opt# 将sdb1设置[root@KE_03 opt]# echo "/dev/sdb1 /opt ext4 default 0 0" >> /etc/fstab -------------本文结束 感谢您的阅读-------------