新購買的Linux云服務器,數據盤未做分區和格式化,無法使用。
可以通過自動格式化和手動格式化兩種方式對Linux云服務器數據盤進行格式化。
注:
(1)格式化后,數據盤中的數據將被全部清空。請在格式化之前,確保數據盤中沒有數據或對重要數據已進行備份。
(2)為避免服務發生異常,格式化前請確保云服務器已停止對外服務。
首先檢查是否有數據盤:
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
看到數據盤的路徑是/dev/vdb
如果沒有對硬盤進行分區,請執行以下硬盤分區命令:
fdisk /dev/vdb
依次輸入 n 、p、 1、 回車、回車、wq
這里的VDB是我們上面看到數據硬盤的名稱
格式化分區
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 ~]#
掛載分區
mount /dev/vdb1 /www
[root@VM_77_80_centos ~]# mount /dev/vdb1 /www
設置開機自動掛載分區
[root@VM_77_80_centos ~]# echo '/dev/vdb1 /www ext3 defaults 0 0' >> /etc/fstab
驗證數據盤是否已經掛載好了,這里我們已經看到/dev/vdb1已經掛載上去了。
[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
可以通過自動格式化和手動格式化兩種方式對Linux云服務器數據盤進行格式化。
注:
(1)格式化后,數據盤中的數據將被全部清空。請在格式化之前,確保數據盤中沒有數據或對重要數據已進行備份。
(2)為避免服務發生異常,格式化前請確保云服務器已停止對外服務。
首先檢查是否有數據盤:
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
看到數據盤的路徑是/dev/vdb
如果沒有對硬盤進行分區,請執行以下硬盤分區命令:
fdisk /dev/vdb
依次輸入 n 、p、 1、 回車、回車、wq
這里的VDB是我們上面看到數據硬盤的名稱
格式化分區
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 ~]#
掛載分區
mount /dev/vdb1 /www
[root@VM_77_80_centos ~]# mount /dev/vdb1 /www
設置開機自動掛載分區
[root@VM_77_80_centos ~]# echo '/dev/vdb1 /www ext3 defaults 0 0' >> /etc/fstab
驗證數據盤是否已經掛載好了,這里我們已經看到/dev/vdb1已經掛載上去了。
[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