新購(gòu)買的Linux云服務(wù)器,數(shù)據(jù)盤未做分區(qū)和格式化,無(wú)法使用。
可以通過自動(dòng)格式化和手動(dòng)格式化兩種方式對(duì)Linux云服務(wù)器數(shù)據(jù)盤進(jìn)行格式化。
注:
(1)格式化后,數(shù)據(jù)盤中的數(shù)據(jù)將被全部清空。請(qǐng)?jiān)诟袷交?,確保數(shù)據(jù)盤中沒有數(shù)據(jù)或?qū)χ匾獢?shù)據(jù)已進(jìn)行備份。
(2)為避免服務(wù)發(fā)生異常,格式化前請(qǐng)確保云服務(wù)器已停止對(duì)外服務(wù)。
首先檢查是否有數(shù)據(jù)盤:
fdisk -l
[root@VM_77_80_centos ~]# fdisk -l
Disk /dev/vda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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: 0x000736d7
Device Boot Start End Blocks Id System
/dev/vda1 * 1 1045 8387584 83 Linux
Note: sector size is 4096 (not 512)
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 56 sectors/track, 29257 cylinders
Units = cylinders of 896 * 4096 = 3670016 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xd1ff745a
Device Boot Start End Blocks Id System
/dev/vdb1 1 29257 104856864 83 Linux
Disk /dev/vdc: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
看到數(shù)據(jù)盤的路徑是/dev/vdb
如果沒有對(duì)硬盤進(jìn)行分區(qū),請(qǐng)執(zhí)行以下硬盤分區(qū)命令:
fdisk /dev/vdb
依次輸入 n 、p、 1、 回車、回車、wq
這里的VDB是我們上面看到數(shù)據(jù)硬盤的名稱
格式化分區(qū)
mkfs.ext3 /dev/vdb1
[root@VM_77_80_centos ~]# mkfs.ext3 /dev/vdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
6553600 inodes, 26214216 blocks
1310710 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@VM_77_80_centos ~]#
掛載分區(qū)
mount /dev/vdb1 /www
[root@VM_77_80_centos ~]# mount /dev/vdb1 /www
設(shè)置開機(jī)自動(dòng)掛載分區(qū)
[root@VM_77_80_centos ~]# echo '/dev/vdb1 /www ext3 defaults 0 0' >> /etc/fstab
驗(yàn)證數(shù)據(jù)盤是否已經(jīng)掛載好了,這里我們已經(jīng)看到/dev/vdb1已經(jīng)掛載上去了。
[root@VM_77_80_centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 7.9G 2.6G 5.0G 35% /
/dev/vdb1 99G 188M 94G 1% /www
可以通過自動(dòng)格式化和手動(dòng)格式化兩種方式對(duì)Linux云服務(wù)器數(shù)據(jù)盤進(jìn)行格式化。
注:
(1)格式化后,數(shù)據(jù)盤中的數(shù)據(jù)將被全部清空。請(qǐng)?jiān)诟袷交?,確保數(shù)據(jù)盤中沒有數(shù)據(jù)或?qū)χ匾獢?shù)據(jù)已進(jìn)行備份。
(2)為避免服務(wù)發(fā)生異常,格式化前請(qǐng)確保云服務(wù)器已停止對(duì)外服務(wù)。
首先檢查是否有數(shù)據(jù)盤:
fdisk -l
[root@VM_77_80_centos ~]# fdisk -l
Disk /dev/vda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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: 0x000736d7
Device Boot Start End Blocks Id System
/dev/vda1 * 1 1045 8387584 83 Linux
Note: sector size is 4096 (not 512)
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 56 sectors/track, 29257 cylinders
Units = cylinders of 896 * 4096 = 3670016 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xd1ff745a
Device Boot Start End Blocks Id System
/dev/vdb1 1 29257 104856864 83 Linux
Disk /dev/vdc: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
看到數(shù)據(jù)盤的路徑是/dev/vdb
如果沒有對(duì)硬盤進(jìn)行分區(qū),請(qǐng)執(zhí)行以下硬盤分區(qū)命令:
fdisk /dev/vdb
依次輸入 n 、p、 1、 回車、回車、wq
這里的VDB是我們上面看到數(shù)據(jù)硬盤的名稱
格式化分區(qū)
mkfs.ext3 /dev/vdb1
[root@VM_77_80_centos ~]# mkfs.ext3 /dev/vdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=0 blocks
6553600 inodes, 26214216 blocks
1310710 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@VM_77_80_centos ~]#
掛載分區(qū)
mount /dev/vdb1 /www
[root@VM_77_80_centos ~]# mount /dev/vdb1 /www
設(shè)置開機(jī)自動(dòng)掛載分區(qū)
[root@VM_77_80_centos ~]# echo '/dev/vdb1 /www ext3 defaults 0 0' >> /etc/fstab
驗(yàn)證數(shù)據(jù)盤是否已經(jīng)掛載好了,這里我們已經(jīng)看到/dev/vdb1已經(jīng)掛載上去了。
[root@VM_77_80_centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 7.9G 2.6G 5.0G 35% /
/dev/vdb1 99G 188M 94G 1% /www