[Linux]vbox 虚拟机加入新磁盘
2023-09-11 14:14:59 时间
情况是这种,開始创建虚拟机的时候硬盘设置太小了。仅仅有10g,我如今通过vbox的设置给这个linux(centos6.6)虚拟机加入了一块硬盘。
以下的操作就是怎么把硬盘挂载到系统中。
通过 fdisk查看如今物理磁盘的信息(这个要用root权限才行)
以下操作均是root权限。
[root@orangleliu ~]# fdisk -l
...
Disk /dev/sdb: 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: 0x00000000
...
写分区表
以下是个交互是过程,每次输入之后依据提示。在进行输入
[root@orangleliu ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa4378777.
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-3916, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-3916, default 3916):
Using default value 3916
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
操作完之后我们再来看磁盘信息
# fdisk -l
...
Disk /dev/sdb: 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: 0xa4378777
Device Boot Start End Blocks Id System
/dev/sdb1 1 3916 31455238+ 83 Linux
...
多了一块分区信息
格式化分区
一个命令就能够搞定了
# mkfs.ext4 /dev/sdb1
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
1966080 inodes, 7863809 blocks
393190 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
240 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
创建新卷标(可忽略)
这一步,我看到有些人做了,有些人没有做,于是查了下资料。
能够看下參考 e2label命令
后面没用上,能够不操作的。
# e2label /dev/sdb1 /data
检查一下
# e2label /dev/sdb1
/data
挂载
创建挂载文件夹,跟上一步一致
mkdir /data
为了开机自己主动挂载。还须要编辑 /etc/fstab
文件,文件后面加入一行
/dev/sdb1 /data ext4 defaults 0 0
有些可能对这个配置文件不太熟悉,请參见[fatab中文解释](https://wiki.archlinux.org/index.php/Fstab_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
測试
# mount -a
# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_orangleliu-lv_root
6.5G 3.2G 3.0G 52% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 477M 29M 424M 7% /boot
/dev/sdb1 30G 44M 28G 1% /data
然后重新启动下。再次查看挂载情况,正常挂载。成功。
相关文章
- 【Linux】linux之如何清理磁盘空间
- 每天一个linux命令(24):Linux文件类型与扩展名
- 【Linux基础】linux updatedb命令
- Linux 批量查找并替换文件夹下所有文件的内容
- Linux deepin下普通用户免密切换至root用户
- 使用xshell链接本地虚拟机中的Linux
- L65.linux命令每日一练 -- 第十章 Linux网络管理命令 -- ifdown和route
- L55.linux命令每日一练 -- 第八章 Linux磁盘与文件系统管理命令 -- mkswap和swapon
- L53.linux命令每日一练 -- 第八章 Linux磁盘与文件系统管理命令 -- dd和mount
- L35.linux命令每日一练 -- 第五章 Linux信息显示与搜索文件命令 -- which和whereis
- 嵌入式linux开发,交叉编译qt4.8.5报错:bin/qmake: Exec format errorThe tslib functionality test failed! You migh
- kali linux 设置不休眠
- XP用户:消除误解,大胆拥抱Linux
- linux安装redis及主从复制、读写分离、哨兵模式
- Linux实验报告六【命令vim、cat、echo、grep、wc的使用】和【shell脚本的编译运行】
- 完美解决VMware虚拟机 Linux系统 Ubuntu 20.04 硬盘/磁盘扩容的问题(超级超级详细)
- 安装VMware虚拟机操作到Linux联网时显示线缆被拔出解决方法(以太网不可用)
- Linux驱动之GPIO子系统