xen中xencenter安装centos77是否可以在线扩展硬盘

&nbsp>&nbsp
&nbsp>&nbsp
&nbsp>&nbsp
CentOS7下根分区扩容
摘要:为更好熟悉CentOS7,日前在PC上安装了VirtualBox软件来跑CentOS7练练手。虚机CentOS7暂采用1CoreCPU,2GMem,10GDisk配置,最小化安装并升级下系统后快照备份存档以备后用,后期可根据需要随时调整配置。今天准备整个PostgreSQL玩玩的,首先需要对10G的磁盘进行扩展。安装系统时选择的是默认分区方案,root分区是用lvm管理的,分区格式是xfs。如下所示:[~]#df-ThFilesystem
为更好熟悉CentOS7,日前在PC上安装了VirtualBox软件来跑CentOS7练练手。虚机CentOS7暂采用1Core CPU,2G Mem,10G Disk配置,最小化安装并升级下系统后快照备份存档以备后用,后期可根据需要随时调整配置。
今天准备整个PostgreSQL玩玩的,首先需要对10G的磁盘进行扩展。安装系统时选择的是默认分区方案,root分区是用lvm管理的,分区格式是xfs。如下所示:
~]# df -Th
Filesystem TypeSizeUsed Avail Use% Mounted on
/dev/mapper/centos_myprecious-root xfs 8.5G855M7.7G10% /
devtmpfs devtmpfs487M 0487M 0% /dev
tmpfstmpfs 497M 0497M 0% /dev/shm
tmpfstmpfs 497M6.5M491M 2% /run
tmpfstmpfs 497M 0497M 0% /sys/fs/cgroup
/dev/sda1xfs 497M124M374M25% /boot
tmpfstmpfs 100M 0100M 0% /run/user/0
所以扩展root分区就很容易了。首先再添加一块虚拟磁盘到虚机,重启后 fdisk -l 查看虚拟磁盘是否被识别。如下,可以看到新增磁盘被标记为 /dev/sdb ,有53.7G的空间。
~]# fdisk -l
Disk /dev/sda: 10.7 GB,bytes,sectors
Units = sectors of1*512=512bytes
Sector size (logical/physical):512bytes /512bytes
I/O size (minimum/optimal):512bytes /512bytes
Disk label type: dos
Disk identifier: 0x0008ee5f
Device BootStart EndBlocks IdSystem
/dev/sda1 *
/dev/sda8eLinux LVM
Disk /dev/sdb: 53.7 GB,bytes,sectors
Units = sectors of1*512=512bytes
Sector size (logical/physical):512bytes /512bytes
I/O size (minimum/optimal):512bytes /512bytes
Disk /dev/mapper/centos_myprecious-root: 8.3 GB,bytes,sectors
Units = sectors of1*512=512bytes
Sector size (logical/physical):512bytes /512bytes
I/O size (minimum/optimal):512bytes /512bytes
Disk /dev/mapper/centos_myprecious-swap:1073MB,bytes,2097152sectors
Units = sectors of1*512=512bytes
Sector size (logical/physical):512bytes /512bytes
I/O size (minimum/optimal):512bytes /512bytes
惯例,为 /dev/sdb 磁盘创建分区,如下:
~]# 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 0x4cb24dcf.
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-624152, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-624152, default 624152):
Using default value 624152
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0Empty 24NEC DOS 81Minix / old Lin bfSolaris
1FAT12 39Plan 982Linux swap / So c1DRDOS/sec (FAT-
2XENIX root3cPartitionMagic83Linux c4DRDOS/sec (FAT-
3XENIX usr 40Venix 80286 84OS/2 hidden C:c6DRDOS/sec (FAT-
4FAT16 &32M41PPC PReP Boot 85Linux extendedc7Syrinx
5Extended42SFS 86NTFS volume set daNon-FS data
6FAT16 4dQNX4.x87NTFS volume set dbCP/M / CTOS / .
7HPFS/NTFS 4eQNX4.x 2nd part 88Linux plaintext deDell Utility
8AIX 4fQNX4.x 3rd part 8eLinux LVM dfBootIt
9AIX bootable50OnTrack DM93Amoebae1DOS access
aOS/2 Boot Manag 51OnTrack DM6 Aux 94Amoeba BBTe3DOS R/O
bW95 FAT32 52CP/M9fBSD/OSe4SpeedStor
cW95 FAT32 (LBA) 53OnTrack DM6 Aux a0IBM Thinkpad hi ebBeOS fs
eW95 FAT16 (LBA) 54OnTrackDM6a5FreeBSD eeGPT
fW95 Ext'd (LBA) 55EZ-Drivea6OpenBSD efEFI (FAT-12/16/
10OPUS56Golden Bowa7NeXTSTEPf0Linux/PA-RISC b
11Hidden FAT125cPriam Edisk a8Darwin UFSf1SpeedStor
12Compaq diagnost 61SpeedStor a9NetBSDf4SpeedStor
14Hidden FAT16 &3 63GNU HURD or Sys abDarwin boot f2DOS secondary
16Hidden FAT1664Novell NetwareafHFS / HFS+fbVMware VMFS
17Hidden HPFS/NTF 65Novell Netwareb7BSDI fs fcVMware VMKCORE
18AST SmartSleep70DiskSecure Mult b8BSDI swap fdLinux raid auto
1bHidden W95 FAT3 75PC/IX bbBoot Wizard hid feLANstep
1cHidden W95 FAT3 80Old Minix beSolaris bootffBBT
1eHidden W95 FAT1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 53.7 GB,
16 heads, 63 sectors/track, 624152 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: 0x4cb24dcf
Device BootStart EndBlocks IdSystem
/dev/sdb1 eLinux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
整块磁盘 /dev/sdb 被分区为 /dev/sdb1 ,将该分区格式化为 xfs 。
~]# mkfs.xfs -f /dev/sdb1
查看并创建物理卷PV:
~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos_myprecious
PV Size 9.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE2434
Allocated PE2434
PV UUID bE8O8-syyl-TSyE-p9Bv-sZEJ-GkE-vNC4XB
~]# pvcreate /dev/sdb1
Physical volume &/dev/sdb1& successfully created
~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos_myprecious
PV Size 9.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE2434
Allocated PE2434
PV UUID bE8O8-syyl-TSyE-p9Bv-sZEJ-GkE-vNC4XB
&/dev/sdb1& is a new physical volume of &53.7 GiB&
--- NEW Physical volume ---
PV Name /dev/sdb1
PV Size 53.7 GiB
Allocatable NO
Allocated PE0
PV UUID Z7hoj-Ub4d-xLr3-z7ti-Z5zM-oVTv-TuLtv7
以上,PV /dev/sdb1 已创建完成,但未被分配。将PV /dev/sdb1 分配到系统的卷组VG上,这里为 centos_myprecious ,如下:
~]# vgdisplay
--- Volume group ---
VG Name centos_myprecious
Formatlvm2
Metadata Areas2
Metadata Sequence No5
VG Access read/write
VG Status resizable
VG Size 59.50 GiB
PE Size 4.00 MiB
Total PE15233
Alloc PE / Size 13065 / 51.04 GiB
FreePE / Size 2168 / 8.47 GiB
VG UUID jvcc7L-quO1-MQOz-KDX3-v4QN-ES9G-q4h7H7
~]# vgextend centos_myprecious /dev/sdb1
Physical volume &/dev/sdb1& successfully created
Volume group &centos_myprecious& successfully extended
在分配完卷组后,就可以见卷组中未分配的空间分配给root分区了,这里为 /dev/sdb1 分区。
~]# lvdisplay
--- Logical volume ---
LV Path/dev/centos_myprecious/root
LV Nameroot
VG Namecentos_myprecious
LV UUIDKqVmPb-MNpe-VPmH-ato8-aeVU-JbOz-HNgG0M
LV Write Accessread/write
LV Creation host, time myprecious,
14:35:34 +0800
LV Statusavailable
LV Size8.47 GiB
Current LE 2168
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path/dev/centos_myprecious/swap
LV Nameswap
VG Namecentos_myprecious
LV UUID4HGA1K-1bYu-Vvmx-j70O-l0U7-NwvG-etzOF6
LV Write Accessread/write
LV Creation host, time myprecious,
14:35:33 +0800
LV Statusavailable
LV Size1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
~]# lvextend -l 100%FREE /dev/centos_myprecious/root
Size of logical volume centos_myprecious/root changed from 8.47 GiB (2168 extents) to 50.04 GiB (12809 extents).
Logical volume root successfully resized.
~]# e2fsck -f /dev/centos_myprecious/root
e2fsck 1.42.9 (28-Dec-2013)
/dev/centos_myprecious/root is mounted.
e2fsck: Cannot continue, aborting.
~]# resize2fs /dev/centos_myprecious/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/centos_myprecious/root
Couldn't find valid filesystem superblock.
FilesystemSizeUsed Avail Use% Mounted on
/dev/mapper/centos_myprecious-root8.5G854M7.7G10% /
devtmpfs487M 0487M 0% /dev
tmpfs 497M 0497M 0% /dev/shm
tmpfs 497M6.5M491M 2% /run
tmpfs 497M 0497M 0% /sys/fs/cgroup
/dev/sda1 497M124M374M25% /boot
tmpfs 100M 0100M 0% /run/user/0
在使用 resize2fs 操作后报错,查看分区信息发现根分区并没有变多,甚至重启后执行 resize2fs 操作依旧报错。之前的 centos6 扩展 ext2 / ext3 / ext4 明明都是好好的,问题出在哪儿呢?查找资料,发现是 resize2fs 不能扩展 xfs 分区所致。扩展 xfs 分区需要使用 xfs_growfs 。如下:
~]# xfs_growfs /dev/centos_myprecious/root
meta-data=/dev/mapper/centos_myprecious-root isize=256agcount=4, agsize=555008 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0finobt=0
data = bsize=4096 blocks=2220032, imaxpct=25
= sunit=0swidth=0 blks
naming =version 2bsize=4096 ascii-ci=0 ftype=0
log=internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2220032 to
FilesystemSizeUsed Avail Use% Mounted on
/dev/mapper/centos_myprecious-root 51G904M 50G 2% /
devtmpfs487M 0487M 0% /dev
tmpfs 497M 0497M 0% /dev/shm
tmpfs 497M6.5M491M 2% /run
tmpfs 497M 0497M 0% /sys/fs/cgroup
/dev/sda1 497M124M374M25% /boot
tmpfs 100M 0100M 0% /run/user/0
使用 xfs_growfs 后,根分区被正常扩展。没注意到 centos7 中根分区已经有 centos6 中的 ext4 变更为 xfs ,相应的扩展分区的命令变更为 xfs_growfs 。
看来有时候真的不能想当然,不经意的一个小小的变动有可能导致满盘皆输。
谢谢你请我喝可乐
以上是的内容,更多
的内容,请您使用右上方搜索功能获取相关信息。
若你要投稿、删除文章请联系邮箱:zixun-group@service.aliyun.com,工作人员会在五个工作日内给你回复。
云服务器 ECS
可弹性伸缩、安全稳定、简单易用
&40.8元/月起
预测未发生的攻击
&24元/月起
为您提供0门槛上云实践机会
你可能还喜欢
你可能感兴趣
阿里云教程中心为您免费提供
CentOS7下根分区扩容相关信息,包括
的信息,所有CentOS7下根分区扩容相关内容均不代表阿里云的意见!投稿删除文章请联系邮箱:zixun-group@service.aliyun.com,工作人员会在五个工作日内答复
售前咨询热线
服务与支持
账号与支持
关注阿里云
InternationalCentOS中安装Xen虚拟机的简单方法
互联网 & 07-08 16:51:36 & 作者:佚名 &
这篇文章主要介绍了在CentOS系统中安装Xen虚拟机的教程,同样适用于Redhat系的其他Linux系统,需要的朋友可以参考下
一、xen虚拟环境准备方法一,可以在安装时选择xen组件后,系统自然支持xen。方法二,在需要时手动安装xen组件。
1. yum自动安装xen组件代码如下:# yum install kernel-xen xen-libs xen
2. 修改启动列表,使用运行xen的内核启动系统代码如下:# vi /boot/grub/grub.confdefault=0title CentOS (2.6.18-194.3.1.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-194.3.1.el5
module /vmlinuz-2.6.18-194.3.1.el5xen ro root=LABEL=/
module /initrd-2.6.18-194.3.1.el5xen.img
说明: yum安装后,grub菜单是自动安装好了。如果没有的话,手动加入,/boot菜单下会有相关的内核文件。
3. reboot 自动进入xen组件的内核。
4. 查看xen启动(1)将xen设为开机启动代码如下:# chkconfig --list |grep xendxend
6:offxendomains
(2)xen的运行情况(以下内容表示已经启动了)代码如下:# xm listName
Mem(MiB) VCPUs State
Time(s)Domain-0
5.创建安装源在Xen虚拟机半虚拟环境中安装Linux虚拟系统时需要使用系统的安装源。可以使用HTTP、FTP或NFS等方式提供给Xen虚拟机用于系统的安装。这里采用ftp方式进行安装。代码如下:# yum install -y vsftpd# service vsftpd start# mount /dev/cdrom /var/ftp/pub/说明: vsftpd安装好后就支持匿名访问。
二、XEN虚拟机安装1. 创建虚拟机代码如下:# virt-install --prompt
What is the name of your virtual machine? centos5How much RAM should be allocated (in megabytes)? 256What would you like to use as the disk (file path)? /data/test.img&/p&
&p&#说明: 这里可以直接采用事先划分好的lvm逻辑卷分区做为xen虚拟机磁盘。#例如: /dev/lvmdata/var01How large would you like the disk(/data/test.img) to be (in gigabytes)? 3What is the install URL? ftp://192.168.44.141/pub/&/p&
&p&Starting install...Retrieving file .treeinfo...
00:00Retrieving file vmlinuz...
00:00Retrieving file initrd.img...
00:00Creating storage file...
&p&#直到安装完毕,中间采用字符界面进行安装,安装过程与光盘字符模式安装一样,也可以采用vnc图形界面方式安装,这里省略。&/p&
&p&# xm listName
ID Mem(MiB) VCPUs State
Time(s)Domain-0
1781.7centos5
31.5testos
2. 进入centos5虚拟主机的控制台代码如下:# xm console centos5# ctrl+] 退出虚拟化控制台
大家感兴趣的内容
12345678910
最近更新的内容他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)散文吧网站海不择细流,故能成其大。山不拒细壤,方能就其高。}

我要回帖

更多关于 centos 硬盘扩展 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信