[[email protected] ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root ext4 8.3G 937M 7.0G 12% / tmpfs tmpfs 119M 0 119M 0% /dev/shm /dev/vda1 ext4 477M 33M 419M 8% /boot [[email protected] ~]# 生成一块新的硬盘 [[email protected] virhost]# qemu-img create -f raw o5cache.add.disk.raw 2G Formatting ‘05cache.add.disk.raw‘, fmt=raw size=2147483648 <disk type=‘file‘ device=‘disk‘> <driver name=‘qemu‘ type=‘raw‘ cache=‘none‘/> <source file=‘/home/virhost/05cache.add.disk.raw‘/> <target dev=‘vda‘ bus=‘virtio‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x07‘ function=‘0x0‘/> </disk> [[email protected] virhost]# virsh start 05cache Domain 05cache started [[email protected] virhost]# virsh attach-disk 05cache /home/virhost/05cache.add.disk.raw vdb --cache none Disk attached successfully virsh edit 05cache----------------> <disk type=‘file‘ device=‘disk‘> <driver name=‘qemu‘ type=‘raw‘ cache=‘none‘/> <source file=‘/home/virhost/05cache.img‘/> <target dev=‘vda‘ bus=‘virtio‘/> <address type=‘pci‘ domain=‘0x0000‘ bus=‘0x00‘ slot=‘0x05‘ function=‘0x0‘/> </disk> <disk type=‘block‘ device=‘cdrom‘> <driver name=‘qemu‘ type=‘raw‘/> <target dev=‘hdc‘ bus=‘ide‘/> <readonly/> <address type=‘drive‘ controller=‘0‘ bus=‘1‘ target=‘0‘ unit=‘0‘/> </disk> [[email protected] ~]# fdisk -l Disk /dev/vda: 10.7 GB, 10737418240 bytes 16 heads, 63 sectors/track, 20805 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: 0x000c1fb8 Device Boot Start End Blocks Id System /dev/vda1 * 3 1018 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/vda2 1018 20806 9972736 8e Linux LVM Partition 2 does not end on cylinder boundary. Disk /dev/vdb: 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 Disk /dev/mapper/VolGroup-lv_root: 9168 MB, 9168748544 bytes 255 heads, 63 sectors/track, 1114 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 /dev/mapper/VolGroup-lv_swap: 1040 MB, 1040187392 bytes 255 heads, 63 sectors/track, 126 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
在虚拟机中对硬盘进行格式化
[[email protected] ~]# mkfs.ext4 /dev/vdb 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 131072 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
接下来建一个目录来挂载新的硬盘:
[[email protected] ~]# mkdir /nd [[email protected] ~]# mkdir /nd [[email protected] ~]# mount /dev/vdb /nd/ #获取硬盘的UUID [[email protected] ~]# blkid /dev/vdb/dev/vdb: UUID="a35e0890-3aa6-47a7-921c-c2cb9dd431e6" TYPE="ext4"
将挂载添加到开机启动中:
[[email protected] ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Jun 28 08:57:38 2016 # # 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 # /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1 UUID=04e8e77f-2604-4683-833b-a06a7300c7a3 /boot ext4 defaults 1 2 /dev/mapper/VolGroup-lv_swap swap swap defaults 0 0 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 UUID=a35e0890-3aa6-47a7-921c-c2cb9dd431e6 /nd ext4 defaults 1 2
[[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 8.3G 644M 7.3G 9% / tmpfs 119M 0 119M 0% /dev/shm /dev/vda1 477M 33M 419M 8% /boot /dev/vdb 2.0G 3.0M 1.9G 1% /nd
时间: 2024-10-07 22:49:37